Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add agent memories #326

Merged
merged 10 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Next, configure your LLM provider. ControlFlow's default provider is OpenAI, whi
export OPENAI_API_KEY=your-api-key
```

To use a different LLM provider, [see the LLM configuration docs](https://controlflow.ai/guides/llms).
To use a different LLM provider, [see the LLM configuration docs](https://controlflow.ai/guides/configure-llms).


## Workflow Example
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Tools are Python functions that the agent can call to perform specific actions o

Each agent has a model, which is the LLM that powers the agent responses. This allows you to choose the most suitable model for your needs, based on factors such as performance, latency, and cost.

ControlFlow supports any LangChain LLM that supports chat and function calling. For more details on how to configure models, see the [LLMs guide](/guides/llms).
ControlFlow supports any LangChain LLM that supports chat and function calling. For more details on how to configure models, see the [LLMs guide](/guides/configure-llms).

### Interactivity

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/llms.mdx → docs/guides/configure-llms.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Configuring LLM models
title: LLM Models
description: ControlFlow supports a variety of LLMs and model providers.
icon: sliders
---
Expand Down
5 changes: 3 additions & 2 deletions docs/guides/default-agent.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Configuring the Default Agent
title: Configuring a Default Agent
sidebarTitle: Default Agent
description: Set global and flow-specific defaults.
icon: robot
---
Expand All @@ -8,7 +9,7 @@ ControlFlow uses a default agent when no specific agents are assigned to a task.

## Changing the Global Default Agent

The global default agent (whose name, of course, is Marvin) uses whatever [default model](/guides/llms#changing-the-default-model) you've configured. It has a basic set of general-purpose instructions and is not equipped with any tools.
The global default agent (whose name, of course, is Marvin) uses whatever [default model](/guides/configure-llms#changing-the-default-model) you've configured. It has a basic set of general-purpose instructions and is not equipped with any tools.

To change the global default agent, assign a new agent to `controlflow.defaults.agent`:

Expand Down
60 changes: 60 additions & 0 deletions docs/guides/default-memory.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Configure a Default Memory Provider
sidebarTitle: Default Memory Provider
description: Set up a default persistent memory provider for your agents
icon: brain
---

ControlFlow's [memory](/patterns/memory) feature allows agents to store and retrieve information across multiple workflows. Memory modules are backed by a vector database, configured using a `MemoryProvider`.

Setting up a default provider simplifies the process of creating memory objects throughout your application. Once configured, you can create memory objects without specifying a provider each time.

<Tip>
While ControlFlow does not include any vector database dependencies by default, the default provider is set to `"chroma-db"`. This means that if you install the `chromadb` package, your memory modules will work without any additional configuration.
</Tip>

## Install dependencies

To use a provider, you must first install its dependencies. Please refer to the [Memory doc](/patterns/memory) to see all supported providers and their required dependencies.

For example, to use the default [Chroma](https://trychroma.com/) provider, you need to install `chromadb`:

```bash
pip install chromadb
```

## Configure a default provider

There are two ways to set up a default provider: using a string setting for common defaults, or instantiating a custom provider. Here, we'll use a persistent Chroma database as our example.

### String configurations

For simple provider setups, you can modify ControlFlow's default settings using a string value. The default value is `"chroma-db"`, which will create a persistent Chroma database. To change it:

<CodeGroup>
```bash Environment variable
export CONTROLFLOW_MEMORY_PROVIDER="chroma-ephemeral"
```
```python Runtime
import controlflow as cf

cf.settings.memory_provider = "chroma-ephemeral"
```
</CodeGroup>

For a list of available string configurations, see the [Memory pattern guide](/patterns/memory).

### Custom provider configuration

For more advanced setups, instantiate a provider with custom settings and assign it to the ControlFlow default. Note this must be done at runtime.

```python
import controlflow as cf
from controlflow.memory.providers.chroma import ChromaMemory
import chromadb

# Set the default provider
cf.defaults.memory_provider = ChromaMemory(
client=chromadb.PersistentClient(path="/custom/path"),
)
```
2 changes: 1 addition & 1 deletion docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export CONTROLFLOW_LLM_MODEL="anthropic/claude-3-5-sonnet-20240620"

### Other providers

ControlFlow supports many other LLM providers as well, though you'll need to install their respective packages and configure the default LLM appropriately. See the [LLM documentation](/guides/llms) for more information.
ControlFlow supports many other LLM providers as well, though you'll need to install their respective packages and configure the default LLM appropriately. See the [LLM documentation](/guides/configure-llms) for more information.


## Next steps
Expand Down
6 changes: 4 additions & 2 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"patterns/tools",
"patterns/interactivity",
"patterns/dependencies",
"patterns/memory",
"patterns/instructions",
"patterns/planning",
"patterns/history"
Expand All @@ -66,8 +67,9 @@
"group": "Configuration",
"pages": [
"guides/settings",
"guides/llms",
"guides/default-agent"
"guides/configure-llms",
"guides/default-agent",
"guides/default-memory"
]
},
{
Expand Down
Loading