Docs: set api_key to env (#2252)
This commit is contained in:
@@ -19,9 +19,12 @@ Here's how to set custom categories:
|
|||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Code
|
```python Code
|
||||||
|
import os
|
||||||
from mem0 import MemoryClient
|
from mem0 import MemoryClient
|
||||||
|
|
||||||
client = MemoryClient(api_key="<your_mem0_api_key>")
|
os.environ["MEM0_API_KEY"] = "your-api-key"
|
||||||
|
|
||||||
|
client = MemoryClient()
|
||||||
|
|
||||||
# Update custom categories
|
# Update custom categories
|
||||||
new_categories = [
|
new_categories = [
|
||||||
@@ -95,8 +98,11 @@ You can also set custom categories during the `add` API call. This will override
|
|||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Code
|
```python Code
|
||||||
|
import os
|
||||||
from mem0 import MemoryClient
|
from mem0 import MemoryClient
|
||||||
|
|
||||||
|
os.environ["MEM0_API_KEY"] = "your-api-key"
|
||||||
|
|
||||||
client = MemoryClient(api_key="<your_mem0_api_key>")
|
client = MemoryClient(api_key="<your_mem0_api_key>")
|
||||||
|
|
||||||
custom_categories = [
|
custom_categories = [
|
||||||
@@ -148,9 +154,12 @@ Here is the list of **default categories**. If you don't specify any custom cate
|
|||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Code
|
```python Code
|
||||||
|
import os
|
||||||
from mem0 import MemoryClient
|
from mem0 import MemoryClient
|
||||||
|
|
||||||
client = MemoryClient(api_key="<your_mem0_api_key>")
|
os.environ["MEM0_API_KEY"] = "your-api-key"
|
||||||
|
|
||||||
|
client = MemoryClient()
|
||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
{"role": "user", "content": "Hi, my name is Alice."},
|
{"role": "user", "content": "Hi, my name is Alice."},
|
||||||
|
|||||||
@@ -29,9 +29,12 @@ Users can define specific kinds of memories to store. This feature enhances memo
|
|||||||
Here’s how you can do it:
|
Here’s how you can do it:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
import os
|
||||||
from mem0 import MemoryClient
|
from mem0 import MemoryClient
|
||||||
|
|
||||||
m = MemoryClient(api_key="xxx")
|
os.environ["MEM0_API_KEY"] = "your-api-key"
|
||||||
|
|
||||||
|
m = MemoryClient()
|
||||||
|
|
||||||
# Define what to include
|
# Define what to include
|
||||||
includes = "sports related things"
|
includes = "sports related things"
|
||||||
|
|||||||
@@ -30,9 +30,10 @@ USER_ID = "customer_service_bot"
|
|||||||
|
|
||||||
# Set up OpenAI API key
|
# Set up OpenAI API key
|
||||||
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
||||||
|
os.environ['MEM0_API_KEY'] = MEM0_API_KEY
|
||||||
|
|
||||||
# Initialize Mem0 and AutoGen agents
|
# Initialize Mem0 and AutoGen agents
|
||||||
memory_client = MemoryClient(api_key=MEM0_API_KEY)
|
memory_client = MemoryClient()
|
||||||
agent = ConversableAgent(
|
agent = ConversableAgent(
|
||||||
"chatbot",
|
"chatbot",
|
||||||
llm_config={"config_list": [{"model": "gpt-4", "api_key": OPENAI_API_KEY}]},
|
llm_config={"config_list": [{"model": "gpt-4", "api_key": OPENAI_API_KEY}]},
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ os.environ["MEM0_API_KEY"] = "your-mem0-api-key"
|
|||||||
|
|
||||||
# Initialize LangChain and Mem0
|
# Initialize LangChain and Mem0
|
||||||
llm = ChatOpenAI(model="gpt-4o-mini")
|
llm = ChatOpenAI(model="gpt-4o-mini")
|
||||||
mem0 = MemoryClient(api_key=os.environ["MEM0_API_KEY"])
|
mem0 = MemoryClient()
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create Prompt Template
|
## Create Prompt Template
|
||||||
|
|||||||
@@ -34,10 +34,11 @@ USER_ID = "your-user-id"
|
|||||||
|
|
||||||
# Set up OpenAI API key
|
# Set up OpenAI API key
|
||||||
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
||||||
|
os.environ['MEM0_API_KEY'] = MEM0_API_KEY
|
||||||
|
|
||||||
# Initialize Mem0 and MultiOn
|
# Initialize Mem0 and MultiOn
|
||||||
memory = Memory() # For local usage
|
memory = Memory() # For local usage
|
||||||
memory_client = MemoryClient(api_key=MEM0_API_KEY) # For API usage
|
memory_client = MemoryClient() # For API usage
|
||||||
multion = MultiOn(api_key=MULTION_API_KEY)
|
multion = MultiOn(api_key=MULTION_API_KEY)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user