I am trying to call Flask API which i alrady running on port 5000 on my system, i am desgning a agentic AI code which will invoke GET and then POSt based on some condition , and using google-adk. I have below code
import requests
from google.adk.agents import LlmAgent
from google.adk.tools.function_tool import FunctionTool
def check_trainer_availability(trainer: str) -> str:
resp = requests.get("http://localhost:5000/availability", params={"trainer": trainer})
return resp.json().get("availability", "unknown")
def book_trainer(trainer: str, trainee: str) -> str:
resp = requests.post("http://localhost:5000/book", json={"trainer": trainer, "trainee": trainee})
return resp.json().get("message", "Booking failed.")
availability_tool = FunctionTool(check_trainer_availability)
booking_tool = FunctionTool(book_trainer)
agent = LlmAgent(
name="TrainerBookingAgent",
model="gemini-1.5-flash",
tools=[availability_tool, booking_tool],
instruction="""
You are an assistant that checks trainer availability using the tool, and books if available.
"""
)
if __name__ == "__main__":
result = agent.invoke("Please book Aisha for John.")
print(" Agent Response:", result.response)
Whenever i am running this i am getting below error:
AttributeError: 'LlmAgent' object has no attribute 'invoke'
I have google-adk version 1.4.1 , still i am getting this issue. Please Help.