From 1048bc145cd0341fcbdd269f3275079bc40ede70 Mon Sep 17 00:00:00 2001 From: batsumaru <> Date: Fri, 11 Sep 2026 13:56:07 +0900 Subject: Added llm logic and config --- client.py | 48 ++++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) (limited to 'client.py') diff --git a/client.py b/client.py index 0974650..c983db1 100644 --- a/client.py +++ b/client.py @@ -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(f"Agent: {answer}") - - messages.append({ - "role": "assistant", - "content": answer - }) + print("Agent: ", end="", flush=True) + + for chunk in agent.chat(user_input): + print(chunk, end="", flush=True) + + print() -- cgit v1.3