[Update] Default LLM (#3587)
This commit is contained in:
@@ -103,7 +103,7 @@ memory = Memory()
|
||||
# With custom configuration
|
||||
config = MemoryConfig(
|
||||
vector_store={"provider": "qdrant", "config": {"host": "localhost"}},
|
||||
llm={"provider": "openai", "config": {"model": "gpt-4o-mini"}},
|
||||
llm={"provider": "openai", "config": {"model": "gpt-4.1-nano-2025-04-14"}},
|
||||
embedder={"provider": "openai", "config": {"model": "text-embedding-3-small"}}
|
||||
)
|
||||
memory = Memory(config)
|
||||
@@ -339,7 +339,7 @@ config = MemoryConfig(
|
||||
llm={
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.1,
|
||||
"max_tokens": 1000
|
||||
}
|
||||
@@ -527,7 +527,7 @@ const memory = new Memory({
|
||||
},
|
||||
llm: {
|
||||
provider: 'openai',
|
||||
config: { model: 'gpt-4o-mini' }
|
||||
config: { model: 'gpt-4.1-nano' }
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ npm install mem0ai
|
||||
|
||||
### Basic Usage
|
||||
|
||||
Mem0 requires an LLM to function, with `gpt-4o-mini` from OpenAI as the default. However, it supports a variety of LLMs; for details, refer to our [Supported LLMs documentation](https://docs.mem0.ai/components/llms/overview).
|
||||
Mem0 requires an LLM to function, with `gpt-4.1-nano-2025-04-14 from OpenAI as the default. However, it supports a variety of LLMs; for details, refer to our [Supported LLMs documentation](https://docs.mem0.ai/components/llms/overview).
|
||||
|
||||
First step is to instantiate the memory:
|
||||
|
||||
@@ -114,7 +114,7 @@ def chat_with_memories(message: str, user_id: str = "default_user") -> str:
|
||||
# Generate Assistant response
|
||||
system_prompt = f"You are a helpful AI. Answer the question based on query and memories.\nUser Memories:\n{memories_str}"
|
||||
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": message}]
|
||||
response = openai_client.chat.completions.create(model="gpt-4o-mini", messages=messages)
|
||||
response = openai_client.chat.completions.create(model="gpt-4.1-nano-2025-04-14", messages=messages)
|
||||
assistant_response = response.choices[0].message.content
|
||||
|
||||
# Create new memories from the conversation
|
||||
|
||||
@@ -20,7 +20,7 @@ os.environ["OPENAI_API_KEY"] = "your-api-key"
|
||||
|
||||
# Initialize a LangChain model directly
|
||||
openai_model = ChatOpenAI(
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
temperature=0.2,
|
||||
max_tokens=2000
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "litellm",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
@@ -85,7 +85,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai_structured",
|
||||
"config": {
|
||||
"model": "gpt-4o-2024-08-06",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ ${memoriesStr}`;
|
||||
];
|
||||
|
||||
const response = await openaiClient.chat.completions.create({
|
||||
model: "gpt-4o-mini",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
messages: messages
|
||||
});
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class CollaborativeAgent:
|
||||
{"role": "user", "content": f"Prompt: {prompt}\nContext:\n{context}"}
|
||||
]
|
||||
reply = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
messages=messages
|
||||
).choices[0].message.content.strip()
|
||||
self.add_message("assistant", "assistant", reply)
|
||||
|
||||
@@ -44,7 +44,7 @@ MEM0_API_KEY= # Mem0 API Key (get from https://app.mem0.ai/dashboard/api-keys)
|
||||
MEM0_USER_ID= # Default: eliza-os-user
|
||||
MEM0_PROVIDER= # Default: openai
|
||||
MEM0_PROVIDER_API_KEY= # API Key for the provider (OpenAI, Anthropic, etc.)
|
||||
SMALL_MEM0_MODEL= # Default: gpt-4o-mini
|
||||
SMALL_MEM0_MODEL= # Default: gpt-4.1-nano
|
||||
MEDIUM_MEM0_MODEL= # Default: gpt-4o
|
||||
LARGE_MEM0_MODEL= # Default: gpt-4o
|
||||
```
|
||||
|
||||
@@ -20,7 +20,7 @@ import os
|
||||
from llama_index.llms.openai import OpenAI
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = "<your-openai-api-key>"
|
||||
llm = OpenAI(model="gpt-4o")
|
||||
llm = OpenAI(model="gpt-4.1-nano-2025-04-14")
|
||||
```
|
||||
|
||||
Initialize the Mem0 client. You can find your API key [here](https://app.mem0.ai/dashboard/api-keys). Read about Mem0 [Open Source](https://docs.mem0.ai/open-source/overview).
|
||||
|
||||
@@ -81,7 +81,7 @@ class MultiAgentLearningSystem:
|
||||
|
||||
def __init__(self, student_id: str):
|
||||
self.student_id = student_id
|
||||
self.llm = OpenAI(model="gpt-4o", temperature=0.2)
|
||||
self.llm = OpenAI(model="gpt-4.1-nano-2025-04-14", temperature=0.2)
|
||||
|
||||
# Memory context for this student
|
||||
self.memory_context = {"user_id": student_id, "app": "learning_assistant"}
|
||||
|
||||
@@ -97,7 +97,7 @@ export const mem0Agent = new Agent({
|
||||
instructions: `
|
||||
You are a helpful assistant that has the ability to memorize and remember facts using Mem0.
|
||||
`,
|
||||
model: openai('gpt-4o'),
|
||||
model: openai('gpt-4.1-nano'),
|
||||
tools: { mem0RememberTool, mem0MemorizeTool },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -162,7 +162,7 @@ def create_memory_voice_agent():
|
||||
Use the search_memories tool when you need context from past conversations or user asks you to recall something.
|
||||
""",
|
||||
),
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
tools=[save_memories, search_memories],
|
||||
)
|
||||
|
||||
@@ -171,7 +171,7 @@ def create_memory_voice_agent():
|
||||
|
||||
This function:
|
||||
- Creates an OpenAI Agent with specific instructions
|
||||
- Configures it to use gpt-4o (you can use other models)
|
||||
- Configures it to use gpt-4.1-nano (you can use other models)
|
||||
- Registers the memory-related tools with the agent
|
||||
- Uses `prompt_with_handoff_instructions` to include standard voice agent behaviors
|
||||
|
||||
@@ -369,7 +369,7 @@ def create_memory_voice_agent():
|
||||
Use the search_memories tool when you need context from past conversations or user asks you to recall something.
|
||||
""",
|
||||
),
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
tools=[save_memories, search_memories],
|
||||
)
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ Preferences:
|
||||
]
|
||||
|
||||
response = openai.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
messages=messages
|
||||
)
|
||||
clean_response = response.choices[0].message.content.strip()
|
||||
|
||||
@@ -119,7 +119,7 @@ const carRecommendationTool = zodResponsesFunction({
|
||||
|
||||
// Use the tool in your OpenAI request
|
||||
const response = await openAIClient.responses.create({
|
||||
model: "gpt-4o",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
tools: [{ type: "web_search_preview" }, carRecommendationTool],
|
||||
input: `${getMemoryString(relevantMemories)}\n${userInput}`,
|
||||
});
|
||||
@@ -131,7 +131,7 @@ Combine memory with web search for up-to-date recommendations:
|
||||
|
||||
```javascript
|
||||
const response = await openAIClient.responses.create({
|
||||
model: "gpt-4o",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
tools: [{ type: "web_search_preview" }, carRecommendationTool],
|
||||
input: `${getMemoryString(relevantMemories)}\n${userInput}`,
|
||||
});
|
||||
@@ -202,7 +202,7 @@ async function main(memory = false) {
|
||||
}
|
||||
|
||||
const response = await openAIClient.responses.create({
|
||||
model: "gpt-4o",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
tools: [{ type: "web_search_preview" }, tool],
|
||||
input: `${getMemoryString(relevantMemories)}\n${input}`,
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ class PersonalAITutor:
|
||||
"""
|
||||
# Start a streaming response request to the AI
|
||||
response = self.client.responses.create(
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
instructions="You are a personal AI Tutor.",
|
||||
input=question,
|
||||
stream=True
|
||||
|
||||
@@ -35,7 +35,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.1,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class PersonalTravelAssistant:
|
||||
|
||||
# Generate response using Responses API
|
||||
response = self.client.responses.create(
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
input=prompt
|
||||
)
|
||||
|
||||
@@ -140,9 +140,9 @@ class PersonalTravelAssistant:
|
||||
prompt = f"User input: {question}\n Previous memories: {previous_memories}"
|
||||
self.messages.append({"role": "user", "content": prompt})
|
||||
|
||||
# Generate response using GPT-4o
|
||||
# Generate response using gpt-4.1-nano
|
||||
response = self.client.chat.completions.create(
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14"2025-04-14",
|
||||
messages=self.messages
|
||||
)
|
||||
answer = response.choices[0].message.content
|
||||
|
||||
@@ -49,7 +49,7 @@ local_config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.1,
|
||||
"max_tokens": 2000,
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ from agno.tools.mem0 import Mem0Tools
|
||||
|
||||
agent = Agent(
|
||||
name="Memory Agent",
|
||||
model=OpenAIChat(id="gpt-4o-mini"),
|
||||
model=OpenAIChat(id="gpt-4.1-nano-2025-04-14"),
|
||||
tools=[Mem0Tools()],
|
||||
description="An assistant that remembers and personalizes using Mem0 memory."
|
||||
)
|
||||
|
||||
@@ -55,7 +55,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.0,
|
||||
"api_key": keywordsai_api_key,
|
||||
"openai_base_url": base_url,
|
||||
@@ -101,7 +101,7 @@ messages = [
|
||||
|
||||
# Add memory and generate a response
|
||||
response = client.chat.completions.create(
|
||||
model="openai/gpt-4o",
|
||||
model="openai/gpt-4.1-nano",
|
||||
messages=messages,
|
||||
extra_body={
|
||||
"mem0_params": {
|
||||
|
||||
@@ -39,7 +39,7 @@ load_dotenv()
|
||||
# os.environ["MEM0_API_KEY"] = "your-mem0-api-key"
|
||||
|
||||
# Initialize LangChain and Mem0
|
||||
llm = ChatOpenAI(model="gpt-4o-mini")
|
||||
llm = ChatOpenAI(model="gpt-4.1-nano-2025-04-14")
|
||||
mem0 = MemoryClient()
|
||||
```
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ async def entrypoint(ctx: JobContext):
|
||||
|
||||
session = AgentSession(
|
||||
stt=deepgram.STT(),
|
||||
llm=openai.LLM(model="gpt-4o-mini"),
|
||||
llm=openai.LLM(model="gpt-4.1-nano-2025-04-14"),
|
||||
tts=openai.TTS(voice="ash",),
|
||||
turn_detection=EnglishModel(),
|
||||
vad=silero.VAD.load(),
|
||||
|
||||
@@ -83,7 +83,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
},
|
||||
@@ -116,7 +116,7 @@ from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
# os.environ["OPENAI_API_KEY"] = "<your-openai-api-key>"
|
||||
llm = OpenAI(model="gpt-4o-mini")
|
||||
llm = OpenAI(model="gpt-4.1-nano-2025-04-14")
|
||||
```
|
||||
|
||||
### SimpleChatEngine
|
||||
|
||||
@@ -106,7 +106,7 @@ const mem0Agent = new Agent({
|
||||
Use the Mem0-memorize tool to save important information that might be useful later.
|
||||
Use the Mem0-remember tool to recall previously saved information when answering questions.
|
||||
`,
|
||||
model: openai('gpt-4o'),
|
||||
model: openai('gpt-4.1-nano'),
|
||||
tools: { mem0RememberTool, mem0MemorizeTool },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -63,7 +63,7 @@ agent = Agent(
|
||||
Use the save_memory tool to store important information about the user.
|
||||
Always personalize your responses based on available memory.""",
|
||||
tools=[search_memory, save_memory],
|
||||
model="gpt-4o"
|
||||
model="gpt-4.1-nano-2025-04-14"
|
||||
)
|
||||
|
||||
def chat_with_agent(user_input: str, user_id: str) -> str:
|
||||
@@ -114,7 +114,7 @@ travel_agent = Agent(
|
||||
understand the user's travel preferences and history before making recommendations.
|
||||
After providing your response, use store_conversation to save important details.""",
|
||||
tools=[search_memory, save_memory],
|
||||
model="gpt-4o"
|
||||
model="gpt-4.1-nano-2025-04-14"
|
||||
)
|
||||
|
||||
health_agent = Agent(
|
||||
@@ -123,7 +123,7 @@ health_agent = Agent(
|
||||
understand the user's health goals and dietary preferences.
|
||||
After providing advice, use store_conversation to save relevant information.""",
|
||||
tools=[search_memory, save_memory],
|
||||
model="gpt-4o"
|
||||
model="gpt-4.1-nano-2025-04-14"
|
||||
)
|
||||
|
||||
# Triage agent with handoffs
|
||||
@@ -134,7 +134,7 @@ triage_agent = Agent(
|
||||
For health-related questions (fitness, diet, wellness, exercise), hand off to the Health Advisor.
|
||||
For general questions, handle them directly using available tools.""",
|
||||
handoffs=[travel_agent, health_agent],
|
||||
model="gpt-4o"
|
||||
model="gpt-4.1-nano-2025-04-14"
|
||||
)
|
||||
|
||||
def chat_with_handoffs(user_input: str, user_id: str) -> str:
|
||||
|
||||
@@ -202,7 +202,7 @@ async def chat_with_memories(message: str, user_id: str = "default_user") -> str
|
||||
# Generate assistant response
|
||||
system_prompt = f"You are a helpful AI. Answer the question based on query and memories.\nUser Memories:\n{memories_str}"
|
||||
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": message}]
|
||||
response = await async_openai_client.chat.completions.create(model="gpt-4o-mini", messages=messages)
|
||||
response = await async_openai_client.chat.completions.create(model="gpt-4.1-nano-2025-04-14", messages=messages)
|
||||
assistant_response = response.choices[0].message.content
|
||||
|
||||
# Create new memories from the conversation
|
||||
@@ -249,7 +249,7 @@ async def handle_initialization_errors():
|
||||
# Initialize with custom config
|
||||
config = MemoryConfig(
|
||||
vector_store={"provider": "chroma", "config": {"path": "./chroma_db"}},
|
||||
llm={"provider": "openai", "config": {"model": "gpt-4o-mini"}}
|
||||
llm={"provider": "openai", "config": {"model": "gpt-4.1-nano-2025-04-14"}}
|
||||
)
|
||||
memory = AsyncMemory(config=config)
|
||||
print("AsyncMemory initialized successfully")
|
||||
|
||||
@@ -76,7 +76,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ messages = [
|
||||
user_id = "alice"
|
||||
chat_completion = client.chat.completions.create(
|
||||
messages=messages,
|
||||
model="gpt-4o-mini",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
user_id=user_id
|
||||
)
|
||||
# Memory saved after this will look like: "Loves Indian food. Allergic to cheese and cannot eat pizza."
|
||||
@@ -42,7 +42,7 @@ messages = [
|
||||
|
||||
chat_completion = client.chat.completions.create(
|
||||
messages=messages,
|
||||
model="gpt-4o-mini",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
user_id=user_id
|
||||
)
|
||||
print(chat_completion.choices[0].message.content)
|
||||
@@ -73,7 +73,7 @@ chat_completion = client.chat.completions.create(
|
||||
"content": "What's the capital of France?",
|
||||
}
|
||||
],
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ You can also customize the LLM for Graph Memory from the [Supported LLM list](ht
|
||||
|
||||
1. **Main Configuration**: If `llm` is set in the main config, it will be used for all graph operations.
|
||||
2. **Graph Store Configuration**: If `llm` is set in the graph_store config, it will override the main config `llm` and be used specifically for graph operations.
|
||||
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4o-2024-08-06`) will be used for all graph operations.
|
||||
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4.1-nano-2025-04-14) will be used for all graph operations.
|
||||
|
||||
Here's how you can do it:
|
||||
|
||||
@@ -100,7 +100,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
@@ -115,7 +115,7 @@ config = {
|
||||
"llm" : {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.0,
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@ const config = {
|
||||
llm: {
|
||||
provider: "openai",
|
||||
config: {
|
||||
model: "gpt-4o",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
temperature: 0.2,
|
||||
max_tokens: 2000,
|
||||
}
|
||||
@@ -146,7 +146,7 @@ const config = {
|
||||
llm: {
|
||||
provider: "openai",
|
||||
config: {
|
||||
model: "gpt-4o-mini",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
temperature: 0.0,
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ You can also customize the LLM for Graph Memory from the [Supported LLM list](ht
|
||||
|
||||
1. **Main Configuration**: If `llm` is set in the main config, it will be used for all graph operations.
|
||||
2. **Graph Store Configuration**: If `llm` is set in the graph_store config, it will override the main config `llm` and be used specifically for graph operations.
|
||||
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4o-2024-08-06`) will be used for all graph operations.
|
||||
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4.1-nano-2025-04-142025-04-14) will be used for all graph operations.
|
||||
|
||||
Here's how you can do it:
|
||||
|
||||
@@ -241,7 +241,7 @@ User can also customize the LLM for Graph Memory from the [Supported LLM list](h
|
||||
|
||||
1. **Main Configuration**: If `llm` is set in the main config, it will be used for all graph operations.
|
||||
2. **Graph Store Configuration**: If `llm` is set in the graph_store config, it will override the main config `llm` and be used specifically for graph operations.
|
||||
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4o-2024-08-06`) will be used for all graph operations.
|
||||
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4.1-nano-2025-04-14) will be used for all graph operations.
|
||||
|
||||
Here's how you can do it:
|
||||
|
||||
@@ -290,7 +290,7 @@ User can also customize the LLM for Graph Memory from the [Supported LLM list](h
|
||||
|
||||
1. **Main Configuration**: If `llm` is set in the main config, it will be used for all graph operations.
|
||||
2. **Graph Store Configuration**: If `llm` is set in the graph_store config, it will override the main config `llm` and be used specifically for graph operations.
|
||||
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4o-2024-08-06`) will be used for all graph operations.
|
||||
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4.1-nano-2025-04-14) will be used for all graph operations.
|
||||
|
||||
Here's how you can do it:
|
||||
|
||||
|
||||
@@ -504,7 +504,7 @@ chat_completion = client.chat.completions.create(
|
||||
"content": "What's the capital of France?",
|
||||
}
|
||||
],
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ os.environ["OPENAI_API_KEY"] = "your-api-key"
|
||||
|
||||
# Initialize a LangChain model directly
|
||||
openai_model = ChatOpenAI(
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
temperature=0.2,
|
||||
max_tokens=2000
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "litellm",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
@@ -85,7 +85,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai_structured",
|
||||
"config": {
|
||||
"model": "gpt-4o-2024-08-06",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ ${memoriesStr}`;
|
||||
];
|
||||
|
||||
const response = await openaiClient.chat.completions.create({
|
||||
model: "gpt-4o-mini",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
messages: messages
|
||||
});
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class CollaborativeAgent:
|
||||
{"role": "user", "content": f"Prompt: {prompt}\nContext:\n{context}"}
|
||||
]
|
||||
reply = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
messages=messages
|
||||
).choices[0].message.content.strip()
|
||||
self.add_message("assistant", "assistant", reply)
|
||||
|
||||
@@ -43,7 +43,7 @@ MEM0_API_KEY= # Mem0 API Key ( Get from https://app.mem0.ai/dashboard/api-keys )
|
||||
MEM0_USER_ID= # Default: eliza-os-user
|
||||
MEM0_PROVIDER= # Default: openai
|
||||
MEM0_PROVIDER_API_KEY= # API Key for the provider (openai, anthropic, etc.)
|
||||
SMALL_MEM0_MODEL= # Default: gpt-4o-mini
|
||||
SMALL_MEM0_MODEL= # Default: gpt-4.1-nano
|
||||
MEDIUM_MEM0_MODEL= # Default: gpt-4o
|
||||
LARGE_MEM0_MODEL= # Default: gpt-4o
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ import os
|
||||
from llama_index.llms.openai import OpenAI
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = "<your-openai-api-key>"
|
||||
llm = OpenAI(model="gpt-4o")
|
||||
llm = OpenAI(model="gpt-4.1-nano-2025-04-14")
|
||||
```
|
||||
|
||||
Initialize the Mem0 client. You can find your API key [here](https://app.mem0.ai/dashboard/api-keys). Read about Mem0 [Open Source](https://docs.mem0.ai/open-source/overview).
|
||||
|
||||
@@ -81,7 +81,7 @@ class MultiAgentLearningSystem:
|
||||
|
||||
def __init__(self, student_id: str):
|
||||
self.student_id = student_id
|
||||
self.llm = OpenAI(model="gpt-4o", temperature=0.2)
|
||||
self.llm = OpenAI(model="gpt-4.1-nano-2025-04-14", temperature=0.2)
|
||||
|
||||
# Memory context for this student
|
||||
self.memory_context = {"user_id": student_id, "app": "learning_assistant"}
|
||||
|
||||
@@ -98,7 +98,7 @@ export const mem0Agent = new Agent({
|
||||
instructions: `
|
||||
You are a helpful assistant that has the ability to memorize and remember facts using Mem0.
|
||||
`,
|
||||
model: openai('gpt-4o'),
|
||||
model: openai('gpt-4.1-nano'),
|
||||
tools: { mem0RememberTool, mem0MemorizeTool },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -162,7 +162,7 @@ def create_memory_voice_agent():
|
||||
Use the search_memories tool when you need context from past conversations or user asks you to recall something.
|
||||
""",
|
||||
),
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
tools=[save_memories, search_memories],
|
||||
)
|
||||
|
||||
@@ -171,7 +171,7 @@ def create_memory_voice_agent():
|
||||
|
||||
This function:
|
||||
- Creates an OpenAI Agent with specific instructions
|
||||
- Configures it to use gpt-4o (you can use other models)
|
||||
- Configures it to use gpt-4.1-nano (you can use other models)
|
||||
- Registers the memory-related tools with the agent
|
||||
- Uses `prompt_with_handoff_instructions` to include standard voice agent behaviors
|
||||
|
||||
@@ -369,7 +369,7 @@ def create_memory_voice_agent():
|
||||
Use the search_memories tool when you need context from past conversations or user asks you to recall something.
|
||||
""",
|
||||
),
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
tools=[save_memories, search_memories],
|
||||
)
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ Preferences:
|
||||
]
|
||||
|
||||
response = openai.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
messages=messages
|
||||
)
|
||||
clean_response = response.choices[0].message.content.strip()
|
||||
|
||||
@@ -119,7 +119,7 @@ const carRecommendationTool = zodResponsesFunction({
|
||||
|
||||
// Use the tool in your OpenAI request
|
||||
const response = await openAIClient.responses.create({
|
||||
model: "gpt-4o",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
tools: [{ type: "web_search_preview" }, carRecommendationTool],
|
||||
input: `${getMemoryString(relevantMemories)}\n${userInput}`,
|
||||
});
|
||||
@@ -131,7 +131,7 @@ Combine memory with web search for up-to-date recommendations:
|
||||
|
||||
```javascript
|
||||
const response = await openAIClient.responses.create({
|
||||
model: "gpt-4o",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
tools: [{ type: "web_search_preview" }, carRecommendationTool],
|
||||
input: `${getMemoryString(relevantMemories)}\n${userInput}`,
|
||||
});
|
||||
@@ -202,7 +202,7 @@ async function main(memory = false) {
|
||||
}
|
||||
|
||||
const response = await openAIClient.responses.create({
|
||||
model: "gpt-4o",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
tools: [{ type: "web_search_preview" }, tool],
|
||||
input: `${getMemoryString(relevantMemories)}\n${input}`,
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ class PersonalAITutor:
|
||||
"""
|
||||
# Start a streaming response request to the AI
|
||||
response = self.client.responses.create(
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
instructions="You are a personal AI Tutor.",
|
||||
input=question,
|
||||
stream=True
|
||||
|
||||
@@ -35,7 +35,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.1,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class PersonalTravelAssistant:
|
||||
|
||||
# Generate response using Responses API
|
||||
response = self.client.responses.create(
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
input=prompt
|
||||
)
|
||||
|
||||
@@ -140,9 +140,9 @@ class PersonalTravelAssistant:
|
||||
prompt = f"User input: {question}\n Previous memories: {previous_memories}"
|
||||
self.messages.append({"role": "user", "content": prompt})
|
||||
|
||||
# Generate response using GPT-4o
|
||||
# Generate response using gpt-4.1-nano
|
||||
response = self.client.chat.completions.create(
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14"2025-04-14",
|
||||
messages=self.messages
|
||||
)
|
||||
answer = response.choices[0].message.content
|
||||
|
||||
@@ -49,7 +49,7 @@ local_config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.1,
|
||||
"max_tokens": 2000,
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ from agno.tools.mem0 import Mem0Tools
|
||||
|
||||
agent = Agent(
|
||||
name="Memory Agent",
|
||||
model=OpenAIChat(id="gpt-4o-mini"),
|
||||
model=OpenAIChat(id="gpt-4.1-nano-2025-04-14"2025-04-14"),
|
||||
tools=[Mem0Tools()],
|
||||
description="An assistant that remembers and personalizes using Mem0 memory."
|
||||
)
|
||||
|
||||
@@ -55,7 +55,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.0,
|
||||
"api_key": keywordsai_api_key,
|
||||
"openai_base_url": base_url,
|
||||
@@ -101,7 +101,7 @@ messages = [
|
||||
|
||||
# Add memory and generate a response
|
||||
response = client.chat.completions.create(
|
||||
model="openai/gpt-4o",
|
||||
model="openai/gpt-4.1-nano",
|
||||
messages=messages,
|
||||
extra_body={
|
||||
"mem0_params": {
|
||||
|
||||
@@ -39,7 +39,7 @@ load_dotenv()
|
||||
# os.environ["MEM0_API_KEY"] = "your-mem0-api-key"
|
||||
|
||||
# Initialize LangChain and Mem0
|
||||
llm = ChatOpenAI(model="gpt-4o-mini")
|
||||
llm = ChatOpenAI(model="gpt-4.1-nano-2025-04-14")
|
||||
mem0 = MemoryClient()
|
||||
```
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ async def entrypoint(ctx: JobContext):
|
||||
|
||||
session = AgentSession(
|
||||
stt=deepgram.STT(),
|
||||
llm=openai.LLM(model="gpt-4o-mini"),
|
||||
llm=openai.LLM(model="gpt-4.1-nano-2025-04-14"2025-04-14"),
|
||||
tts=openai.TTS(voice="ash",),
|
||||
turn_detection=EnglishModel(),
|
||||
vad=silero.VAD.load(),
|
||||
|
||||
@@ -83,7 +83,7 @@ config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
},
|
||||
@@ -116,7 +116,7 @@ from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
# os.environ["OPENAI_API_KEY"] = "<your-openai-api-key>"
|
||||
llm = OpenAI(model="gpt-4o-mini")
|
||||
llm = OpenAI(model="gpt-4.1-nano-2025-04-14"2025-04-14")
|
||||
```
|
||||
|
||||
### SimpleChatEngine
|
||||
|
||||
@@ -106,7 +106,7 @@ const mem0Agent = new Agent({
|
||||
Use the Mem0-memorize tool to save important information that might be useful later.
|
||||
Use the Mem0-remember tool to recall previously saved information when answering questions.
|
||||
`,
|
||||
model: openai('gpt-4o'),
|
||||
model: openai('gpt-4.1-nano'),
|
||||
tools: { mem0RememberTool, mem0MemorizeTool },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -63,7 +63,7 @@ agent = Agent(
|
||||
Use the save_memory tool to store important information about the user.
|
||||
Always personalize your responses based on available memory.""",
|
||||
tools=[search_memory, save_memory],
|
||||
model="gpt-4o"
|
||||
model="gpt-4.1-nano-2025-04-14"
|
||||
)
|
||||
|
||||
def chat_with_agent(user_input: str, user_id: str) -> str:
|
||||
@@ -114,7 +114,7 @@ travel_agent = Agent(
|
||||
understand the user's travel preferences and history before making recommendations.
|
||||
After providing your response, use store_conversation to save important details.""",
|
||||
tools=[search_memory, save_memory],
|
||||
model="gpt-4o"
|
||||
model="gpt-4.1-nano-2025-04-14"
|
||||
)
|
||||
|
||||
health_agent = Agent(
|
||||
@@ -123,7 +123,7 @@ health_agent = Agent(
|
||||
understand the user's health goals and dietary preferences.
|
||||
After providing advice, use store_conversation to save relevant information.""",
|
||||
tools=[search_memory, save_memory],
|
||||
model="gpt-4o"
|
||||
model="gpt-4.1-nano-2025-04-14"
|
||||
)
|
||||
|
||||
# Triage agent with handoffs
|
||||
@@ -134,7 +134,7 @@ triage_agent = Agent(
|
||||
For health-related questions (fitness, diet, wellness, exercise), hand off to Health Advisor.
|
||||
For general questions, you can handle them directly using available tools.""",
|
||||
handoffs=[travel_agent, health_agent],
|
||||
model="gpt-4o"
|
||||
model="gpt-4.1-nano-2025-04-14"
|
||||
)
|
||||
|
||||
def chat_with_handoffs(user_input: str, user_id: str) -> str:
|
||||
|
||||
@@ -504,7 +504,7 @@ chat_completion = client.chat.completions.create(
|
||||
"content": "What's the capital of France?",
|
||||
}
|
||||
],
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -239,7 +239,7 @@
|
||||
" # Generate Assistant response\n",
|
||||
" system_prompt = f\"You are a helpful AI. Answer the question based on query and memories.\\nUser Memories:\\n{memories_str}\"\n",
|
||||
" messages = [{\"role\": \"system\", \"content\": system_prompt}, {\"role\": \"user\", \"content\": message}]\n",
|
||||
" response = openai_client.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
|
||||
" response = openai_client.chat.completions.create(model=\"gpt-4.1-nano-2025-04-14\", messages=messages)\n",
|
||||
" assistant_response = response.choices[0].message.content\n",
|
||||
"\n",
|
||||
" # Create new memories from the conversation\n",
|
||||
|
||||
@@ -37,7 +37,7 @@ food_agent = Agent(
|
||||
name="Personal Food Assistant",
|
||||
description="Provides personalized food recommendations with memory and generates voice responses using Cartesia TTS tools.",
|
||||
instructions=agent_instructions,
|
||||
model=OpenAIChat(id="gpt-4o"),
|
||||
model=OpenAIChat(id="gpt-4.1-nano-2025-04-14"),
|
||||
tools=[CartesiaTools(voice_localize_enabled=True)],
|
||||
show_tool_calls=True,
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""
|
||||
Simple Fitness Memory Tracker that tracks your fitness progress and knows your health priorities.
|
||||
Uses Mem0 for memory and GPT-4o for image understanding.
|
||||
Uses Mem0 for memory and gpt-4.1-nano for image understanding.
|
||||
|
||||
In order to run this file, you need to set up your Mem0 API at Mem0 platform and also need an OpenAI API key.
|
||||
export OPENAI_API_KEY="your_openai_api_key"
|
||||
@@ -18,7 +18,7 @@ USER_ID = "Anish"
|
||||
|
||||
agent = Agent(
|
||||
name="Fitness Agent",
|
||||
model=OpenAIChat(id="gpt-4o"),
|
||||
model=OpenAIChat(id="gpt-4.1-nano-2025-04-14"),
|
||||
description="You are a helpful fitness assistant who remembers past logs and gives personalized suggestions for Anish's training and diet.",
|
||||
markdown=True,
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ memory = MemoryClient()
|
||||
# Research team models with specialized roles
|
||||
RESEARCH_TEAM = {
|
||||
"tech_analyst": {
|
||||
"model": "gpt-4o",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"role": "Technical Analyst - Code review, architecture, and technical decisions",
|
||||
},
|
||||
"writer": {
|
||||
@@ -42,7 +42,7 @@ RESEARCH_TEAM = {
|
||||
"role": "Documentation Writer - Clear explanations and user guides",
|
||||
},
|
||||
"data_analyst": {
|
||||
"model": "gpt-4o-mini",
|
||||
"model": "gpt-4.1-nano-2025-04-14",
|
||||
"role": "Data Analyst - Insights, trends, and data-driven recommendations",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ client = MemoryClient()
|
||||
# Define the agent
|
||||
agent = Agent(
|
||||
name="Personal Agent",
|
||||
model=OpenAIChat(id="gpt-4o"),
|
||||
model=OpenAIChat(id="gpt-4.1-nano-2025-04-14"),
|
||||
description="You are a helpful personal agent that helps me with day to day activities."
|
||||
"You can process both text and images.",
|
||||
markdown=True,
|
||||
|
||||
@@ -35,7 +35,7 @@ BE IT TIME, LOCATION, USER'S PERSONAL LIFE, CHOICES, USER'S PREFERENCES, we need
|
||||
'''
|
||||
)
|
||||
|
||||
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0.2)
|
||||
llm = ChatOpenAI(model="gpt-4.1-nano-2025-04-14", temperature=0.2)
|
||||
|
||||
|
||||
def setup_user_history(user_id):
|
||||
|
||||
@@ -35,7 +35,7 @@ travel_agent = Agent(
|
||||
understand the user's travel preferences and history before making recommendations.
|
||||
After providing your response, use store_conversation to save important details.""",
|
||||
tools=[search_memory, save_memory],
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
)
|
||||
|
||||
health_agent = Agent(
|
||||
@@ -44,7 +44,7 @@ health_agent = Agent(
|
||||
understand the user's health goals and dietary preferences.
|
||||
After providing advice, use store_conversation to save relevant information.""",
|
||||
tools=[search_memory, save_memory],
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
)
|
||||
|
||||
# Triage agent with handoffs
|
||||
@@ -55,7 +55,7 @@ triage_agent = Agent(
|
||||
For health-related questions (fitness, diet, wellness, exercise), hand off to Health Advisor.
|
||||
For general questions, you can handle them directly using available tools.""",
|
||||
handoffs=[travel_agent, health_agent],
|
||||
model="gpt-4o",
|
||||
model="gpt-4.1-nano-2025-04-14",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class MultiAgentLearningSystem:
|
||||
|
||||
def __init__(self, student_id: str):
|
||||
self.student_id = student_id
|
||||
self.llm = OpenAI(model="gpt-4o", temperature=0.2)
|
||||
self.llm = OpenAI(model="gpt-4.1-nano-2025-04-14", temperature=0.2)
|
||||
|
||||
# Memory context for this student
|
||||
self.memory_context = {"user_id": student_id, "app": "learning_assistant"}
|
||||
|
||||
@@ -172,7 +172,7 @@ export const useChat = ({ user, mem0ApiKey, openaiApiKey }: UseChatProps): UseCh
|
||||
}
|
||||
|
||||
const completion = await openai.chat.completions.create({
|
||||
model: "gpt-4o-mini",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
messages: messagesForLLM.map(msg => ({
|
||||
|
||||
@@ -172,7 +172,7 @@ export const useChat = ({ user, mem0ApiKey, openaiApiKey }: UseChatProps): UseCh
|
||||
}
|
||||
|
||||
const completion = await openai.chat.completions.create({
|
||||
model: "gpt-4o-mini",
|
||||
model: "gpt-4.1-nano-2025-04-14",
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
messages: messagesForLLM.map(msg => ({
|
||||
|
||||
@@ -11,7 +11,7 @@ export class OpenAILLM implements LLM {
|
||||
apiKey: config.apiKey,
|
||||
baseURL: config.baseURL,
|
||||
});
|
||||
this.model = config.model || "gpt-4o-mini";
|
||||
this.model = config.model || "gpt-4.1-nano-2025-04-14";
|
||||
}
|
||||
|
||||
async generateResponse(
|
||||
|
||||
@@ -29,7 +29,7 @@ class BaseLlmConfig(ABC):
|
||||
Initialize a base configuration class instance for the LLM.
|
||||
|
||||
Args:
|
||||
model: The model identifier to use (e.g., "gpt-4o-mini", "claude-3-5-sonnet-20240620")
|
||||
model: The model identifier to use (e.g., "gpt-4.1-nano-2025-04-14", "claude-3-5-sonnet-20240620")
|
||||
Defaults to None (will be set by provider-specific configs)
|
||||
temperature: Controls the randomness of the model's output.
|
||||
Higher values (closer to 1) make output more random, lower values make it more deterministic.
|
||||
|
||||
@@ -38,7 +38,7 @@ class AzureOpenAILLM(LLMBase):
|
||||
|
||||
# Model name should match the custom deployment name chosen for it.
|
||||
if not self.config.model:
|
||||
self.config.model = "gpt-4o"
|
||||
self.config.model = "gpt-4.1-nano-2025-04-14"
|
||||
|
||||
api_key = self.config.azure_kwargs.api_key or os.getenv("LLM_AZURE_OPENAI_API_KEY")
|
||||
azure_deployment = self.config.azure_kwargs.azure_deployment or os.getenv("LLM_AZURE_DEPLOYMENT")
|
||||
|
||||
@@ -16,7 +16,7 @@ class AzureOpenAIStructuredLLM(LLMBase):
|
||||
|
||||
# Model name should match the custom deployment name chosen for it.
|
||||
if not self.config.model:
|
||||
self.config.model = "gpt-4o-2024-08-06"
|
||||
self.config.model = "gpt-4.1-nano-2025-04-14"
|
||||
|
||||
api_key = self.config.azure_kwargs.api_key or os.getenv("LLM_AZURE_OPENAI_API_KEY")
|
||||
azure_deployment = self.config.azure_kwargs.azure_deployment or os.getenv("LLM_AZURE_DEPLOYMENT")
|
||||
|
||||
@@ -16,7 +16,7 @@ class LiteLLM(LLMBase):
|
||||
super().__init__(config)
|
||||
|
||||
if not self.config.model:
|
||||
self.config.model = "gpt-4o-mini"
|
||||
self.config.model = "gpt-4.1-nano-2025-04-14"
|
||||
|
||||
def _parse_response(self, response, tools):
|
||||
"""
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class OpenAILLM(LLMBase):
|
||||
super().__init__(config)
|
||||
|
||||
if not self.config.model:
|
||||
self.config.model = "gpt-4o-mini"
|
||||
self.config.model = "gpt-4.1-nano-2025-04-14"
|
||||
|
||||
if os.environ.get("OPENROUTER_API_KEY"): # Use OpenRouter
|
||||
self.client = OpenAI(
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ DEFAULT_CONFIG = {
|
||||
"provider": "neo4j",
|
||||
"config": {"url": NEO4J_URI, "username": NEO4J_USERNAME, "password": NEO4J_PASSWORD},
|
||||
},
|
||||
"llm": {"provider": "openai", "config": {"api_key": OPENAI_API_KEY, "temperature": 0.2, "model": "gpt-4o"}},
|
||||
"llm": {"provider": "openai", "config": {"api_key": OPENAI_API_KEY, "temperature": 0.2, "model": "gpt-4.1-nano-2025-04-14"}},
|
||||
"embedder": {"provider": "openai", "config": {"api_key": OPENAI_API_KEY, "model": "text-embedding-3-small"}},
|
||||
"history_db_path": HISTORY_DB_PATH,
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import pytest
|
||||
from mem0.configs.llms.azure import AzureOpenAIConfig
|
||||
from mem0.llms.azure_openai import AzureOpenAILLM
|
||||
|
||||
MODEL = "gpt-4o" # or your custom deployment name
|
||||
MODEL = "gpt-4.1-nano-2025-04-14" # or your custom deployment name
|
||||
TEMPERATURE = 0.7
|
||||
MAX_TOKENS = 100
|
||||
TOP_P = 1.0
|
||||
@@ -191,8 +191,8 @@ def test_init_with_env_vars(monkeypatch):
|
||||
http_client=None,
|
||||
default_headers=None,
|
||||
)
|
||||
# Should default to "gpt-4o" if model is None
|
||||
assert llm.config.model == "gpt-4o"
|
||||
# Should default to "gpt-4.1-nano-2025-04-14" if model is None
|
||||
assert llm.config.model == "gpt-4.1-nano-2025-04-14"
|
||||
|
||||
|
||||
def test_init_with_default_azure_credential(monkeypatch):
|
||||
|
||||
@@ -56,7 +56,7 @@ def test_init_with_default_credential(mock_credential, mock_token_provider, mock
|
||||
mock_token_provider.return_value = "token-provider"
|
||||
llm = AzureOpenAIStructuredLLM(config)
|
||||
# Should set default model if not provided
|
||||
assert llm.config.model == "gpt-4o-2024-08-06"
|
||||
assert llm.config.model == "gpt-4.1-nano-2025-04-14"
|
||||
mock_credential.assert_called_once()
|
||||
mock_token_provider.assert_called_once_with(mock_credential.return_value, SCOPE)
|
||||
mock_azure_openai.assert_called_once()
|
||||
@@ -91,7 +91,7 @@ def test_init_with_placeholder_api_key_uses_default_credential(
|
||||
config = DummyConfig(model=None, azure_kwargs=DummyAzureKwargs(api_key="your-api-key"))
|
||||
mock_token_provider.return_value = "token-provider"
|
||||
llm = AzureOpenAIStructuredLLM(config)
|
||||
assert llm.config.model == "gpt-4o-2024-08-06"
|
||||
assert llm.config.model == "gpt-4.1-nano-2025-04-14"
|
||||
mock_credential.assert_called_once()
|
||||
mock_token_provider.assert_called_once_with(mock_credential.return_value, SCOPE)
|
||||
mock_azure_openai.assert_called_once()
|
||||
|
||||
@@ -24,7 +24,7 @@ def test_generate_response_with_unsupported_model(mock_litellm):
|
||||
|
||||
|
||||
def test_generate_response_without_tools(mock_litellm):
|
||||
config = BaseLlmConfig(model="gpt-4o", temperature=0.7, max_tokens=100, top_p=1)
|
||||
config = BaseLlmConfig(model="gpt-4.1-nano-2025-04-14", temperature=0.7, max_tokens=100, top_p=1)
|
||||
llm = litellm.LiteLLM(config)
|
||||
messages = [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
@@ -39,13 +39,13 @@ def test_generate_response_without_tools(mock_litellm):
|
||||
response = llm.generate_response(messages)
|
||||
|
||||
mock_litellm.completion.assert_called_once_with(
|
||||
model="gpt-4o", messages=messages, temperature=0.7, max_tokens=100, top_p=1.0
|
||||
model="gpt-4.1-nano-2025-04-14", messages=messages, temperature=0.7, max_tokens=100, top_p=1.0
|
||||
)
|
||||
assert response == "I'm doing well, thank you for asking!"
|
||||
|
||||
|
||||
def test_generate_response_with_tools(mock_litellm):
|
||||
config = BaseLlmConfig(model="gpt-4o", temperature=0.7, max_tokens=100, top_p=1)
|
||||
config = BaseLlmConfig(model="gpt-4.1-nano-2025-04-14", temperature=0.7, max_tokens=100, top_p=1)
|
||||
llm = litellm.LiteLLM(config)
|
||||
messages = [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
@@ -82,7 +82,7 @@ def test_generate_response_with_tools(mock_litellm):
|
||||
response = llm.generate_response(messages, tools=tools)
|
||||
|
||||
mock_litellm.completion.assert_called_once_with(
|
||||
model="gpt-4o", messages=messages, temperature=0.7, max_tokens=100, top_p=1, tools=tools, tool_choice="auto"
|
||||
model="gpt-4.1-nano-2025-04-14", messages=messages, temperature=0.7, max_tokens=100, top_p=1, tools=tools, tool_choice="auto"
|
||||
)
|
||||
|
||||
assert response["content"] == "I've added the memory for you."
|
||||
|
||||
+11
-11
@@ -17,7 +17,7 @@ def mock_openai_client():
|
||||
|
||||
def test_openai_llm_base_url():
|
||||
# case1: default config: with openai official base url
|
||||
config = OpenAIConfig(model="gpt-4o", temperature=0.7, max_tokens=100, top_p=1.0, api_key="api_key")
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14", temperature=0.7, max_tokens=100, top_p=1.0, api_key="api_key")
|
||||
llm = OpenAILLM(config)
|
||||
# Note: openai client will parse the raw base_url into a URL object, which will have a trailing slash
|
||||
assert str(llm.client.base_url) == "https://api.openai.com/v1/"
|
||||
@@ -25,7 +25,7 @@ def test_openai_llm_base_url():
|
||||
# case2: with env variable OPENAI_API_BASE
|
||||
provider_base_url = "https://api.provider.com/v1"
|
||||
os.environ["OPENAI_BASE_URL"] = provider_base_url
|
||||
config = OpenAIConfig(model="gpt-4o", temperature=0.7, max_tokens=100, top_p=1.0, api_key="api_key")
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14", temperature=0.7, max_tokens=100, top_p=1.0, api_key="api_key")
|
||||
llm = OpenAILLM(config)
|
||||
# Note: openai client will parse the raw base_url into a URL object, which will have a trailing slash
|
||||
assert str(llm.client.base_url) == provider_base_url + "/"
|
||||
@@ -33,7 +33,7 @@ def test_openai_llm_base_url():
|
||||
# case3: with config.openai_base_url
|
||||
config_base_url = "https://api.config.com/v1"
|
||||
config = OpenAIConfig(
|
||||
model="gpt-4o", temperature=0.7, max_tokens=100, top_p=1.0, api_key="api_key", openai_base_url=config_base_url
|
||||
model="gpt-4.1-nano-2025-04-14", temperature=0.7, max_tokens=100, top_p=1.0, api_key="api_key", openai_base_url=config_base_url
|
||||
)
|
||||
llm = OpenAILLM(config)
|
||||
# Note: openai client will parse the raw base_url into a URL object, which will have a trailing slash
|
||||
@@ -41,7 +41,7 @@ def test_openai_llm_base_url():
|
||||
|
||||
|
||||
def test_generate_response_without_tools(mock_openai_client):
|
||||
config = OpenAIConfig(model="gpt-4o", temperature=0.7, max_tokens=100, top_p=1.0)
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14", temperature=0.7, max_tokens=100, top_p=1.0)
|
||||
llm = OpenAILLM(config)
|
||||
messages = [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
@@ -55,13 +55,13 @@ def test_generate_response_without_tools(mock_openai_client):
|
||||
response = llm.generate_response(messages)
|
||||
|
||||
mock_openai_client.chat.completions.create.assert_called_once_with(
|
||||
model="gpt-4o", messages=messages, temperature=0.7, max_tokens=100, top_p=1.0, store=False
|
||||
model="gpt-4.1-nano-2025-04-14", messages=messages, temperature=0.7, max_tokens=100, top_p=1.0, store=False
|
||||
)
|
||||
assert response == "I'm doing well, thank you for asking!"
|
||||
|
||||
|
||||
def test_generate_response_with_tools(mock_openai_client):
|
||||
config = OpenAIConfig(model="gpt-4o", temperature=0.7, max_tokens=100, top_p=1.0)
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14", temperature=0.7, max_tokens=100, top_p=1.0)
|
||||
llm = OpenAILLM(config)
|
||||
messages = [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
@@ -97,7 +97,7 @@ def test_generate_response_with_tools(mock_openai_client):
|
||||
response = llm.generate_response(messages, tools=tools)
|
||||
|
||||
mock_openai_client.chat.completions.create.assert_called_once_with(
|
||||
model="gpt-4o", messages=messages, temperature=0.7, max_tokens=100, top_p=1.0, tools=tools, tool_choice="auto", store=False
|
||||
model="gpt-4.1-nano-2025-04-14", messages=messages, temperature=0.7, max_tokens=100, top_p=1.0, tools=tools, tool_choice="auto", store=False
|
||||
)
|
||||
|
||||
assert response["content"] == "I've added the memory for you."
|
||||
@@ -110,7 +110,7 @@ def test_response_callback_invocation(mock_openai_client):
|
||||
# Setup mock callback
|
||||
mock_callback = Mock()
|
||||
|
||||
config = OpenAIConfig(model="gpt-4o", response_callback=mock_callback)
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14", response_callback=mock_callback)
|
||||
llm = OpenAILLM(config)
|
||||
messages = [{"role": "user", "content": "Test callback"}]
|
||||
|
||||
@@ -131,7 +131,7 @@ def test_response_callback_invocation(mock_openai_client):
|
||||
|
||||
|
||||
def test_no_response_callback(mock_openai_client):
|
||||
config = OpenAIConfig(model="gpt-4o")
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14")
|
||||
llm = OpenAILLM(config)
|
||||
messages = [{"role": "user", "content": "Test no callback"}]
|
||||
|
||||
@@ -153,7 +153,7 @@ def test_callback_exception_handling(mock_openai_client):
|
||||
def faulty_callback(*args):
|
||||
raise ValueError("Callback error")
|
||||
|
||||
config = OpenAIConfig(model="gpt-4o", response_callback=faulty_callback)
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14", response_callback=faulty_callback)
|
||||
llm = OpenAILLM(config)
|
||||
messages = [{"role": "user", "content": "Test exception"}]
|
||||
|
||||
@@ -172,7 +172,7 @@ def test_callback_exception_handling(mock_openai_client):
|
||||
|
||||
def test_callback_with_tools(mock_openai_client):
|
||||
mock_callback = Mock()
|
||||
config = OpenAIConfig(model="gpt-4o", response_callback=mock_callback)
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14", response_callback=mock_callback)
|
||||
llm = OpenAILLM(config)
|
||||
messages = [{"role": "user", "content": "Test tools"}]
|
||||
tools = [
|
||||
|
||||
+3
-3
@@ -68,14 +68,14 @@ def test_completions_create(mock_memory_client, mock_litellm):
|
||||
mock_litellm.completion.return_value = {"choices": [{"message": {"content": "I'm doing well, thank you!"}}]}
|
||||
mock_litellm.supports_function_calling.return_value = True
|
||||
|
||||
response = completions.create(model="gpt-4o-mini", messages=messages, user_id="test_user", temperature=0.7)
|
||||
response = completions.create(model="gpt-4.1-nano-2025-04-14", messages=messages, user_id="test_user", temperature=0.7)
|
||||
|
||||
mock_memory_client.add.assert_called_once()
|
||||
mock_memory_client.search.assert_called_once()
|
||||
|
||||
mock_litellm.completion.assert_called_once()
|
||||
call_args = mock_litellm.completion.call_args[1]
|
||||
assert call_args["model"] == "gpt-4o-mini"
|
||||
assert call_args["model"] == "gpt-4.1-nano-2025-04-14"
|
||||
assert len(call_args["messages"]) == 2
|
||||
assert call_args["temperature"] == 0.7
|
||||
|
||||
@@ -93,7 +93,7 @@ def test_completions_create_with_system_message(mock_memory_client, mock_litellm
|
||||
mock_litellm.completion.return_value = {"choices": [{"message": {"content": "I'm doing well, thank you!"}}]}
|
||||
mock_litellm.supports_function_calling.return_value = True
|
||||
|
||||
completions.create(model="gpt-4o-mini", messages=messages, user_id="test_user")
|
||||
completions.create(model="gpt-4.1-nano-2025-04-14", messages=messages, user_id="test_user")
|
||||
|
||||
call_args = mock_litellm.completion.call_args[1]
|
||||
assert call_args["messages"][0]["role"] == "system"
|
||||
|
||||
Reference in New Issue
Block a user