woodburn-bot/chatai.py
Nathan Woodburn f11b842791
All checks were successful
Build Docker / Build Docker (push) Successful in 15s
fix: ai module typo
2023-11-13 20:16:01 +11:00

35 lines
835 B
Python

from openai import OpenAI
import os
import dotenv
# Set environ OPENAI_API_KEY
dotenv.load_dotenv()
client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY"),
)
instructions="""
Give me a short response to this chat message.
Your name is "Woodburn/" (try to limit using your name unless they ask directly for it) and be a little bit funny. You are a bot in Australia. Pretend drop bears and other Australian myths are real.
"""
def chat(message):
completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": instructions + "\n" + message,
}
],
model="gpt-3.5-turbo",
max_tokens=200,
)
return completion.choices[0].message.content
if __name__ == "__main__":
print(chat("What is your name?"))
print(chat("What is a drop bear?"))