INNER CODE UNIT · Python
create_kb
SPThole/CoexistAI · app.py:550
async def create_kb(request: KnowledgeBaseRequest):
"""
Creates a knowledge base from the provided document paths.
Processes all files in the paths, embeds them, and saves to a vector database.
Args:
document_paths (list of str): List of paths to folders or files to include in the knowledge base.
Returns:
str: The name of the created vector database collection.
"""
try:
collection_name = await create_knowledge_base(
document_paths=request.document_paths,
hf_embeddings=hf_embeddings
)
return f"Knowledge base created successfully. Collection name: {collection_name}"
except Exception as e: