Issue running Google Calendar agent

I keep encountering the error (attached image) when running the calendar agent from Python examples.
No description
10 Replies
exotic-emerald
exotic-emerald2w ago
Here is my code for reference:
import os
from datetime import datetime
from composio import Composio
from composio_crewai import App, ComposioToolSet
from composio.client.exceptions import NoItemsFound
from crewai import Agent, Task, Crew
from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI

load_dotenv()

# Initialize the language model
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
llm = ChatGoogleGenerativeAI(
model="gemini-1.0-pro-latest",
# verbose = True,
temperature = 0.0,
google_api_key=GOOGLE_API_KEY
)

# Define tools for the agents
composio_toolset = ComposioToolSet()
tools = composio_toolset.get_tools(apps=[App.GOOGLECALENDAR])

# Retreive the current date and time
date = datetime.today().strftime("%Y-%m-%d")
timezone = datetime.now().astimezone().tzinfo

todo = """
When and what is my next meeting today?
"""

# Create and Execute Agent.
def run_crew():
calendar_agent = Agent(
role="Google Calendar Agent",
goal="""You take action on Google Calendar using Google Calendar APIs""",
backstory="""You are an AI agent responsible for taking actions on Google Calendar on users' behalf.
You need to take action on Calendar using Google Calendar APIs. Use correct tools to run APIs from the given tool-set.""",
verbose=True,
tools=tools,
llm=llm,
)
task = Task(
description=f"Perform the task according to {todo}. Label them with the work provided to be done in that time period. Schedule it for today. Today's date is {date} (it's in YYYY-MM-DD format) and make the timezone be {timezone}.",
agent=calendar_agent,
expected_output="if task completed successfully",
)
crew = Crew(agents=[calendar_agent], tasks=[task])
result = crew.kickoff()
print(result)

run_crew()
import os
from datetime import datetime
from composio import Composio
from composio_crewai import App, ComposioToolSet
from composio.client.exceptions import NoItemsFound
from crewai import Agent, Task, Crew
from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI

load_dotenv()

# Initialize the language model
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
llm = ChatGoogleGenerativeAI(
model="gemini-1.0-pro-latest",
# verbose = True,
temperature = 0.0,
google_api_key=GOOGLE_API_KEY
)

# Define tools for the agents
composio_toolset = ComposioToolSet()
tools = composio_toolset.get_tools(apps=[App.GOOGLECALENDAR])

# Retreive the current date and time
date = datetime.today().strftime("%Y-%m-%d")
timezone = datetime.now().astimezone().tzinfo

todo = """
When and what is my next meeting today?
"""

# Create and Execute Agent.
def run_crew():
calendar_agent = Agent(
role="Google Calendar Agent",
goal="""You take action on Google Calendar using Google Calendar APIs""",
backstory="""You are an AI agent responsible for taking actions on Google Calendar on users' behalf.
You need to take action on Calendar using Google Calendar APIs. Use correct tools to run APIs from the given tool-set.""",
verbose=True,
tools=tools,
llm=llm,
)
task = Task(
description=f"Perform the task according to {todo}. Label them with the work provided to be done in that time period. Schedule it for today. Today's date is {date} (it's in YYYY-MM-DD format) and make the timezone be {timezone}.",
agent=calendar_agent,
expected_output="if task completed successfully",
)
crew = Crew(agents=[calendar_agent], tasks=[task])
result = crew.kickoff()
print(result)

run_crew()
Can someone please help me fix this?
wise-white
wise-white2w ago
Hey @ZoRo, in my case your code is working completely fine, can you get an new API key (https://aistudio.google.com/app/apikey) and try again 🙂
exotic-emerald
exotic-emerald2w ago
I tried running it with a new API key, I get the same error
No description
wise-white
wise-white2w ago
If you don't mind, can we have a quick gmeet regarding this issue??
exotic-emerald
exotic-emerald2w ago
sure, what time would work for you?
wise-white
wise-white2w ago
We can now, if it works for you
exotic-emerald
exotic-emerald2w ago
yes works 👍
wise-white
wise-white2w ago
https://meet.google.com/jhr-wtyn-yte?authuser=1 @ZoRo Let me know if you need any other help 🙌 @ZoRo
exotic-emerald
exotic-emerald2w ago
thanks alot @thatsmeadarsh!
wise-white
wise-white2w ago
It was my pleasure to help you 😄