license:mit region:us
---
license: mit
---
# Table of Contents

* [run](#run)
* [ChromaDBFlow](#ChromaDBFlow)
  * [ChromaDBFlow](#ChromaDBFlow.ChromaDBFlow)
    * [instantiate\_from\_config](#ChromaDBFlow.ChromaDBFlow.instantiate_from_config)
    * [run](#ChromaDBFlow.ChromaDBFlow.run)
* [VectorStoreFlow](#VectorStoreFlow)
  * [VectorStoreFlow](#VectorStoreFlow.VectorStoreFlow)
    * [instantiate\_from\_config](#VectorStoreFlow.VectorStoreFlow.instantiate_from_config)
    * [package\_documents](#VectorStoreFlow.VectorStoreFlow.package_documents)
    * [run](#VectorStoreFlow.VectorStoreFlow.run)
* [\_\_init\_\_](#__init__)

<a id="run"></a>

# run

A simple script to run a Flow that can be used for development and debugging.

<a id="ChromaDBFlow"></a>

# ChromaDBFlow

<a id="ChromaDBFlow.ChromaDBFlow"></a>

## ChromaDBFlow Objects

```python
class ChromaDBFlow(AtomicFlow)
```

A flow that uses the ChromaDB model to write and read memories stored in a database

*Configuration Parameters*:

- `name` (str): The name of the flow. Default: "chroma_db"
- `description` (str): A description of the flow. This description is used to generate the help message of the flow. 
Default: "ChromaDB is a document store that uses vector embeddings to store and retrieve documents."
- `backend` (Dict[str, Any]): The configuration of the backend which is used to fetch api keys. Default: LiteLLMBackend with the
default parameters of LiteLLMBackend (see aiflows.backends.LiteLLMBackend). Except for the following parameter whose default value is overwritten:
    - `api_infos` (List[Dict[str, Any]]): The list of api infos. Default: No default value, this parameter is required.
    - `model_name` (str): The name of the model. Default: "". In the current implementation, this parameter is not used.
- `similarity_search_kwargs` (Dict[str, Any]): The parameters to pass to the similarity search method of the ChromaDB. Default:
    - `k` (int): The number of documents to retrieve. Default: 2
    - `filter` (str): The filter to apply to the documents. Default: null
- `paths_to_data` (List[str]): The paths to the data to store in the database at instantiation. Default: []
- `chunk_size` (int): The size of the chunks to split the documents into. Default: 700
- `seperator` (str): The separator to use to split the documents. Default: "\n"
- `chunk_overlap` (int): The overlap between the chunks. Default: 0
- `persist_directory` (str): The directory to persist the database. Default: "./demo_db_dir"

- Other parameters are inherited from the default configuration of AtomicFlow (see AtomicFlow)

*Input Interface*:

- `operation` (str): The operation to perform. It can be "write" or "read".
- `content` (str or List[str]): The content to write or read. If operation is "write", it must be a string or a list of strings. If operation is "read", it must be a string.

*Output Interface*:

- `retrieved` (str or List[str]): The retrieved content. If operation is "write", it is an empty string. If operation is "read", it is a string or a list of strings.

**Arguments**:

- `backend` (`LiteLLMBackend`): The backend of the flow (used to retrieve the API key)
- `\**kwargs`: Additional arguments to pass to the flow.

<a id="ChromaDBFlow.ChromaDBFlow.instantiate_from_config"></a>

#### instantiate\_from\_config

```python
@classmethod
def instantiate_from_config(cls, config)
```

This method instantiates the flow from a configuration file

**Arguments**:

- `config` (`Dict[str, Any]`): The configuration of the flow.

**Returns**:

`ChromaDBFlow`: The instantiated flow.

<a id="ChromaDBFlow.ChromaDBFlow.run"></a>

#### run

```python
def run(input_message: FlowMessage)
```

This method runs the flow. It runs the ChromaDBFlow. It either writes or reads memories from the database.

**Arguments**:

- `input_message` (`FlowMessage`): The input message of the flow.

<a id="VectorStoreFlow"></a>

# VectorStoreFlow

<a id="VectorStoreFlow.VectorStoreFlow"></a>

## VectorStoreFlow Objects

```python
class VectorStoreFlow(AtomicFlow)
```

A flow that uses the VectorStore model to write and read memories stored in a database (see VectorStoreFlow.yaml for the default configuration)

*Configuration Parameters*:

- `name` (str): The name of the flow. Default: "VecotrStoreFlow"
- `description` (str): A description of the flow. This description is used to generate the help message of the flow.
Default: "VectorStoreFlow"
- `backend` (Dict[str, Any]): The configuration of the backend which is used to fetch api keys. Default: LiteLLMBackend with the
default parameters of LiteLLMBackend (see flows.backends.LiteLLMBackend). Except for the following parameter whose default value is overwritten:
    - `api_infos` (List[Dict[str, Any]]): The list of api infos. Default: No default value, this parameter is required.
    - `model_name` (str): The name of the model. Default: "". In the current implementation, this parameter is not used.
- `type` (str): The type of the vector store. It can be "chroma" or "faiss". Default: "chroma"
- `embedding_size` (int): The size of the embeddings (only for faiss). Default: 1536
- `retriever_config` (Dict[str, Any]): The configuration of the retriever. Default: empty dictionary
- Other parameters are inherited from the default configuration of AtomicFlow (see AtomicFlow)

*Input Interface*:

- `operation` (str): The operation to perform. It can be "write" or "read".
- `content` (str or List[str]): The content to write or read. If operation is "write", it must be a string or a list of strings. If operation is "read", it must be a string.

*Output Interface*:

- `retrieved` (str or List[str]): The retrieved content. If operation is "write", it is an empty string. If operation is "read", it is a string or a list of strings.

**Arguments**:

- `backend` (`LiteLLMBackend`): The backend of the flow (used to retrieve the API key)
- `vector_db` (`VectorStoreRetriever`): The vector store retriever
- `type` (`str`): The type of the vector store
- `\**kwargs`: Additional arguments to pass to the flow. See :class:`aiflows.base_flows.AtomicFlow` for more details.

<a id="VectorStoreFlow.VectorStoreFlow.instantiate_from_config"></a>

#### instantiate\_from\_config

```python
@classmethod
def instantiate_from_config(cls, config: Dict[str, Any])
```

This method instantiates the flow from a configuration file

**Arguments**:

- `config` (`Dict[str, Any]`): The configuration of the flow.

**Returns**:

`VectorStoreFlow`: The instantiated flow.

<a id="VectorStoreFlow.VectorStoreFlow.package_documents"></a>

#### package\_documents

```python
@staticmethod
def package_documents(documents: List[str]) -> List[Document]
```

This method packages the documents in a list of Documents.

**Arguments**:

- `documents` (`List[str]`): The documents to package.

**Returns**:

`List[Document]`: The packaged documents.

<a id="VectorStoreFlow.VectorStoreFlow.run"></a>

#### run

```python
def run(input_message: FlowMessage)
```

This method runs the flow. It either writes or reads memories from the database.

**Arguments**:

- `input_message` (`FlowMessage`): The input data of the flow.

<a id="__init__"></a>

# \_\_init\_\_

