Skip to content

Commit 7239840

Browse files
committed
ci: update langchain version
1 parent 18e4647 commit 7239840

File tree

8 files changed

+32
-26
lines changed

8 files changed

+32
-26
lines changed

apps/setting/models_provider/base_model_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from functools import reduce
1212
from typing import Dict, Iterator, Type, List
1313

14-
from pydantic.v1 import BaseModel
14+
from pydantic import BaseModel
1515

1616
from common.exception.app_exception import AppApiException
1717
from django.utils.translation import gettext_lazy as _

apps/setting/models_provider/impl/base_chat_open_ai.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from langchain_core.runnables import RunnableConfig, ensure_config
1111
from langchain_core.utils.pydantic import is_basemodel_subclass
1212
from langchain_openai import ChatOpenAI
13-
from langchain_openai.chat_models.base import _convert_chunk_to_generation_chunk
1413

1514
from common.config.tokenizer_manage_config import TokenizerManage
1615

@@ -98,7 +97,7 @@ def _stream(
9897
if not isinstance(chunk, dict):
9998
chunk = chunk.model_dump()
10099

101-
generation_chunk = _convert_chunk_to_generation_chunk(
100+
generation_chunk = super()._convert_chunk_to_generation_chunk(
102101
chunk,
103102
default_chunk_class,
104103
base_generation_info if is_first_chunk else {},

apps/setting/models_provider/impl/gemini_model_provider/model/llm.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
from typing import List, Dict, Optional, Sequence, Union, Any, Iterator, cast
1010

1111
from google.ai.generativelanguage_v1 import GenerateContentResponse
12-
from google.generativeai.responder import ToolDict
13-
from google.generativeai.types import FunctionDeclarationType, SafetySettingDict
14-
from google.generativeai.types import Tool as GoogleTool
12+
from google.ai.generativelanguage_v1beta.types import (
13+
Tool as GoogleTool,
14+
)
1515
from langchain_core.callbacks import CallbackManagerForLLMRun
1616
from langchain_core.messages import BaseMessage
1717
from langchain_core.outputs import ChatGenerationChunk
1818
from langchain_google_genai import ChatGoogleGenerativeAI
19-
from langchain_google_genai._function_utils import _ToolConfigDict
20-
from langchain_google_genai.chat_models import _chat_with_retry, _response_to_result
21-
19+
from langchain_google_genai._function_utils import _ToolConfigDict, _ToolDict
20+
from langchain_google_genai.chat_models import _chat_with_retry, _response_to_result, \
21+
_FunctionDeclarationType
22+
from langchain_google_genai._common import (
23+
SafetySettingDict,
24+
)
2225
from setting.models_provider.base_model_provider import MaxKBBaseModel
2326

2427

@@ -54,8 +57,8 @@ def _stream(
5457
stop: Optional[List[str]] = None,
5558
run_manager: Optional[CallbackManagerForLLMRun] = None,
5659
*,
57-
tools: Optional[Sequence[Union[ToolDict, GoogleTool]]] = None,
58-
functions: Optional[Sequence[FunctionDeclarationType]] = None,
60+
tools: Optional[Sequence[Union[_ToolDict, GoogleTool]]] = None,
61+
functions: Optional[Sequence[_FunctionDeclarationType]] = None,
5962
safety_settings: Optional[SafetySettingDict] = None,
6063
tool_config: Optional[Union[Dict, _ToolConfigDict]] = None,
6164
generation_config: Optional[Dict[str, Any]] = None,

apps/setting/models_provider/impl/local_model_provider/model/embedding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import requests
1212
from langchain_core.embeddings import Embeddings
13-
from langchain_core.pydantic_v1 import BaseModel
13+
from pydantic import BaseModel
1414
from langchain_huggingface import HuggingFaceEmbeddings
1515

1616
from setting.models_provider.base_model_provider import MaxKBBaseModel

apps/setting/models_provider/impl/local_model_provider/model/reranker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@date:2024/9/2 16:42
77
@desc:
88
"""
9-
from typing import Sequence, Optional, Dict, Any
9+
from typing import Sequence, Optional, Dict, Any, ClassVar
1010

1111
import requests
1212
import torch
@@ -69,7 +69,7 @@ class LocalBaseReranker(MaxKBBaseModel, BaseDocumentCompressor):
6969
tokenizer: Any = None
7070
model: Optional[str] = None
7171
cache_dir: Optional[str] = None
72-
model_kwargs = {}
72+
model_kwargs: ClassVar = {}
7373

7474
def __init__(self, model_name, cache_dir=None, **model_kwargs):
7575
super().__init__()

apps/setting/models_provider/impl/ollama_model_provider/model/reranker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from typing import Sequence, Optional, Any, Dict
2+
3+
from langchain_community.embeddings import OllamaEmbeddings
24
from langchain_core.callbacks import Callbacks
35
from langchain_core.documents import Document
4-
from langchain_community.embeddings import OllamaEmbeddings
56
from setting.models_provider.base_model_provider import MaxKBBaseModel
67
from sklearn.metrics.pairwise import cosine_similarity
7-
from pydantic.v1 import BaseModel, Field
8+
from pydantic import BaseModel, Field
89

910

1011
class OllamaReranker(MaxKBBaseModel, OllamaEmbeddings, BaseModel):

apps/setting/models_provider/impl/tencent_model_provider/model/hunyuan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
HumanMessageChunk, SystemMessage,
1919
)
2020
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult
21-
from langchain_core.pydantic_v1 import Field, SecretStr, root_validator
21+
from pydantic import Field, SecretStr, root_validator
2222
from langchain_core.utils import (
2323
convert_to_secret_str,
2424
get_from_dict_or_env,
@@ -137,7 +137,7 @@ def lc_serializable(self) -> bool:
137137
class Config:
138138
"""Configuration for this pydantic object."""
139139

140-
allow_population_by_field_name = True
140+
validate_by_name = True
141141

142142
@root_validator(pre=True)
143143
def build_extra(cls, values: Dict[str, Any]) -> Dict[str, Any]:

pyproject.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ django = "4.2.18"
1212
djangorestframework = "^3.15.2"
1313
drf-yasg = "1.21.7"
1414
django-filter = "23.2"
15-
langchain = "0.2.16"
16-
langchain_community = "0.2.17"
17-
langchain-huggingface = "^0.0.3"
15+
langchain-openai = "^0.3.0"
16+
langchain-anthropic = "^0.3.0"
17+
langchain-community = "^0.3.0"
18+
langchain-deepseek = "^0.1.0"
19+
langchain-google-genai = "^2.0.9"
20+
langchain-mcp-adapters = "^0.0.5"
21+
langchain-huggingface = "^0.1.2"
22+
langchain-ollama = "^0.2.3"
23+
langgraph = "^0.3.0"
24+
mcp = "^1.4.1"
1825
psycopg2-binary = "2.9.10"
1926
jieba = "^0.42.1"
2027
diskcache = "^5.6.3"
@@ -28,8 +35,6 @@ qianfan = "^0.3.6.1"
2835
pycryptodome = "^3.19.0"
2936
beautifulsoup4 = "^4.12.2"
3037
html2text = "^2024.2.26"
31-
langchain-openai = "^0.1.8"
32-
langchain-ollama = "0.1.3"
3338
django-ipware = "^6.0.4"
3439
django-apscheduler = "^0.6.2"
3540
pymupdf = "1.24.9"
@@ -42,8 +47,6 @@ zhipuai = "^2.0.1"
4247
httpx = "^0.27.0"
4348
httpx-sse = "^0.4.0"
4449
websockets = "^13.0"
45-
langchain-google-genai = "^1.0.3"
46-
langchain-anthropic= "^0.1.0"
4750
openpyxl = "^3.1.2"
4851
xlrd = "^2.0.1"
4952
gunicorn = "^22.0.0"
@@ -55,7 +58,7 @@ psutil = "^6.0.0"
5558
celery = { extras = ["sqlalchemy"], version = "^5.4.0" }
5659
django-celery-beat = "^2.6.0"
5760
celery-once = "^3.0.1"
58-
anthropic = "^0.34.2"
61+
anthropic = "^0.39.0"
5962
pylint = "3.1.0"
6063
pydub = "^0.25.1"
6164
cffi = "^1.17.1"

0 commit comments

Comments
 (0)