Skip to content

Commit

Permalink
Change package importing, and add posture
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfiero committed Nov 19, 2024
1 parent 0b8daba commit bd1c2d1
Show file tree
Hide file tree
Showing 7 changed files with 607 additions and 21 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ Use a swarm of AI agents to generate a marketing plan for your business.
ai marketing-plan
```

### 8. Posture Coach (`ai posture`)

Use the webcam and a tiny vision model to analyze your posture and focus.

```bash
ai posture
```

## Tool Use Tools (`tooluse` command)

### 1. Podcast RSS Reader (`tooluse`)
Expand Down
114 changes: 110 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tool-use-ai"
version = "1.1.6"
version = "1.1.10"
description = "Tools to simplify life with AI"
authors = ["Ty Fiero <[email protected]>", "Mike Bird <[email protected]>"]
readme = "README.md"
Expand Down
35 changes: 19 additions & 16 deletions src/tool_use/cli.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import sys
import argparse
import subprocess
import pkg_resources
from importlib.metadata import version, PackageNotFoundError
from .scripts._script_dependencies import SCRIPT_DEPENDENCIES
from .scripts import ai_cli, cal, obsidian_plugin, convert, transcribe, prioritize, activity_tracker, marketing_agency
from .utils.config_wizard import setup_wizard, SCRIPT_INFO


Expand All @@ -13,8 +12,8 @@ def ensure_dependencies(script_name):

for package in SCRIPT_DEPENDENCIES[script_name]:
try:
pkg_resources.require(package)
except (pkg_resources.DistributionNotFound, pkg_resources.VersionConflict):
version(package)
except PackageNotFoundError:
print(f"Installing required dependency: {package}")
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "--upgrade", package]
Expand Down Expand Up @@ -44,6 +43,7 @@ def main():
"prioritize": "Brain dump and prioritize tasks",
"log": "Track your activities",
"marketing-plan": "Use a marketing agency of AI agents to create a marketing plan",
"posture": "Use the webcam and a tiny vision model to analyze your posture and focus",
}

for name, help_text in all_scripts.items():
Expand All @@ -68,22 +68,25 @@ def main():

# Try to import dependencies, install if missing
ensure_dependencies(script_name)

# Map script names to their modules
# Map script names to their module paths
script_modules = {
"do": ai_cli,
"make-obsidian-plugin": obsidian_plugin,
"cal": cal,
"convert": convert,
"transcribe": transcribe,
"prioritize": prioritize,
"log": activity_tracker,
"marketing-plan": marketing_agency,
"do": "ai_cli",
"make-obsidian-plugin": "obsidian_plugin",
"cal": "cal",
"convert": "convert",
"transcribe": "transcribe",
"prioritize": "prioritize",
"log": "activity_tracker",
"marketing-plan": "marketing_agency",
"posture": "posture",
}

# Run the appropriate script
# Dynamic import of only the needed module
if script_name in script_modules:
script_modules[script_name].main(script_args)
module_name = script_modules[script_name]
module = __import__(f"tool_use.scripts.{module_name}", fromlist=["main"])
module.main(script_args)
else:
print(f"Unknown script: {script_name}")
sys.exit(1)
Expand Down
13 changes: 13 additions & 0 deletions src/tool_use/scripts/_script_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,17 @@
],
"log": [],
"marketing-plan": ["rich", "openai", "swarm"],
"posture": [
"moondream",
"rich",
"opencv-python",
"pillow",
"pydantic",
"llama-index",
"numpy>=1.22.4,<1.29.0",
"scipy>=1.10.0",
"transformers",
"llama-index",
"llama-index-llms-ollama",
],
}
Loading

0 comments on commit bd1c2d1

Please sign in to comment.