Skip to content

Commit

Permalink
Fix: added there should not be any ' or " in answer to routers
Browse files Browse the repository at this point in the history
  • Loading branch information
EldarAlvik committed Nov 7, 2024
1 parent 2b4c714 commit 238b2ae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
12 changes: 6 additions & 6 deletions core/noder.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def jarvis_agent(state: GraphState):
- 'use_tool': Call on tools to help solve the users problem
- 'generate': Generate a response if you have what you need to answer
Answer with the option name and nothing else
Answer with the option name and nothing else there should not be any ' or " in the answer.
""",
)
chain = prompt | ToolsAgent.agent | StrOutputParser()
Expand All @@ -50,14 +50,14 @@ def tool_agent_decider(state: GraphState):
Data: {data}
Your options for agents are the following:
- 'perplexity': This agent has access to tools that use the perplexity API.
- "perplexity": This agent has access to tools that use the perplexity API.
These tools are the following: {perplexity_tools}
- 'calendar': This agent has access to calendar tools
- "calendar": This agent has access to calendar tools
These tools are the following: {calendar_tools}
- 'other': Other tools available: {other_tools}
- "other": Other tools available: {other_tools}
Answer with the option name and nothing else
Answer with the option name and nothing else there should not be any ' or " in the answer.
""",
)

Expand Down Expand Up @@ -148,7 +148,7 @@ def calendar_desicion_agent(state: GraphState):
- 'use_calendar_tool': Call on calendar_tools to help solve the users problem
- 'return_to_jarvis': go back to the jarvis agent
Answer with the option name and nothing else.
Answer with the option name and nothing else there should not be any ' or " in the answer.
""",
)
chain = prompt | ToolsAgent.agent | StrOutputParser()
Expand Down
24 changes: 23 additions & 1 deletion core/tools/google_calendar_read.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from dotenv import load_dotenv
from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
Expand Down Expand Up @@ -42,6 +42,28 @@ def read_calendar_events(time_min: str, time_max: str, maxResults: int = 10) ->
Use this tool to read events from the calendar within a specified time range.
"""
service = get_calendar_service()

try:
# Parse input strings into datetime objects
time_min_dt = datetime.fromisoformat(time_min)
time_max_dt = datetime.fromisoformat(time_max)

# If timezone info is missing, add UTC timezone
if time_min_dt.tzinfo is None:
time_min_dt = time_min_dt.replace(tzinfo=timezone.utc)
if time_max_dt.tzinfo is None:
time_max_dt = time_max_dt.replace(tzinfo=timezone.utc)

# Validate that time_min is before time_max
if time_min_dt >= time_max_dt:
return "Error: time_min must be earlier than time_max."

# Convert back to RFC3339 strings
time_min_formatted = time_min_dt.isoformat()
time_max_formatted = time_max_dt.isoformat()

except ValueError as e:
return f"Invalid time format: {e}"

events_result = service.events().list(
calendarId=os.getenv("GOOGLE_CALENDAR_ID"),
Expand Down

0 comments on commit 238b2ae

Please sign in to comment.