> ## Documentation Index
> Fetch the complete documentation index at: https://futureagi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Base

> Use FutureAGI Knowledge Base to create and manage your knowledge base

You can checkout the [colab notebook](https://colab.research.google.com/drive/1VPfOA6HlO-0WBE-gK98-mZ3sGd5L4en4?usp=sharing) to quickly get started with the FutureAGI Knowledge Base. <a href="https://colab.research.google.com/drive/1VPfOA6HlO-0WBE-gK98-mZ3sGd5L4en4?usp=sharing"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab" /></a>

## Installing FutureAGI SDK

```bash theme={null}
pip install futureagi
```

## Initializing FutureAGI Knowledge Base

```python theme={null}
from fi.kb import KnowledgeBase

# Initialize the Knowledge Base client
kb_client = KnowledgeBase()
```

## Create a Knowledge Base

```python theme={null}
# 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

```python theme={null}
# 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

```python theme={null}
# 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

```python theme={null}
# Delete the entire knowledge base
kb_id = kb_client.kb.id
kb_client = kb_client.delete_kb(kb_ids=[kb_id])
```

<Tip>
  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
</Tip>
