Skip to content

Commit 3712522

Browse files
authored
Fix langchain llm and update changelog (#2508)
1 parent 93f34e4 commit 3712522

File tree

4 files changed

+53
-17
lines changed

4 files changed

+53
-17
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ install:
1313
install_all:
1414
poetry install
1515
poetry run pip install groq together boto3 litellm ollama chromadb weaviate weaviate-client sentence_transformers vertexai \
16-
google-generativeai elasticsearch opensearch-py vecs pinecone pinecone-text faiss-cpu
16+
google-generativeai elasticsearch opensearch-py vecs pinecone pinecone-text faiss-cpu langchain-community
1717

1818
# Format code with ruff
1919
format:

docs/changelog/overview.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ mode: "wide"
66
<Tabs>
77
<Tab title="Python">
88

9+
<Update label="2025-04-07" description="v0.1.82">
10+
11+
**New Features:**
12+
- **LLM Integrations:** Added support for Langchain LLMs, Google as new LLM and embedder
13+
- **Development:** Added development docker compose
14+
15+
**Improvements:**
16+
- **Output Format:** Set output_format='v1.1' and updated documentation
17+
18+
**Documentation:**
19+
- **Integrations:** Added LMStudio and Together.ai documentation
20+
- **API Reference:** Updated output_format documentation
21+
- **Integrations:** Added PipeCat integration documentation
22+
- **Integrations:** Added Flowise integration documentation for Mem0 memory setup
23+
24+
**Bug Fixes:**
25+
- **Tests:** Fixed failing unit tests
26+
</Update>
27+
928
<Update label="2025-04-02" description="v0.1.79">
1029

1130
**New Features:**
@@ -56,6 +75,17 @@ mode: "wide"
5675

5776
<Tab title="TypeScript">
5877

78+
<Update label="2025-04-01" description="v2.1.14">
79+
**New Features:**
80+
- **Mastra Example:** Added Mastra example
81+
- **Integrations:** Added Flowise integration documentation for Mem0 memory setup
82+
83+
**Improvements:**
84+
- **Demo:** Updated Demo Mem0AI
85+
- **Client:** Enhanced Ping method in Mem0 Client
86+
- **AI SDK:** Updated AI SDK implementation
87+
</Update>
88+
5989
<Update label="2025-03-29" description="v2.1.13">
6090
**Improvements:**
6191
- **Introuced `ping` method to check if API key is valid and populate org/project id**

mem0/llms/langchain.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# Provider-specific package mapping
1414
PROVIDER_PACKAGES = {
15-
# "Anthropic": "langchain_anthropic", # Special handling for Anthropic with Pydantic v2
15+
"Anthropic": "langchain_anthropic",
1616
"MistralAI": "langchain_mistralai",
1717
"Fireworks": "langchain_fireworks",
1818
"AzureOpenAI": "langchain_openai",
@@ -135,18 +135,25 @@ def __init__(self, config: Optional[BaseLlmConfig] = None):
135135
try:
136136
# Check if this provider needs a specialized package
137137
if provider in PROVIDER_PACKAGES:
138-
package_name = PROVIDER_PACKAGES[provider]
139-
try:
140-
# Import the model class directly from the package
141-
module_path = f"{package_name}"
142-
model_class = __import__(module_path, fromlist=[model_name])
143-
model_class = getattr(model_class, model_name)
144-
except ImportError:
145-
raise ImportError(
146-
f"Package {package_name} not found. " f"Please install it with `pip install {package_name}`"
147-
)
148-
except AttributeError:
149-
raise ImportError(f"Model {model_name} not found in {package_name}")
138+
if provider == "Anthropic": # Special handling for Anthropic with Pydantic v2
139+
try:
140+
from langchain_anthropic import ChatAnthropic
141+
model_class = ChatAnthropic
142+
except ImportError:
143+
raise ImportError("langchain_anthropic not found. Please install it with `pip install langchain-anthropic`")
144+
else:
145+
package_name = PROVIDER_PACKAGES[provider]
146+
try:
147+
# Import the model class directly from the package
148+
module_path = f"{package_name}"
149+
model_class = __import__(module_path, fromlist=[model_name])
150+
model_class = getattr(model_class, model_name)
151+
except ImportError:
152+
raise ImportError(
153+
f"Package {package_name} not found. " f"Please install it with `pip install {package_name}`"
154+
)
155+
except AttributeError:
156+
raise ImportError(f"Model {model_name} not found in {package_name}")
150157
else:
151158
# Use the default langchain_community module
152159
if not hasattr(chat_models, model_name):
@@ -158,8 +165,7 @@ def __init__(self, config: Optional[BaseLlmConfig] = None):
158165
self.langchain_model = model_class(
159166
model=self.config.model,
160167
temperature=self.config.temperature,
161-
max_tokens=self.config.max_tokens,
162-
api_key=self.config.api_key,
168+
max_tokens=self.config.max_tokens
163169
)
164170
except (ImportError, AttributeError, ValueError) as e:
165171
raise ImportError(f"Error setting up langchain model for provider {provider}: {str(e)}")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mem0ai"
3-
version = "0.1.82"
3+
version = "0.1.83"
44
description = "Long-term memory for AI Agents"
55
authors = ["Mem0 <[email protected]>"]
66
exclude = [

0 commit comments

Comments
 (0)