Generating one question at time

Hello

I need to extract several informations from a client in a chat. But I need to make sure the model only asks one question at time, I am testing with gpt-3.5-turbo in chat mode

I found this prompt that seems to work:

The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly. If the user wants they can talk about anything as soon as the assistant finishes collecting the following fields from the user:

The user's name
The user's departure location
The user's destination location
The user's dates of travel
The user's budget for the trip
Any additional preferences or constraints the user may have

After collecting all these fields the AI should thank the human for their time. It should then write EODC (for end of data collection) and on a new line output all these fields as JSON. {"user_name": "<user_name>", "departure_location": <departure_location>, "destination_location": "<destination_location>", "dates_of_travel": "<dates_of_travel>", "budget": <budget>, "additional_preferences": "<additional_preferences>"}

user: book a flight 
AI: Sure! I can help you book a flight. Can I start by getting your name?

The problem is that some times 50% it asks like this:

Sure, I can help you book a flight. Before we proceed, can you please provide me with the following information:
- Your name?
- Your departure location?
- Your destination location?
- Your dates of travel?
- Your budget for the trip?
- Any additional preferences or constraints you may have?

I need to make sure it only asks one question at time, even if the user provides more then one information at time, like:

user: book a flight from Miami to Chicago (the model should ask all the remaining questions one at time)

Thanks for any help

To limit to one question, try setting the stop parameter to ?.

Hi @wfhbrian
I tried adding the stop=“?” but now the model generates

Great! I'd be happy to help you with that. Before we get started, can you please provide me with the following information:
- Your name
- Your departure locatio
- Your destination location
- Your dates of travel
- Your budget for the trip
- Any additional preferences or constraints you may have

Once I have all of this information, I can help you find the best flight options.

For some reason, this output does not have any “?” so it does not stops.
Maybe because of todays problems it is very unstable

I will try tomorow

Thanks

Now work on the prompt to instruct it to ask questions. Reformat the list into questions.

Hi @wfhbrian, that worked

Here is the prompt changed:

The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly. If the user wants they can talk about anything as soon as the assistant finishes collecting the following fields from the user:

What is the user's name?
What is the user's departure location?
What is the user's destination location?
What are the user's dates of travel?
What is the user's budget for the trip?
Deoes the user has any additional preferences or constraints?

After collecting all these fields the AI should thank the human for their time. It should then write the letters "EODC" and on a new line output all these fields as JSON. {"user_name": "<user_name>", "departure_location": <departure_location>, "destination_location": "<destination_location>", "dates_of_travel": "<dates_of_travel>", "budget": <budget>, "additional_preferences": "<additional_preferences>"}

And here is the output:

messages=[
    {"role": "system", "content": msg_context },
    {"role": "user", "content": "I would like to book a fligth from Miami to Chicago"},
    {"role": "assistant", "content": "Great! I'd be happy to help you with that. Before we get started, can you please provide me with the following information: What is your name?"},
    {"role": "user", "content": "Cesar"},
    {"role": "assistant", "content": "Thanks, Cesar! And when are you planning to travel from Miami to Chicago?"},
    {"role": "user", "content": "From March 12 to March 20"},
    {"role": "assistant", "content": "Got it! And do you have a specific budget in mind for your flight?"},
    {"role": "user", "content": "300"},
    {"role": "assistant", "content": "Thanks for letting me know. Do you have any additional preferences or constraints for your flight?"},
    {"role": "user", "content": "No"},
]

Final output

"Alright, I have all the information I need. Thank you for providing that to me, Cesar! Here are the details of your trip:\n\n- Departure location: Miami\n- Destination location: Chicago\n- Dates of travel: March 12 to March 20\n- Budget: $300\n- Additional preferences: None\n\nThank you for your time! EODC\n\n{\"user_name\": \"Cesar\", \"departure_location\": \"Miami\", \"destination_location\": \"Chicago\", \"dates_of_travel\": \"March 12 to March 20\", \"budget\": 300, \"additional_preferences\": \"None\"}

Thanks so much

1 Like