-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (48 loc) · 1.4 KB
/
main.py
File metadata and controls
62 lines (48 loc) · 1.4 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
#!/usr/bin/env python3
import asyncio
from typing import Optional, List
import typer
from rich.console import Console
from sdk import OllamaProvider
from cli.session import ChatSession
from cli.theme import Theme
from cli.interface import ChatInterface
app = typer.Typer(
name="cli",
help="Offline Function Calling CLI",
add_completion=False,
no_args_is_help=True,
)
@app.command()
def chat(
model_name: str = typer.Option(
"gemma3:12b-fc", "--model", "-m", help="The Ollama model to use"
),
ollama_host: str = typer.Option(
"http://localhost:11434", "--ollama", "-o", help="The Ollama server to use"
),
system_prompt: Optional[str] = typer.Option(
None, "--system", "-s", help="The system prompt to use"
),
tools_dir: Optional[List[str]] = typer.Option(
None, "--tools", "-t", help="Directory containing tool definitions"
),
):
"""A CLI for function-calling enabled offline agents."""
console = Console()
theme = Theme()
interface = ChatInterface(console, theme)
config = {
"provider": OllamaProvider(model_name, ollama_host),
"prompt": system_prompt,
"tools": tools_dir,
}
session = ChatSession(interface, config)
try:
asyncio.run(session.run())
except KeyboardInterrupt:
pass
finally:
interface.show_farewell()
if __name__ == "__main__":
app()