Files
myorg-assistant/src/main.py

103 lines
2.7 KiB
Python
Raw Normal View History

2026-02-03 23:50:19 +01:00
"""Main entry point for MyOrg Assistant."""
import sys
import argparse
from pathlib import Path
def cli_mode() -> None:
"""Run in CLI mode for testing."""
from src.agent.core import MyOrgAgent
from src.agent.prompts import get_system_prompt
from src.tools.file_ops import get_file_operation_tools
from src.tools.task_ops import get_task_management_tools
from src.tools.calendar_ops import get_calendar_tools
from src.tools.git_ops import get_git_tools
from src.config import settings
print("🤖 MyOrg Assistant - CLI Mode")
print("=" * 50)
print("Type 'exit' or 'quit' to stop")
print("Type 'reset' to clear conversation history")
print("=" * 50)
print()
# Initialize agent with all tools
agent = MyOrgAgent(
system_prompt=get_system_prompt(),
tools=(
get_file_operation_tools() +
get_task_management_tools() +
get_calendar_tools() +
get_git_tools()
),
)
print(f"✅ Agent initialized with {len(agent.tools)} tools")
print(f"📁 Working with repository: {settings.myorg_repo_path}\n")
while True:
try:
# Get user input
user_input = input("You: ").strip()
if not user_input:
continue
if user_input.lower() in ['exit', 'quit']:
print("\n👋 Goodbye!")
break
if user_input.lower() == 'reset':
agent.reset_conversation()
print("🔄 Conversation history cleared\n")
continue
# Run agent
print("\nAssistant: ", end="", flush=True)
response = agent.run(user_input)
print(response)
print()
except KeyboardInterrupt:
print("\n\n👋 Goodbye!")
break
except Exception as e:
print(f"\n❌ Error: {str(e)}\n")
def bot_mode() -> None:
"""Run in Discord bot mode."""
from src.bot.discord_bot import run_bot
run_bot()
def web_mode() -> None:
"""Run in web server mode."""
from src.api.app import run_web
run_web()
def main() -> None:
"""Main entry point."""
parser = argparse.ArgumentParser(description="MyOrg Personal Assistant")
parser.add_argument(
"mode",
choices=["cli", "bot", "web"],
default="cli",
nargs="?",
help="Run mode: cli (default), bot (Discord), or web (FastAPI server)",
)
args = parser.parse_args()
if args.mode == "cli":
cli_mode()
elif args.mode == "bot":
bot_mode()
elif args.mode == "web":
web_mode()
if __name__ == "__main__":
main()