Repository navigation
Expand file tree
/
Copy pathsimple_chat.py
More file actions
74 lines (64 loc) · 2.78 KB
/
Copy pathsimple_chat.py
File metadata and controls
74 lines (64 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
"""
Simple chat interface without full LangChain agent - for testing.
"""
import sys
import os
from pathlib import Path
from dotenv import load_dotenv
# Add src to path
src_path = Path(__file__).parent / "src"
sys.path.insert(0, str(src_path))
from src.tools.simple_tools import SIMPLE_FUNCTIONS
from rich.console import Console
from rich.panel import Panel
# Load environment variables
load_dotenv()
console = Console()
def simple_chat():
"""Simple chat interface using our Things3 functions."""
console.print(Panel.fit("🤖 Simple Things3 Chat", style="bold blue"))
console.print("Available commands:")
console.print(" • 'today' - Show today's tasks")
console.print(" • 'work' - Show work tasks (AMPL)")
console.print(" • 'search <query>' - Search for tasks")
console.print(" • 'analyze <query>' - Analyze today view")
console.print(" • 'quit' - Exit")
console.print()
while True:
try:
user_input = console.input("[bold cyan]You:[/bold cyan] ").strip()
if user_input.lower() in ['quit', 'exit', 'bye']:
console.print("\n[yellow]Goodbye! 👋[/yellow]")
break
elif not user_input:
continue
elif user_input.lower() == 'today':
result = SIMPLE_FUNCTIONS['get_today_tasks']()
console.print(f"\n[bold green]Response:[/bold green]\n{result}\n")
elif user_input.lower() == 'work':
result = SIMPLE_FUNCTIONS['get_work_tasks']()
console.print(f"\n[bold green]Response:[/bold green]\n{result}\n")
elif user_input.lower().startswith('search '):
query = user_input[7:].strip()
if query:
result = SIMPLE_FUNCTIONS['search_tasks'](query)
console.print(f"\n[bold green]Response:[/bold green]\n{result}\n")
else:
console.print("[red]Please provide a search query[/red]\n")
elif user_input.lower().startswith('analyze '):
query = user_input[8:].strip()
if query:
result = SIMPLE_FUNCTIONS['analyze_today_view'](query)
console.print(f"\n[bold green]Response:[/bold green]\n{result}\n")
else:
console.print("[red]Please provide an analysis query[/red]\n")
else:
console.print("[yellow]Unknown command. Try 'today', 'work', 'search <query>', or 'analyze <query>'[/yellow]\n")
except KeyboardInterrupt:
console.print("\n[yellow]Goodbye! 👋[/yellow]")
break
except Exception as e:
console.print(f"[red]Error: {str(e)}[/red]\n")
if __name__ == "__main__":
simple_chat()