Skip to content

Commit 3a1b23f

Browse files
committed
fix: update imports for BaseMessage and message types from langchain_core
1 parent 1e44d00 commit 3a1b23f

File tree

10 files changed

+23
-78
lines changed

10 files changed

+23
-78
lines changed

apps/application/chat_pipeline/step/chat_step/i_chat_step.py

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

1212
from django.utils.translation import gettext_lazy as _
1313
from langchain.chat_models.base import BaseChatModel
14-
from langchain.schema import BaseMessage
14+
from langchain_core.messages import BaseMessage
1515
from rest_framework import serializers
1616

1717
from application.chat_pipeline.I_base_chat_pipeline import IBaseChatPipelineStep, ParagraphPipelineModel

apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
from django.http import StreamingHttpResponse
1717
from django.utils.translation import gettext as _
1818
from langchain.chat_models.base import BaseChatModel
19-
from langchain.schema import BaseMessage
20-
from langchain.schema.messages import HumanMessage, AIMessage
21-
from langchain_core.messages import AIMessageChunk, SystemMessage
19+
from langchain_core.messages import AIMessageChunk, SystemMessage, BaseMessage, HumanMessage, AIMessage
2220
from rest_framework import status
2321

2422
from application.chat_pipeline.I_base_chat_pipeline import ParagraphPipelineModel

apps/application/chat_pipeline/step/generate_human_message_step/i_generate_human_message_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import Type, List
1111

1212
from django.utils.translation import gettext_lazy as _
13-
from langchain.schema import BaseMessage
13+
from langchain_core.messages import BaseMessage
1414
from rest_framework import serializers
1515

1616
from application.chat_pipeline.I_base_chat_pipeline import IBaseChatPipelineStep, ParagraphPipelineModel

apps/application/chat_pipeline/step/generate_human_message_step/impl/base_generate_human_message_step.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"""
99
from typing import List, Dict
1010

11-
from langchain.schema import BaseMessage, HumanMessage
12-
from langchain_core.messages import SystemMessage
11+
from langchain_core.messages import SystemMessage, BaseMessage, HumanMessage
1312

1413
from application.chat_pipeline.I_base_chat_pipeline import ParagraphPipelineModel
1514
from application.chat_pipeline.step.generate_human_message_step.i_generate_human_message_step import \

apps/application/chat_pipeline/step/reset_problem_step/impl/base_reset_problem_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import List
1010

1111
from django.utils.translation import gettext as _
12-
from langchain.schema import HumanMessage
12+
from langchain_core.messages import HumanMessage
1313

1414
from application.chat_pipeline.step.reset_problem_step.i_reset_problem_step import IResetProblemStep
1515
from application.models import ChatRecord

apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
from django.db.models import QuerySet
1616
from django.utils.translation import gettext as _
17-
from langchain.schema import HumanMessage, SystemMessage
18-
from langchain_core.messages import BaseMessage, AIMessage
17+
from langchain_core.messages import BaseMessage, AIMessage, HumanMessage, SystemMessage
1918

2019
from application.flow.i_step_node import NodeResult, INode
2120
from application.flow.step_node.ai_chat_step_node.i_chat_node import IChatNode

apps/application/flow/step_node/intent_node/impl/base_intent_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from functools import reduce
77

88
from django.db.models import QuerySet
9-
from langchain.schema import HumanMessage, SystemMessage
9+
from langchain_core.messages import HumanMessage, SystemMessage
1010

1111
from application.flow.i_step_node import INode, NodeResult
1212
from application.flow.step_node.intent_node.i_intent_node import IIntentNode

apps/application/flow/step_node/question_node/impl/base_question_node.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
from typing import List, Dict
1313

1414
from django.db.models import QuerySet
15-
from langchain.schema import HumanMessage, SystemMessage
16-
from langchain_core.messages import BaseMessage
15+
from langchain_core.messages import BaseMessage, HumanMessage, SystemMessage
1716

1817
from application.flow.i_step_node import NodeResult, INode
1918
from application.flow.step_node.question_node.i_question_node import IQuestionNode

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

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,10 @@
66
@Author :Brian Yang
77
@Date :5/13/24 7:40 AM
88
"""
9-
from typing import List, Dict, Optional, Sequence, Union, Any, Iterator, cast
9+
from typing import List, Dict, Optional, Any
1010

11-
from google.ai.generativelanguage_v1 import GenerateContentResponse
12-
from google.ai.generativelanguage_v1beta.types import (
13-
Tool as GoogleTool,
14-
)
15-
from langchain_core.callbacks import CallbackManagerForLLMRun
1611
from langchain_core.messages import BaseMessage, get_buffer_string
17-
from langchain_core.outputs import ChatGenerationChunk
1812
from langchain_google_genai import ChatGoogleGenerativeAI
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-
)
2513

2614
from common.config.tokenizer_manage_config import TokenizerManage
2715
from models_provider.base_model_provider import MaxKBBaseModel
@@ -60,41 +48,3 @@ def get_num_tokens(self, text: str) -> int:
6048
except Exception as e:
6149
tokenizer = TokenizerManage.get_tokenizer()
6250
return len(tokenizer.encode(text))
63-
64-
def _stream(
65-
self,
66-
messages: List[BaseMessage],
67-
stop: Optional[List[str]] = None,
68-
run_manager: Optional[CallbackManagerForLLMRun] = None,
69-
*,
70-
tools: Optional[Sequence[Union[_ToolDict, GoogleTool]]] = None,
71-
functions: Optional[Sequence[_FunctionDeclarationType]] = None,
72-
safety_settings: Optional[SafetySettingDict] = None,
73-
tool_config: Optional[Union[Dict, _ToolConfigDict]] = None,
74-
generation_config: Optional[Dict[str, Any]] = None,
75-
**kwargs: Any,
76-
) -> Iterator[ChatGenerationChunk]:
77-
request = self._prepare_request(
78-
messages,
79-
stop=stop,
80-
tools=tools,
81-
functions=functions,
82-
safety_settings=safety_settings,
83-
tool_config=tool_config,
84-
generation_config=generation_config,
85-
)
86-
response: GenerateContentResponse = _chat_with_retry(
87-
request=request,
88-
generation_method=self.client.stream_generate_content,
89-
**kwargs,
90-
metadata=self.default_metadata,
91-
)
92-
for chunk in response:
93-
_chat_result = _response_to_result(chunk, stream=True)
94-
gen = cast(ChatGenerationChunk, _chat_result.generations[0])
95-
if gen.message:
96-
token_usage = gen.message.usage_metadata
97-
self.__dict__.setdefault('_last_generation_info', {}).update(token_usage)
98-
if run_manager:
99-
run_manager.on_llm_new_token(gen.text)
100-
yield gen

pyproject.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,33 @@ dependencies = [
1313
"django-mptt==0.17.0",
1414
"psycopg[binary]==3.2.9",
1515
"python-dotenv==1.1.1",
16-
"uuid-utils==0.11.0",
16+
"uuid-utils==0.14.0",
1717
"captcha==0.7.1",
1818
"pytz==2025.2",
1919
"psutil==7.0.0",
2020
"cffi==1.17.1",
2121
"beautifulsoup4==4.13.4",
2222
"jieba==0.42.1",
23-
"langchain-openai==0.3.35",
24-
"langchain-anthropic==0.3.22",
25-
"langchain-community==0.3.31",
26-
"langchain-deepseek==0.1.4",
27-
"langchain-google-genai==2.1.12",
28-
"langchain-mcp-adapters==0.1.13",
29-
"langchain-huggingface==0.3.1",
30-
"langchain-ollama==0.3.10",
31-
"langchain_core==0.3.81",
32-
"langchain-aws==0.2.28",
33-
"langgraph==0.5.3",
23+
"langchain==1.2.9",
24+
"langchain-openai==1.1.9",
25+
"langchain-anthropic==1.3.3",
26+
"langchain-community==0.4.1",
27+
"langchain-deepseek==1.0.1",
28+
"langchain-google-genai==4.2.0",
29+
"langchain-mcp-adapters==0.2.1",
30+
"langchain-huggingface==1.2.0",
31+
"langchain-ollama==1.0.1",
32+
"langchain-aws==1.2.4",
33+
"langgraph==1.0.8",
3434
"torch==2.8.0",
3535
"sentence-transformers==5.0.0",
3636
"qianfan==0.4.12.3",
3737
"zhipuai==2.1.5.20250708",
3838
"volcengine-python-sdk[ark]==4.0.5",
39-
"boto3==1.39.4",
39+
"boto3==1.42.46",
4040
"tencentcloud-sdk-python==3.0.1420",
4141
"xinference-client==1.7.1.post1",
42-
"anthropic==0.74.1",
42+
"anthropic==0.79.0",
4343
"dashscope==1.25.7",
4444
"celery[sqlalchemy]==5.5.3",
4545
"django-celery-beat==2.8.1",

0 commit comments

Comments
 (0)