I’m working on a Gemini application where I need to make dynamic API calls based on user input. Specifically, I want to perform different API requests depending on the user’s query. For example, if the user asks for the latest news, the application should make an API call to a news service. Similarly, if the user wants to know the current weather, the application should fetch data from a weather API.
Here’s a basic outline of what I’m trying to achieve:
Capture the user’s input.
Determine the type of request based on the input (e.g., news or weather).
Make the appropriate API call and return the data to the user.
I want to avoid using third-party libraries like RAG for this purpose. How can I implement this functionality in a clean and efficient way within my Gemini application?
And i dont want to use a approach like this ‘
def handle_user_input(user_input):
if "news" in user_input:
# Call news API
pass
elif "weather" in user_input:
# Call weather API
pass
else:
return "I can't handle that request."