-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: align knowledge base CRUD API contract with kb_name, canonical payload fields, and matching OpenAPI types #9000
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -205,13 +205,46 @@ class ImMessageRequest(OpenModel): | |||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| class KnowledgeBaseRequest(OpenModel): | ||||||||||||||||||
|
sourcery-ai[bot] marked this conversation as resolved.
|
||||||||||||||||||
| kb_id: str | None = None | ||||||||||||||||||
| name: str | None = None | ||||||||||||||||||
| kb_name: str | None = Field(None, alias="name") | ||||||||||||||||||
| description: str | None = None | ||||||||||||||||||
| emoji: str | None = None | ||||||||||||||||||
| embedding_provider_id: str | None = None | ||||||||||||||||||
| rerank_provider_id: str | None = None | ||||||||||||||||||
| chunk_size: int | None = None | ||||||||||||||||||
| chunk_overlap: int | None = None | ||||||||||||||||||
| top_k_dense: int | None = None | ||||||||||||||||||
| top_k_sparse: int | None = None | ||||||||||||||||||
| top_m_final: int | None = None | ||||||||||||||||||
|
|
||||||||||||||||||
| model_config = ConfigDict(populate_by_name=True, extra="allow") | ||||||||||||||||||
|
|
||||||||||||||||||
| def canonical_payload(self) -> dict[str, Any]: | ||||||||||||||||||
| """Return the service-facing knowledge base payload. | ||||||||||||||||||
|
|
||||||||||||||||||
| Returns: | ||||||||||||||||||
| Dictionary accepted by KnowledgeBaseService. | ||||||||||||||||||
| """ | ||||||||||||||||||
| return self.model_dump( | ||||||||||||||||||
| exclude_unset=True, | ||||||||||||||||||
| include={ | ||||||||||||||||||
| "kb_name", | ||||||||||||||||||
| "description", | ||||||||||||||||||
| "emoji", | ||||||||||||||||||
| "embedding_provider_id", | ||||||||||||||||||
| "rerank_provider_id", | ||||||||||||||||||
| "chunk_size", | ||||||||||||||||||
| "chunk_overlap", | ||||||||||||||||||
| "top_k_dense", | ||||||||||||||||||
| "top_k_sparse", | ||||||||||||||||||
| "top_m_final", | ||||||||||||||||||
| }, | ||||||||||||||||||
| by_alias=False, | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| class KnowledgeBaseCreateRequest(KnowledgeBaseRequest): | ||||||||||||||||||
| kb_name: str = Field(..., alias="name") | ||||||||||||||||||
| embedding_provider_id: str | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| class KnowledgeBaseImportRequest(OpenModel): | ||||||||||||||||||
|
Comment on lines
249
to
250
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR description mentions syncing Please define
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The helper function
_model_dictwas removed from this file. However, it is still referenced in multiple other endpoints within the same file:import_knowledge_base_documents(line 210)import_knowledge_base_document_url(line 224)retrieve_knowledge_base(line 304)Removing
_model_dictwill cause aNameErrorwhen any of these endpoints are called. Please restore_model_dictor refactor those endpoints to usepayload.model_dump(exclude_none=True)directly.