Some of the examples I have seen from function calling seems like the function is good for “fill in the blank” type of operations, rather than a question and answer interaction.
Now, given a json docuemen feed in a function to be called … say something like:
{open: 8am
close: 5pm}
(Ignore syntax for now… i am on my phone )
^^^ if the user ask the question: what are your hours of operation?.. can the bot response be in natural language giving the opening and closing hours?
I am trying to do a Q&A bot and I can feed lots of info… but could it respond in a natural language with the given information?
Edgar, you can definitely create a Q&A bot to respond in natural language based on the provided information. For instance, given the JSON document with opening and closing hours, you could structure a function in Python to interpret a user’s query about hours of operation and respond accordingly. Here’s a simplified example:
import json
data = '{"open": "8am", "close": "5pm"}'
info = json.loads(data)
def get_hours_of_operation(info):
return f"We are open from {info['open']} to {info['close']}."
def handle_query(query):
if 'hours of operation' in query.lower():
return get_hours_of_operation(info)
else:
return "Sorry, I didn't understand your question."
user_query = "What are your hours of operation?"
bot_response = handle_query(user_query)
print(bot_response) # Output: We are open from 8am to 5pm.
In this script, handle_query
checks if the query is about hours of operation, and if so, calls get_hours_of_operation
to generate a natural language response based on the JSON data.
2 Likes