Skip to content

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, specifically using its state-of-the-art language model, GPT-3.5 Turbo, 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.

Before you start

In order to complete the project you will need to create a developer account with OpenAI and store your API key as an environment variable. Instructions for these steps are outlined below.

Create a developer account with OpenAI

  1. Go to the API signup page.

  2. Create your account (you'll need to provide your email address and your phone number).

  1. Go to the API keys page.

  2. Create a new secret key.

  1. Take a copy of it. (If you lose it, delete the key and create a new one.)

Add a payment method

OpenAI sometimes provides free credits for the API, but this can vary based on geography. You may need to add debit/credit card details.

Using the gpt-3.5-turbo model in this project should incur a cost less than 1 US cent (but if you rerun tasks, you will be charged every time). For more information on pricing, see OpenAI's pricing page.

  1. Go to the Payment Methods page.

  2. Click Add payment method.

  1. Fill in your card details.

Add an environment variable for your OpenAI key

  1. In the Workbook, click on "Environment," in the left sidebar.

  2. Click on the plus button next to "Environment variables" to add environment variables.

  3. In the "Name" field, type "OPENAI". In the "Value" field, paste in your secret key.

  1. Click "Create", then you'll see the following pop-up window. Click "Connect," then wait 5-10 seconds for the kernel to restart, or restart it manually in the Run menu.
# Start your code here!
import os
from openai import OpenAI

# Define the model to use
model = "gpt-3.5-turbo"


# Define the client
client = OpenAI(api_key=os.environ["OPENAI"])

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?" ]

conversation = [{"role": 'system', "content": 'You are a chatbot that generate responses to Parisian tourist questions'}]

reponse = client.chat.completions.create(
    model=model,
    messages=conversation,
    max_tokens=100
   )

for q in questions:
    conversation.append({
        "role": 'user',
        "content": q
    })
    response = client.chat.completions.create(
    model=model,
    messages=conversation,
    max_tokens=100).choices[0].message.content
    

    conversation.append({
        "role": 'assistant',
        "content": response
    })
    
print(conversation)
    




# Start coding here
# Add as many cells as you like