Spaces:
Sleeping
Sleeping
Updated calendar api
Browse files
app.py
CHANGED
@@ -9,13 +9,14 @@ from Gradio_UI import GradioUI
|
|
9 |
|
10 |
@tool
|
11 |
def add_event_to_calendar(event_name: str, start: str, end: str) -> str:
|
12 |
-
"""A tool that
|
13 |
-
|
14 |
-
|
15 |
event_name: The name of the event.
|
16 |
start: The start time of the event represented as a datetime str.
|
17 |
end: The end time of the event respresented as a datetime str.
|
18 |
"""
|
|
|
19 |
from google.oauth2 import service_account
|
20 |
from googleapiclient.discovery import build
|
21 |
from googleapiclient.errors import HttpError
|
@@ -23,8 +24,10 @@ def add_event_to_calendar(event_name: str, start: str, end: str) -> str:
|
|
23 |
# Service account configuration
|
24 |
SERVICE_ACCOUNT_FILE = "credentials.json" # Your service account JSON file
|
25 |
SCOPES = ["https://www.googleapis.com/auth/calendar"]
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
try:
|
29 |
# Authenticate with service account
|
30 |
creds = service_account.Credentials.from_service_account_file(
|
@@ -56,6 +59,7 @@ def add_event_to_calendar(event_name: str, start: str, end: str) -> str:
|
|
56 |
return f"❌ Error: {error}"
|
57 |
except Exception as e:
|
58 |
return f"❌ Unexpected error: {str(e)}"
|
|
|
59 |
|
60 |
@tool
|
61 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
9 |
|
10 |
@tool
|
11 |
def add_event_to_calendar(event_name: str, start: str, end: str) -> str:
|
12 |
+
"""A tool that allows you to create events on google calendar.
|
13 |
+
Time should be represented in this format: Y-M-DTH:M:S+utc (for now take utc as 01:00 WAT)
|
14 |
+
Args:
|
15 |
event_name: The name of the event.
|
16 |
start: The start time of the event represented as a datetime str.
|
17 |
end: The end time of the event respresented as a datetime str.
|
18 |
"""
|
19 |
+
import os
|
20 |
from google.oauth2 import service_account
|
21 |
from googleapiclient.discovery import build
|
22 |
from googleapiclient.errors import HttpError
|
|
|
24 |
# Service account configuration
|
25 |
SERVICE_ACCOUNT_FILE = "credentials.json" # Your service account JSON file
|
26 |
SCOPES = ["https://www.googleapis.com/auth/calendar"]
|
27 |
+
PERSONAL_EMAIL = os.environ['PERSONAL_EMAIL']
|
28 |
+
CALENDAR_ID = PERSONAL_EMAIL # Or your specific calendar ID
|
29 |
+
|
30 |
+
|
31 |
try:
|
32 |
# Authenticate with service account
|
33 |
creds = service_account.Credentials.from_service_account_file(
|
|
|
59 |
return f"❌ Error: {error}"
|
60 |
except Exception as e:
|
61 |
return f"❌ Unexpected error: {str(e)}"
|
62 |
+
|
63 |
|
64 |
@tool
|
65 |
def get_current_time_in_timezone(timezone: str) -> str:
|