-
Notifications
You must be signed in to change notification settings - Fork 59.8k
Expand file tree
/
Copy pathoai-history-bot.py
More file actions
32 lines (24 loc) · 1.08 KB
/
oai-history-bot.py
File metadata and controls
32 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from openai import OpenAI
import os
from dotenv import load_dotenv
# load environment variables from .env file
load_dotenv()
# configure Azure OpenAI service client
client = OpenAI()
deployment="gpt-3.5-turbo"
# add your completion code
persona = input("Tell me the historical character I want to be: ")
question = input("Ask your question about the historical character: ")
prompt = f"""
You are going to play as a historical character {persona}.
Whenever certain questions are asked, you need to remember facts about the timelines and incidents and respond the accurate answer only. Don't create content yourself. If you don't know something, tell that you don't remember.
Provide answer for the question: {question}
"""
messages = [{"role": "user", "content": prompt}]
# make completion
completion = client.chat.completions.create(model=deployment, messages=messages, temperature=0)
# print response
if completion.choices and completion.choices[0].message is not None:
print(completion.choices[0].message.content)
# very unhappy _____.
# Once upon a time there was a very unhappy mermaid.