feat: enhance OneDrive file creation tool by adding parent folder selection and handling expired accounts

This commit is contained in:
Anish Sarkar 2026-03-29 05:08:04 +05:30
parent c325f53941
commit 5d467cdfc2
2 changed files with 160 additions and 30 deletions

View file

@ -109,7 +109,32 @@ def create_create_onedrive_file_tool(
"connector_type": "onedrive",
}
context = {"accounts": accounts}
parent_folders: dict[int, list[dict[str, str]]] = {}
for acc in accounts:
cid = acc["id"]
if acc.get("auth_expired"):
parent_folders[cid] = []
continue
try:
client = OneDriveClient(session=db_session, connector_id=cid)
items, err = await client.list_children("root")
if err:
logger.warning("Failed to list folders for connector %s: %s", cid, err)
parent_folders[cid] = []
else:
parent_folders[cid] = [
{"folder_id": item["id"], "name": item["name"]}
for item in items
if item.get("folder") is not None and item.get("id") and item.get("name")
]
except Exception:
logger.warning("Error fetching folders for connector %s", cid, exc_info=True)
parent_folders[cid] = []
context: dict[str, Any] = {
"accounts": accounts,
"parent_folders": parent_folders,
}
approval = interrupt(
{