summaryrefslogtreecommitdiff
path: root/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'client.py')
-rw-r--r--client.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/client.py b/client.py
new file mode 100644
index 0000000..0974650
--- /dev/null
+++ b/client.py
@@ -0,0 +1,39 @@
+import requests
+
+URL = "http://localhost:8080/v1/chat/completions"
+
+messages = []
+
+while True:
+ user_input = input("You: ")
+
+ 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
+ })