mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
fix bugs and pattern inconsistencies in google drive tools
This commit is contained in:
parent
9abe136646
commit
856d258318
3 changed files with 16 additions and 0 deletions
|
|
@ -76,6 +76,9 @@ def create_create_google_drive_file_tool(
|
||||||
logger.error(f"Failed to fetch creation context: {context['error']}")
|
logger.error(f"Failed to fetch creation context: {context['error']}")
|
||||||
return {"status": "error", "message": context["error"]}
|
return {"status": "error", "message": context["error"]}
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
f"Requesting approval for creating Google Drive file: name='{name}', type='{file_type}'"
|
||||||
|
)
|
||||||
approval = interrupt(
|
approval = interrupt(
|
||||||
{
|
{
|
||||||
"type": "google_drive_file_creation",
|
"type": "google_drive_file_creation",
|
||||||
|
|
@ -97,6 +100,7 @@ def create_create_google_drive_file_tool(
|
||||||
decisions = decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
decisions = decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
||||||
decisions = [d for d in decisions if isinstance(d, dict)]
|
decisions = [d for d in decisions if isinstance(d, dict)]
|
||||||
if not decisions:
|
if not decisions:
|
||||||
|
logger.warning("No approval decision received")
|
||||||
return {"status": "error", "message": "No approval decision received"}
|
return {"status": "error", "message": "No approval decision received"}
|
||||||
|
|
||||||
decision = decisions[0]
|
decision = decisions[0]
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,15 @@ def create_trash_google_drive_file_tool(
|
||||||
file_id = file["file_id"]
|
file_id = file["file_id"]
|
||||||
connector_id_from_context = context["account"]["id"]
|
connector_id_from_context = context["account"]["id"]
|
||||||
|
|
||||||
|
if not file_id:
|
||||||
|
return {
|
||||||
|
"status": "error",
|
||||||
|
"message": "File ID is missing from the indexed document. Please re-index the file and try again.",
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
f"Requesting approval for trashing Google Drive file: '{file_name}' (file_id={file_id})"
|
||||||
|
)
|
||||||
approval = interrupt(
|
approval = interrupt(
|
||||||
{
|
{
|
||||||
"type": "google_drive_file_trash",
|
"type": "google_drive_file_trash",
|
||||||
|
|
@ -88,6 +97,7 @@ def create_trash_google_drive_file_tool(
|
||||||
decisions = decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
decisions = decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
||||||
decisions = [d for d in decisions if isinstance(d, dict)]
|
decisions = [d for d in decisions if isinstance(d, dict)]
|
||||||
if not decisions:
|
if not decisions:
|
||||||
|
logger.warning("No approval decision received")
|
||||||
return {"status": "error", "message": "No approval decision received"}
|
return {"status": "error", "message": "No approval decision received"}
|
||||||
|
|
||||||
decision = decisions[0]
|
decision = decisions[0]
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,8 @@ class GoogleDriveToolMetadataService:
|
||||||
and_(
|
and_(
|
||||||
SearchSourceConnector.id == document.connector_id,
|
SearchSourceConnector.id == document.connector_id,
|
||||||
SearchSourceConnector.user_id == user_id,
|
SearchSourceConnector.user_id == user_id,
|
||||||
|
SearchSourceConnector.connector_type
|
||||||
|
== SearchSourceConnectorType.GOOGLE_DRIVE_CONNECTOR,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue