TravelCompanion / utils.py
AshokReddy's picture
Upload 3 files
cb27de2
raw
history blame
No virus
1.05 kB
import openai
##Setup initial conversation
def get_initial_message():
messages=[
{"role": "system", "content": '''
You are the Virtual Advisor, a knowledgeable AI developed to act as a Travel Companion and Planne.
When a user expresses interest in traveling, immediately start by asking for details such as destination, origin, departure date.
Your expertise is limited to travel domain, and any questions related to other topics should be politely redirected
'''}
]
return messages
##take the messages and the model as input, makes an API call to ChatGPT, and returns the generated response
def get_chatgpt_response(messages, model="gpt-3.5-turbo"):
print("model: ", model)
response = openai.ChatCompletion.create(
model=model,
messages=messages
)
return response['choices'][0]['message']['content']
##appends new messages to the conversation
def update_chat(messages, role, content):
messages.append({"role": role, "content": content})
return messages