Difference between revisions of "Axis and Allies GPT"

From SaladFrosting
Jump to navigation Jump to search
(Created API Key)
(tokens cost .25 and id say 99% of them didn't work.)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
'''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.
 +
 
*we discussed this when playing the game
 
*we discussed this when playing the game
 
*[https://twitter.com/alliekmiller/status/1721621531686809786 today it came out]
 
*[https://twitter.com/alliekmiller/status/1721621531686809786 today it came out]
Line 8: Line 11:
 
*Installed Python locally sans admin access https://plainenglish.io/blog/install-python-on-a-locked-down-pc-without-local-admin-37a440c42c12
 
*Installed Python locally sans admin access https://plainenglish.io/blog/install-python-on-a-locked-down-pc-without-local-admin-37a440c42c12
 
*Created API Key https://platform.openai.com/api-keys
 
*Created API Key https://platform.openai.com/api-keys
 +
*added API key to environment variable
 +
*run sample code. doesn't work.
 +
*reboot for my environment variable to "stick"
 +
*error 429 exceeded quota... find out that my account is out of credits or it expired because it is > 3 months old https://stackoverflow.com/questions/75898276/openai-chatgpt-gpt-3-5-api-error-429-you-exceeded-your-current-quota-please
 +
*upgrade/buy credits https://platform.openai.com/account/billing/overview  added $50 bucks.
 +
*recreate API key
 +
*reboot? nah, just had to refresh my path by closing command prompt and re-opening. tested by
 +
echo %OPENAI_API_KEY%
 +
*re-run
 +
python openai-test.py
 +
SUCCESS. 
 +
 +
okay, now on to XY...
 +
 +
*https://platform.openai.com/docs/quickstart?context=python
 +
*https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
 +
*https://platform.openai.com/docs/overview
 +
 +
==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

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