-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
62 lines (50 loc) · 2.01 KB
/
cli.py
File metadata and controls
62 lines (50 loc) · 2.01 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
import click
from agent import Agent
from tools import tool_registry
from util import function_to_payload
import models.user # noqa: F401
import models.appointment # noqa: F401
TOOL_MAP = tool_registry
TOOL_PAYLOADS = [function_to_payload(func) for func in tool_registry.values()]
DEFAULT_MODEL = "qwen3.5:latest"
DEFAULT_INSTRUCTION = (
"You are a assistant which use various tool do requested task "
"if not possible without any descirption just say i cant do this"
)
@click.group()
def cli():
"""Agent CLI - interact with the AI agent from your terminal."""
pass
@cli.command()
@click.option("--model", default=DEFAULT_MODEL, help="Model name to use.")
@click.option("--instruction", default=DEFAULT_INSTRUCTION, help="System instruction for the agent.")
@click.argument("message")
def ask(model: str, instruction: str, message: str):
"""Send a single message to the agent."""
agent = Agent(model, instruction, TOOL_PAYLOADS, tool_map=TOOL_MAP)
response = agent.chat(message)
for log in agent.tool_call_log:
click.echo(log)
click.echo(f"\nAgent: {response}")
@cli.command()
@click.option("--model", default=DEFAULT_MODEL, help="Model name to use.")
@click.option("--instruction", default=DEFAULT_INSTRUCTION, help="System instruction for the agent.")
def chat(model: str, instruction: str):
"""Start an interactive chat session with the agent."""
agent = Agent(model, instruction, TOOL_PAYLOADS, tool_map=TOOL_MAP)
click.echo("Agent chat started. Type 'exit' or 'quit' to end the session.\n")
while True:
try:
user_input = click.prompt("You", prompt_suffix="> ")
except (EOFError, KeyboardInterrupt):
click.echo("\nGoodbye!")
break
if user_input.strip().lower() in ("exit", "quit"):
click.echo("Goodbye!")
break
response = agent.chat(user_input)
for log in agent.tool_call_log:
click.echo(log)
click.echo(response)
if __name__ == "__main__":
cli()