From 0762c40cec07cb434e35da86e45faa44c53115ac Mon Sep 17 00:00:00 2001 From: Max Value Date: Sat, 3 Jan 2026 20:51:34 +0000 Subject: [PATCH] revisit --- .gitignore | 1 + Makefile | 6 ++++++ commissioner.py | 10 ++++------ main.py | 5 +---- requirements.txt | 2 ++ 5 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 Makefile create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index a230a78..0c07feb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .venv/ __pycache__/ +api_key diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fb58856 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +all : .venv/touchfile + OPENAI_API_KEY="$$(cat api_key)" .venv/bin/flask --app main run --host 127.0.0.1 --port 5000 --debug + +.venv/touchfile : requirements.txt + python3 -m venv .venv + .venv/bin/python -m pip install -r requirements.txt diff --git a/commissioner.py b/commissioner.py index 19611a0..f98710c 100644 --- a/commissioner.py +++ b/commissioner.py @@ -1,5 +1,5 @@ import xml.etree.ElementTree as et -from ollama import Client +from openai import OpenAI import re class commissioner(): @@ -8,7 +8,7 @@ class commissioner(): self.log = [] self.dream = "" - self.client = Client(host='http://127.0.0.1:11434') + self.client = OpenAI() self.gamespace = """ @@ -49,9 +49,7 @@ class commissioner(): self.instability = 0 self.log = [] - response = self.client.chat(model='deepseek-r1:14b', messages=[{ - 'role': 'user', - 'content': f""" + response = self.client.responses.create(model='gpt-5-nano', input=f""" Below is some XML describing a card game.\n The outer element is the "cardGame" element. Inside the game there are the "player" elements (denoting players), the "message" element and "rule" elements (denoting the rules of the game that should be applied). "rule" elements have the attribute "lifespan" describing when they should be removed from "cardGame". "player" elements contain cards but also the "state" element.\n The state can either be "playing", "stuck", "bust" or "winner".\n @@ -60,7 +58,7 @@ class commissioner(): Card game XML follows:\n {self.gamespace} """ - }]) + ) think = re.search(r"[\n\D\d]*<\/think>", response.message.content) # get bounds of body = response.message.content[think.span()[1]:] # get body by removing diff --git a/main.py b/main.py index 43d171a..fe0d177 100755 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ lock = Lock() @app.route("/") def home(): - return render_template("index.html", title = 'Test') + return render_template("index.html") @app.route("/api") def get_gamespace(): @@ -58,6 +58,3 @@ def observe_rule(): with lock: c.observe() return "", 200 - -if __name__ == "__main__": - app.run(host='127.0.0.1', port=5000, debug=True) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a0e785c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +openai +flask -- 2.39.2