Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): Fixed getDocument(s) endpoint errors #518

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 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 @@ -307,13 +313,7 @@ def update_rss_feed(input: dict):


def _convert_document(document: dict):
if "crawler_properties" in document:
document["crawler_properties"] = {
"followLinks": document["crawler_properties"]["follow_links"],
"limit": document["crawler_properties"]["limit"],
"contentTypes": document["crawler_properties"]["content_types"],
}
return {
converted_document = {
"id": document["document_id"],
"workspaceId": document["workspace_id"],
"type": document["document_type"],
Expand All @@ -329,11 +329,14 @@ def _convert_document(document: dict):
"updatedAt": document.get("updated_at", None),
"rssFeedId": document.get("rss_feed_id", None),
"rssLastCheckedAt": document.get("rss_last_checked", None),
"crawlerProperties": {
}
if "crawler_properties" in document:
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
),
}
if document.get("crawler_properties", None) != None
else None,
}

return converted_document
Loading