-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create get_credentials function to handle oauth google
- Loading branch information
Showing
9 changed files
with
21 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +0,0 @@ | ||
from typing import Union, Dict, Tuple | ||
from langchain_core.tools import BaseTool | ||
from ai.integration.google_calendar import Calendar | ||
|
||
|
||
class GoogleCalendarListEventTool(BaseTool): | ||
name = "google_calendar_list_event_tool" | ||
description = "Useful for when you need to answer questions about events from Google calendar" | ||
|
||
def _to_args_and_kwargs(self, tool_input: Union[str, Dict]) -> Tuple[Tuple, Dict]: | ||
return (), {} | ||
|
||
def _run(self) -> str: | ||
calendar = Calendar() | ||
return calendar.get_all_events() | ||
|
||
async def _arun(self) -> str: | ||
"""Use the tool asynchronously.""" | ||
raise NotImplementedError("custom_search does not support async") | ||
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os.path | ||
from google_auth_oauthlib.flow import InstalledAppFlow | ||
from google.oauth2.credentials import Credentials | ||
|
||
|
||
SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"] | ||
|
||
|
||
def get_credentials() -> None | Credentials: | ||
if os.path.exists("credentials.json"): | ||
flow = InstalledAppFlow.from_client_secrets_file("credentials.json", SCOPES) | ||
creds = flow.run_local_server(port=0) | ||
with open("token.json", "w") as token: | ||
token.write(creds.to_json()) | ||
return Credentials.from_authorized_user_file("token.json", SCOPES) | ||
else: | ||
print("Credentials were not provided") |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters