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. This project will not only improve Peterman Reality Tours' customer service, but also solidify their place at the forefront of AI-enhanced innovation in the global tourism industry. Users will be able to pre-define their questions and receive well-informed answers from the AI, making the travel planning process seamless and intuitive.

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 it's not clear if that is worldwide or what the conditions are. You may need to add debit/credit card details.

The API costs $0.002 / 1000 tokens for GPT-3.5-turbo. 1000 tokens is about 750 words. This project should cost less than 1 US cents (but if you rerun tasks, you will be charged every time).

  1. Go to the Payment Methods page.

  2. Click Add payment method.

  1. Fill in your card details.

Add an environmental variable with your OpenAI key

  1. In Workspace, 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
import openai
openai.api_key = os.environ["OPENAI"]

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

# Define the conversation
conversation =[{
    "role": "system",
    "content":"You are a travel guide designed to provide information about landmarks that tourists should explore in Paris. You speak in a concise manner."},
    {"role":"user",
    "content":"What is the most famous landmark in Paris?"},
    {"role":"assistant",
    "content":"The most famous landmark in Paris is the Eiffel Tower."},
    ]

# Define a list of questions
questions = [
    "How far away is the Louvre from the Eiffel Tower (in driving miles)?",
    "Where is the Arc de Triomphe?",
    "What are the must-see artworks at the Louvre Museum?"
]

# Loop through each question to generate responses
for question in questions:

    # Format the user input into dictionary form
    input_dict = {"role": "user",
                  "content": question}
    
    # Add the user input dictionary to the conversation
    conversation.append(input_dict)  

    # Make the next API call
    response = openai.ChatCompletion.create(
        model=model,
        messages=conversation,
        temperature=0.0,
        max_tokens=100
    )
    
    # Print the response from the model
    resp = response.choices[0]['message']['content']
    print(resp)

    # Convert the response into the dictionary
    resp_dict = {"role": "assistant",
                 "content": resp}
    
    # Append the response to the conversation
    conversation.append(resp_dict)