diff options
Diffstat (limited to 'client.py')
| -rw-r--r-- | client.py | 44 |
1 files changed, 16 insertions, 28 deletions
@@ -1,8 +1,17 @@ -import requests +from agent import Agent +from identity import load_agent_identity, load_user_profile +from llm import LLM -URL = "http://localhost:8080/v1/chat/completions" +llm = LLM("http://localhost:8080/v1/chat/completions",) -messages = [] +agent_identity = load_agent_identity("agent.toml") +user_profile = load_user_profile("user.toml") + +agent = Agent( + llm, + agent_identity, + user_profile, +) while True: user_input = input("You: ") @@ -10,30 +19,9 @@ while True: if user_input.lower() in {"exit", "quit"}: break - messages.append({ - "role": "user", - "content": user_input - }) - - response = requests.post( - URL, - json={ - "messages": messages, - "max_tokens": 256, - "temperature": 0.7, - } - ) - - if not response.ok: - print("Server error: ", response.text) - continue - - data = response.json() - answer = data["choices"][0]["message"]["content"] + print("Agent: ", end="", flush=True) - print(f"Agent: {answer}") + for chunk in agent.chat(user_input): + print(chunk, end="", flush=True) - messages.append({ - "role": "assistant", - "content": answer - }) + print() |
