I am currently developing a chatbot capable of executing various functions based on user queries.
Let’s say the chatbot currently supports two functions - book_appointment
and fetch_records
. The chatbot effectively handles user queries related to these functions.
However, it currently lacks context awareness when handling queries unrelated to these specific functions. For example, if a user asks about applying for a job, connecting to an agent, or checking the order status, the chatbot is responding inappropriately.
Request
{
"model": "gpt-3.5-turbo-0613",
"messages": [
{
"role": "system",
"content": "Today is Tuesday, 01th August 2023 11:09 AM."
},
{
"role": "user",
"content": "I want to apply for a job"
}
],
"functions": [
{
"name": "book_appointment",
"description": "Use this function to book an appointment",
"parameters": {
"type": "object",
"properties": {
"user_id": {
"type": "string",
"description": "user id"
},
"date": {
"type": "string",
"description": "date of appointment"
}
},
"required": [
"user_id",
"date"
]
}
},
{
"name": "fetch_records",
"description": "Use this function to fetch records",
"parameters": {
"type": "object",
"properties": {
"user_id": {
"type": "string",
"description": "user-id"
},
"start_date": {
"type": "string",
"description": "start date of records"
},
"end_date": {
"type": "string",
"description": "end date of records"
}
},
"required": [
"user_id",
"start_date",
"end_date"
]
}
}
],
"function_call": "auto",
"temperature": 0,
"max_tokens": 2048,
"stream": false,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"stop": null
}
Response
{
"id": "chatcmpl-7iiXRB7f65HqiK379PfgHaR4MOwON",
"object": "chat.completion",
"created": 1690891993,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "That's great! I can help you with that. Could you please provide me with some more information? What kind of job are you looking for?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 136,
"completion_tokens": 31,
"total_tokens": 167
}
}
I have one solution, implementing a default function named others
that the chatbot will call for out-of-context queries. Any suggestion on this?