Add TogetherAI support (#1485)

This commit is contained in:
Dev Khant
2024-07-17 01:49:18 +05:30
committed by GitHub
parent 03f787d5cb
commit b620f8fae3
7 changed files with 883 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ Mem0 includes built-in support for various popular large language models. Memory
<CardGroup cols={4}>
<Card title="OpenAI" href="#openai"></Card>
<Card title="Groq" href="#groq"></Card>
<Card title="Together" href="#together"></Card>
</CardGroup>
## OpenAI
@@ -64,3 +65,30 @@ config = {
m = Memory.from_config(config)
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})
```
## TogetherAI
To use TogetherAI LLM models, you have to set the `TOGETHER_API_KEY` environment variable. You can obtain the TogetherAI API key from their [Account settings page](https://api.together.xyz/settings/api-keys).
Once you have obtained the key, you can use it like this:
```python
import os
from mem0 import Memory
os.environ['TOGETHER_API_KEY'] = 'xxx'
config = {
"llm": {
"provider": "togetherai",
"config": {
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"temperature": 0.2,
"max_tokens": 1500,
}
}
}
m = Memory.from_config(config)
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})
```