Book an appointment
The document provides a scenario where a customer wants to book a haircut appointment, and the model outputs the next available time based on the available slots provided.
This could be used in a scenario when the model is connected to other services such as calendar and scheduling API.
Prompt
# Customer
I want to book an appointment for a haircut next Friday at 3pm.
# Available times
2024-03-11 Monday 5pm - 6pm
2024-03-13 Wednesday 12pm - 3pm
2024-03-15 Friday 4pm - 5pm
# Context
Now is 2024-03-11 3:27pm
# Instruction
Each appointment takes 1 hour. If there is availabiltiy within "available times" that meets
Customer's schedule, output a start time of the appointment that can be scheduled in the following
format "%Y-%m-%d %H".
If there are multiple times, choose the earliest. If no times are available, output None.
Output should be in JSON format:
```json JSON
{
next_available_time: "%Y-%m-%d %H"
}
```Output
{
"next_available_time": "2024-03-15 4pm"
}
API Request
import cohere
co = cohere.ClientV2(api_key="<YOUR API KEY>")
response = co.chat(
model="command-a-plus-05-2026",
messages=[
{
"role": "user",
"content": """
# Customer
I want to book an appointment for a haircut next Friday at 3pm.
# Available times
2024-03-11 Monday 5pm - 6pm
2024-03-13 Wednesday 12pm - 3pm
2024-03-15 Friday 4pm - 5pm
# Context
Now is 2024-03-11 3:27pm
# Instruction
Each appointment takes 1 hour. If there is availabiltiy within "available times" that meets Customer's schedule, output a start time of the appointment that can be scheduled in the following format "%Y-%m-%d %H".
If there are multiple times, choose the earliest. If no times are available, output None.
Output should be in JSON format:
```json
{
next_available_time: "%Y-%m-%d %H"
}
```
""",
}
],
)
print(response.message.content[0].text)Also check out the Structured Outputs feature which guarantees that output of the model will be a valid JSON object.