summaryrefslogtreecommitdiff
path: root/client.py
diff options
context:
space:
mode:
authorbatsumaru <>2026-09-11 13:56:07 +0900
committerbatsumaru <>2026-09-11 13:56:07 +0900
commit1048bc145cd0341fcbdd269f3275079bc40ede70 (patch)
tree54616ee011a4914a28e8f360237fbdc9492715c7 /client.py
parent9b51fae7d02669f3d7b43703b5e0b6731d2f32ce (diff)
Added llm logic and config
Diffstat (limited to 'client.py')
-rw-r--r--client.py44
1 files changed, 16 insertions, 28 deletions
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("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()