Difference between revisions of "Axis and Allies GPT"

From SaladFrosting
Jump to navigation Jump to search
(tokens cost .25 and id say 99% of them didn't work.)
 
(One intermediate revision by the same user not shown)
Line 49: Line 49:
 
   )
 
   )
 
     return response.choices[0].text.strip()
 
     return response.choices[0].text.strip()
 +
 +
 +
The rest of the code seemed straightworward:
 +
 +
# Query ChatGPT with your question
 +
question = "What is the general combat sequence"
 +
response = ask_chatgpt(question, user_manual_text)
 +
 +
 +
response = client.completions.create(
 +
  model="gpt-3.5-turbo-instruct",
 +
  prompt="What is the general combat sequence"
 +
)
 +
 +
#Print the response
 +
print(f"Question: {question}")
 +
print(f"Answer: {response}")
 +
 +
 +
but sadly the syntax for
 +
 +
  response = openai.completions.create( ...
 +
 +
is pretty unclear to me at this point and even chatGPT was tripping up with it and apologizing.
 +
 +
==Roll your own assistant==
 +
 +
So, I ended up rolling my own assistant in the playground and tweeted it here:
 +
 +
https://twitter.com/phalseid/status/1722022484927447146

Latest revision as of 23:10, 7 November 2023

A & A Gee Pee Tee solves the problem of "I want to play A&A but I don't want to read the rulebook". Solution: spin up an "AI Assistant" with a custom domain of knowledge concerning the board game.


Work Notes

echo %OPENAI_API_KEY%
  • re-run
python openai-test.py

SUCCESS.

okay, now on to XY...

The Manual

the PDF is kinda big... (47000KB). Converted it to text (100KB) with an online tool. i uploaded (read) it using

# Read the contents of the text file (user manual)
file_path = "axy.txt"  # Replace with your file path
with open(file_path, "r", encoding="utf-8") as file:
   user_manual_text = file.read()

and then fought the syntax here for way too long:

# Define a function to interact with ChatGPT
def ask_chatgpt(question, context):
response = openai.completions.create(
  engine="text-davinci-002",
   prompt=f"User Manual: {context}\nQuestion: {question}\nAnswer:",
    max_tokens=150,  # Adjust based on your needs
     temperature=0.7,  # Adjust for creativity vs. accuracy
  )
   return response.choices[0].text.strip()


The rest of the code seemed straightworward:

# Query ChatGPT with your question
question = "What is the general combat sequence"
response = ask_chatgpt(question, user_manual_text)


response = client.completions.create(
  model="gpt-3.5-turbo-instruct",
  prompt="What is the general combat sequence"
)
#Print the response
print(f"Question: {question}")
print(f"Answer: {response}")


but sadly the syntax for

 response = openai.completions.create( ... 

is pretty unclear to me at this point and even chatGPT was tripping up with it and apologizing.

Roll your own assistant

So, I ended up rolling my own assistant in the playground and tweeted it here:

https://twitter.com/phalseid/status/1722022484927447146