Use FutureAGI Knowledge Base to create and manage your knowledge base
You can checkout the colab notebook to quickly get started with the FutureAGI Knowledge Base.
Installing FutureAGI SDK
pip install futureagi
Initializing FutureAGI Knowledge Base
from fi.kb import KnowledgeBase# Initialize the Knowledge Base clientkb_client = KnowledgeBase()
Create a Knowledge Base
# Create a new knowledge base with fileskb_client = kb_client.create_kb( name="my_knowledge_base", # Choose a unique name file_paths=["path/to/file1.txt", "path/to/file2.txt"] # List of file paths to include)# The created KB will have an ID and list of filesprint(f"Created KB: {kb_client.kb.id} with name: {kb_client.kb.name}")print(f"Number of files: {len(kb_client.kb.files)}")
Update a Knowledge Base
# Add new files to the existing knowledge basekb_client = kb_client.update_kb( file_paths=["path/to/new_file.txt"] # List of new file paths to add)# The updated KB will have the new filesprint(f"Updated KB: {kb_client.kb.id}")print(f"Total files: {len(kb_client.kb.files)}")
Delete Files from Knowledge Base
# Delete specific files from the knowledge basefile_names = ["file_to_delete.txt"]kb_client = kb_client.delete_files_from_kb( file_names=file_names # List of file names to delete)# The KB will now have fewer filesprint(f"Remaining files: {len(kb_client.kb.files)}")
Delete a Knowledge Base
# Delete the entire knowledge basekb_id = kb_client.kb.idkb_client = kb_client.delete_kb(kb_ids=[kb_id])
When working with knowledge bases, make sure to:
Use unique names for your knowledge bases
Keep track of file paths and names
Handle exceptions appropriately
Clean up knowledge bases when they’re no longer needed