]> OzVa Git service - blackjack-gpt/commitdiff
revisit main
authorMax Value <greenwoodw50@gmail.com>
Sat, 3 Jan 2026 20:51:34 +0000 (20:51 +0000)
committerMax Value <greenwoodw50@gmail.com>
Sat, 3 Jan 2026 20:51:34 +0000 (20:51 +0000)
.gitignore
Makefile [new file with mode: 0644]
commissioner.py
main.py
requirements.txt [new file with mode: 0644]

index a230a78aea291ec7c0c35eefbc89b3898612a118..0c07febf0d26e7c369d2e18adf8258811bd47d79 100644 (file)
@@ -1,2 +1,3 @@
 .venv/
 __pycache__/
+api_key
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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
index 19611a013673cccbfa6dca1a630f72cf99805f51..f98710c06c5b3b02c2439e1a69278cd60b24e6a0 100644 (file)
@@ -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 = """
                        <cardGame>
@@ -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"<think>[\n\D\d]*<\/think>", response.message.content)       # get bounds of <think>
                body = response.message.content[think.span()[1]:]                                                       # get body by removing <think>
diff --git a/main.py b/main.py
index 43d171aee7356cee0892e17de86b81c59adc095d..fe0d1777e5ec5c7ce3ff2304b68d86f199b7ff9c 100755 (executable)
--- 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 (file)
index 0000000..a0e785c
--- /dev/null
@@ -0,0 +1,2 @@
+openai
+flask