-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
61 lines (46 loc) · 1.56 KB
/
main.py
File metadata and controls
61 lines (46 loc) · 1.56 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
import asyncio
import sys
import os
from dotenv import load_dotenv
from contextlib import AsyncExitStack
from mcp_client import MCPClient
from core.claude import Claude
from core.cli_chat import CliChat
from core.cli import CliApp
load_dotenv()
# Groq Config
groq_model = os.getenv("GROQ_MODEL", "llama-3.3-70b-versatile")
groq_api_key = os.getenv("GROQ_API_KEY", "")
assert groq_api_key, "Error: GROQ_API_KEY cannot be empty. Update .env"
async def main():
claude_service = Claude(model=groq_model)
server_scripts = sys.argv[1:]
clients = {}
command, args = (
("uv", ["run", "mcp_server.py"])
if os.getenv("USE_UV", "0") == "1"
else ("python", ["mcp_server.py"])
)
async with AsyncExitStack() as stack:
doc_client = await stack.enter_async_context(
MCPClient(command=command, args=args)
)
clients["doc_client"] = doc_client
for i, server_script in enumerate(server_scripts):
client_id = f"client_{i}_{server_script}"
client = await stack.enter_async_context(
MCPClient(command="uv", args=["run", server_script])
)
clients[client_id] = client
chat = CliChat(
doc_client=doc_client,
clients=clients,
claude_service=claude_service,
)
cli = CliApp(chat)
await cli.initialize()
await cli.run()
if __name__ == "__main__":
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
asyncio.run(main())