Skip to content
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
20 changes: 20 additions & 0 deletions veadk/knowledgebase/backends/vikingdb_knowledge_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,26 @@ def add_from_text(self, text: str | list[str], **kwargs) -> bool:
raise ValueError("text must be str or list[str]")
return True

def add_from_bytes(self, content: bytes, file_name: str, **kwargs) -> bool:
"""
Args:
content: bytes, the content to add to knowledgebase, bytes
file_name: str, the file name of the content
**kwargs:
- tos_bucket_name: str, the bucket name of TOS
- tos_bucket_path: str, the path of TOS bucket
"""
tos_bucket_name, tos_bucket_path = _extract_tos_attributes(**kwargs)
tos_url = _upload_bytes_to_tos(
content,
tos_bucket_name=tos_bucket_name,
object_key=f"{tos_bucket_path}/{file_name}",
)
response = self._add_doc(tos_url=tos_url)
if response["code"] == 0:
return True
return False

@override
def search(self, query: str, top_k: int = 5) -> list:
return self._search_knowledge(query=query, top_k=top_k)
Expand Down