You can checkout the colab notebook to quickly get started with the FutureAGI Knowledge Base. Open In Colab

Installing FutureAGI SDK

pip install futureagi

Initializing FutureAGI Knowledge Base

from fi.kb import KnowledgeBase

# Initialize the Knowledge Base client
kb_client = KnowledgeBase()

Create a Knowledge Base

# Create a new knowledge base with files
kb_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 files
print(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 base
kb_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 files
print(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 base
file_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 files
print(f"Remaining files: {len(kb_client.kb.files)}")

Delete a Knowledge Base

# Delete the entire knowledge base
kb_id = kb_client.kb.id
kb_client = kb_client.delete_kb(kb_ids=[kb_id])

When working with knowledge bases, make sure to:

  1. Use unique names for your knowledge bases
  2. Keep track of file paths and names
  3. Handle exceptions appropriately
  4. Clean up knowledge bases when they’re no longer needed