As a distinguished AI Developer, you've been selected by Peterman Reality Tours, an internationally acclaimed tourism company, to undertake an influential project. This project requires you to harness the potential of OpenAI's API, to create an AI-powered travel guide for the culturally rich city of Paris.
Your creation will become a virtual Parisian expert, delivering valuable insights into the city's iconic landmarks and hidden treasures. The AI will respond intelligently to a set of common questions, providing a more engaging and immersive travel planning experience for the clientele of Peterman Reality Tours.
The ultimate aspiration is a user-friendly, AI-driven travel guide that significantly enhances the exploration of Paris. Users will be able to pre-define their questions and receive well-informed answers from the AI, providing a seamless and intuitive travel planning process.
# Start your code here!
import os
from openai import OpenAI
# Define the model to use
model = "gpt-4o-mini"
# Define the client
client = OpenAI()
# Start coding here
# Add as many cells as you like#creating system prompt to control the bots behaviour
system_prompt = """
You are a virtual Parisian expert, delivering valuable insights into the city's iconic landmarks and hidden treasures. you will respond intelligently to a set of common questions, providing a more engaging and immersive travel planning experience for the clientele of Peterman Reality Tours. your ultimate aspiration is to be a user-friendly, travel guide that aims to significantly enhance the exploration of Paris.
ensure that all responses must be within 100 tokens
"""
#creating a list to store the questions
questions = [
'How far away is the Louvre from the Eiffel Tower (in miles) if you are driving?',
'Where is the Arc de Triomphe?',
'What are the must-see artworks at the Louvre Museum?'
]
#creating a dictionary to store the questions
conversation = [
#instruction to define system behaviour
{
'role':'system',
'content': system_prompt
}
]# function to generate responses
def gen_responses(questions, conversation):
for each in questions:
#appending question to the conversation dictionary
conversation.append(
{
'role':'user',
'content':each
}
)
#generating responses
responses = client.chat.completions.create(
model=model,
messages = conversation,
temperature = 0.0,
max_completion_tokens = 100
)
#appending response to conversation dictionary
conversation.append(
{
'role':'assistant',
'content':responses.choices[0].message.content
}
)
return conversation
#unpacking results
conversation = gen_responses(questions,conversation)
#outputting results
for each in conversation:
if each == conversation[0]: # to skip displaying the system prompt
pass
else:
for key,values in each.items():
print(values,'\n')