Skip to content

Commit

Permalink
formatting: formatted updates to documents route
Browse files Browse the repository at this point in the history
  • Loading branch information
flamingquaks authored and bigadsoleiman committed Jul 25, 2024
1 parent 39cbca2 commit 0e8ddd3
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/chatbot-api/functions/api-handler/routes/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ class GetDocumentRequest(BaseModel):
workspaceId: str
documentId: str


class DeleteDocumentRequest(BaseModel):
workspaceId: str
documentId: str


class GetRssPostsRequest(BaseModel):
workspaceId: str
documentId: str
Expand Down Expand Up @@ -135,14 +137,18 @@ def get_documents(input: dict):
"lastDocumentId": result["last_document_id"],
}


@router.resolver(field_name="deleteDocument")
@tracer.capture_method
def delete_document(input: dict):
request = DeleteDocumentRequest(**input)
result = genai_core.documents.delete_document(request.workspaceId, request.documentId)

result = genai_core.documents.delete_document(
request.workspaceId, request.documentId
)

return result


@router.resolver(field_name="getDocument")
@tracer.capture_method
def get_document_details(input: dict):
Expand Down Expand Up @@ -322,13 +328,15 @@ def _convert_document(document: dict):
"createdAt": document["created_at"],
"updatedAt": document.get("updated_at", None),
"rssFeedId": document.get("rss_feed_id", None),
"rssLastCheckedAt": document.get("rss_last_checked", None)
"rssLastCheckedAt": document.get("rss_last_checked", None),
}
if "crawler_properties" in document:
converted_document['crawlerProperties'] = {
converted_document["crawlerProperties"] = {
"followLinks": document.get("crawler_properties").get("follow_links", None),
"limit": document.get("crawler_properties").get("limit", None),
"contentTypes": document.get("crawler_properties").get("content_types", None),
"contentTypes": document.get("crawler_properties").get(
"content_types", None
),
}

return converted_document

0 comments on commit 0e8ddd3

Please sign in to comment.