-
Notifications
You must be signed in to change notification settings - Fork 44
feat: upgrade langchain to 0.3.0 and update related dependencies #811
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
Changes from all commits
3b4c403
6757a1f
11d5bf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,10 @@ | |
| from dataclasses import dataclass | ||
| from typing import List, Optional, Union, cast | ||
|
|
||
| from langchain.embeddings.cohere import CohereEmbeddings | ||
| from langchain.embeddings.fake import FakeEmbeddings | ||
| from langchain.embeddings.localai import LocalAIEmbeddings | ||
| from langchain.embeddings.openai import OpenAIEmbeddings | ||
| from langchain_cohere import CohereEmbeddings | ||
| from langchain_community.embeddings import FakeEmbeddings, LocalAIEmbeddings | ||
| from langchain_openai import AzureOpenAIEmbeddings, OpenAIEmbeddings | ||
| from pydantic import SecretStr | ||
|
|
||
| from airbyte_cdk.destinations.vector_db_based.config import ( | ||
| AzureOpenAIEmbeddingConfigModel, | ||
|
|
@@ -118,14 +118,13 @@ class AzureOpenAIEmbedder(BaseOpenAIEmbedder): | |
| def __init__(self, config: AzureOpenAIEmbeddingConfigModel, chunk_size: int): | ||
| # Azure OpenAI API has — as of 20230927 — a limit of 16 documents per request | ||
| super().__init__( | ||
| OpenAIEmbeddings( # type: ignore [call-arg] | ||
| openai_api_key=config.openai_key, | ||
| AzureOpenAIEmbeddings( # type: ignore [call-arg] | ||
| api_key=SecretStr(config.openai_key), | ||
| chunk_size=16, | ||
| max_retries=15, | ||
| openai_api_type="azure", | ||
| openai_api_version="2023-05-15", | ||
| openai_api_base=config.api_base, | ||
| deployment=config.deployment, | ||
| api_version="2023-05-15", | ||
| azure_endpoint=config.api_base, | ||
| azure_deployment=config.deployment, | ||
| disallowed_special=(), | ||
|
Comment on lines
+121
to
128
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify Azure OpenAI parameter mappings with the new SDK. The parameter renames look aligned with Azure-specific naming conventions (e.g., As you noted in the PR description, testing with real Azure OpenAI credentials would help confirm the mappings are correct. 🏁 Script executed: #!/bin/bash
# Description: Check for actual usage patterns of AzureOpenAIEmbeddings in the codebase to ensure parameter names are used correctly
# Search for any other references to AzureOpenAIEmbeddings or AzureOpenAIEmbedder
rg -nP -C5 'AzureOpenAI(Embeddings|Embedder)' --type=pyLength of output: 6311 Let me verify the exact parameter names for langchain-openai 0.2.x: Let me check the actual implementation more closely and whether the Add missing The The Azure OpenAI Service embeddings operation supports text-embedding-ada-002 (Version 2), text-embedding-3-large, and text-embedding-3-small models. Wdyt about adding something like 🤖 Prompt for AI Agents |
||
| ), | ||
| chunk_size, | ||
|
|
@@ -140,7 +139,7 @@ def __init__(self, config: CohereEmbeddingConfigModel): | |
| super().__init__() | ||
| # Client is set internally | ||
| self.embeddings = CohereEmbeddings( | ||
| cohere_api_key=config.cohere_key, model="embed-english-light-v2.0" | ||
| cohere_api_key=SecretStr(config.cohere_key), model="embed-english-light-v2.0" | ||
| ) # type: ignore | ||
|
|
||
| def check(self) -> Optional[str]: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Should the Azure OpenAI API version be configurable or more recent?
The
api_versionis hardcoded to "2023-05-15", which is over 2 years old. Azure OpenAI has released newer API versions since then. This could limit access to newer features or cause compatibility issues.Consider either:
AzureOpenAIEmbeddingConfigModelWdyt about making this configurable for flexibility?
🌐 Web query:
💡 Result:
Short answer
Recommended version for langchain-openai 0.2.x
Sources
References (links shown as numbered sources above).
Update the Azure OpenAI API version to match LangChain compatibility requirements.
The
api_versionis hardcoded to "2023-05-15", but LangChain v0.2 docs recommend setting OPENAI_API_VERSION = 2023-12-01-preview for langchain-openai 0.2.x. This 7-month gap may cause compatibility issues or limit access to features.Would updating to
2023-12-01-previewwork for your use case? Additionally, consider making this configurable viaAzureOpenAIEmbeddingConfigModelfor flexibility across different deployment scenarios.🤖 Prompt for AI Agents