refactor: 适配了 langchain v1 版本,但并引入新特性,仅无兼容性错误
This commit is contained in:
parent
0ee327cb97
commit
d56cec5002
@ -5,8 +5,8 @@ description = "Add your description here"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arxiv>=2.2.0",
|
|
||||||
"asyncpg>=0.30.0",
|
"asyncpg>=0.30.0",
|
||||||
|
"langchain==1.0",
|
||||||
"chromadb>=1.0.15",
|
"chromadb>=1.0.15",
|
||||||
"colorlog>=6.9.0",
|
"colorlog>=6.9.0",
|
||||||
"dashscope>=1.23.2",
|
"dashscope>=1.23.2",
|
||||||
@ -19,8 +19,7 @@ dependencies = [
|
|||||||
"langchain-openai>=0.3.14",
|
"langchain-openai>=0.3.14",
|
||||||
"langchain-tavily>=0.2.3",
|
"langchain-tavily>=0.2.3",
|
||||||
"langchain-text-splitters>=0.3.9",
|
"langchain-text-splitters>=0.3.9",
|
||||||
"langchain-together>=0.3.0",
|
"langgraph==1.0.1",
|
||||||
"langgraph>=0.3.34",
|
|
||||||
"langgraph-checkpoint-sqlite>=2.0.7",
|
"langgraph-checkpoint-sqlite>=2.0.7",
|
||||||
"langgraph-cli[inmem]>=0.1.54",
|
"langgraph-cli[inmem]>=0.1.54",
|
||||||
"langsmith>=0.3.37",
|
"langsmith>=0.3.37",
|
||||||
|
|||||||
@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from fastapi import APIRouter, Body, Depends, HTTPException
|
from fastapi import APIRouter, Body, Depends, HTTPException
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
from langchain_core.messages import AIMessageChunk, HumanMessage
|
from langchain.messages import AIMessageChunk, HumanMessage
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from langchain_core.messages import AIMessage, ToolMessage
|
from langchain.messages import AIMessage, ToolMessage
|
||||||
from langgraph.graph import END, START, StateGraph
|
from langgraph.graph import END, START, StateGraph
|
||||||
from langgraph.prebuilt import ToolNode, tools_condition
|
from langgraph.prebuilt import ToolNode, tools_condition
|
||||||
from langgraph.runtime import Runtime
|
from langgraph.runtime import Runtime
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from collections.abc import Sequence
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
from langchain_core.messages import AnyMessage
|
from langchain.messages import AnyMessage
|
||||||
from langgraph.graph import add_messages
|
from langgraph.graph import add_messages
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import os
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from langchain_core.tools import tool
|
from langchain.tools import tool
|
||||||
|
|
||||||
from src.agents.common.toolkits.mysql import get_mysql_tools
|
from src.agents.common.toolkits.mysql import get_mysql_tools
|
||||||
from src.agents.common.tools import get_buildin_tools
|
from src.agents.common.tools import get_buildin_tools
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from langchain_core.language_models import BaseChatModel
|
from langchain.chat_models import BaseChatModel
|
||||||
from pydantic import SecretStr
|
from pydantic import SecretStr
|
||||||
|
|
||||||
from src import config
|
from src import config
|
||||||
@ -37,15 +37,15 @@ def load_chat_model(fully_specified_name: str, **kwargs) -> BaseChatModel:
|
|||||||
stream_usage=True,
|
stream_usage=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif provider == "together":
|
# elif provider == "together":
|
||||||
from langchain_together import ChatTogether
|
# from langchain_together import ChatTogether
|
||||||
|
|
||||||
return ChatTogether(
|
# return ChatTogether(
|
||||||
model=model,
|
# model=model,
|
||||||
api_key=SecretStr(api_key),
|
# api_key=SecretStr(api_key),
|
||||||
base_url=base_url,
|
# base_url=base_url,
|
||||||
stream_usage=True,
|
# stream_usage=True,
|
||||||
)
|
# )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try: # 其他模型,默认使用OpenAIBase, like openai, zhipuai
|
try: # 其他模型,默认使用OpenAIBase, like openai, zhipuai
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
from typing import Annotated, Any
|
from typing import Annotated, Any
|
||||||
|
|
||||||
from langchain_core.tools import tool
|
from langchain.tools import tool
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
|
|||||||
@ -2,7 +2,8 @@ import asyncio
|
|||||||
import traceback
|
import traceback
|
||||||
from typing import Annotated, Any
|
from typing import Annotated, Any
|
||||||
|
|
||||||
from langchain_core.tools import StructuredTool, tool
|
from langchain.tools import tool
|
||||||
|
from langchain_core.tools import StructuredTool
|
||||||
from langchain_tavily import TavilySearch
|
from langchain_tavily import TavilySearch
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
from langchain_core.messages import AIMessageChunk, ToolMessage
|
from langchain.messages import AIMessageChunk, ToolMessage
|
||||||
from langchain_core.runnables import RunnableConfig
|
from langchain_core.runnables import RunnableConfig
|
||||||
|
|
||||||
from src.agents.common.base import BaseAgent
|
from src.agents.common.base import BaseAgent
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from langchain_core.messages import AnyMessage, SystemMessage
|
from langchain.messages import AnyMessage, SystemMessage
|
||||||
from langgraph.prebuilt import create_react_agent
|
from langgraph.prebuilt import create_react_agent
|
||||||
from langgraph.runtime import get_runtime
|
from langgraph.runtime import get_runtime
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import asyncio
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
||||||
from langchain_community.document_loaders import (
|
from langchain_community.document_loaders import (
|
||||||
CSVLoader,
|
CSVLoader,
|
||||||
JSONLoader,
|
JSONLoader,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user