mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 21:37:20 +08:00
升级agent,pydantic升级到2
This commit is contained in:
parent
a306c10375
commit
4e358db525
@ -1,9 +1,9 @@
|
||||
# LangChain 的 ArxivQueryRun 工具
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
from langchain.tools.arxiv.tool import ArxivQueryRun
|
||||
def arxiv(query: str):
|
||||
tool = ArxivQueryRun()
|
||||
return tool.run(tool_input=query)
|
||||
|
||||
class ArxivInput(BaseModel):
|
||||
query: str = Field(description="The search query title")
|
||||
query: str = Field(description="The search query title")
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import base64
|
||||
import os
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
|
||||
def save_base64_audio(base64_audio, file_path):
|
||||
audio_data = base64.b64decode(base64_audio)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
|
||||
def calculate(a: float, b: float, operator: str) -> float:
|
||||
if operator == "+":
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
from langchain.utilities.bing_search import BingSearchAPIWrapper
|
||||
from langchain.utilities.duckduckgo_search import DuckDuckGoSearchAPIWrapper
|
||||
from configs import TOOL_CONFIG
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from urllib.parse import urlencode
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
|
||||
from server.knowledge_base.kb_doc_api import search_docs
|
||||
from configs import TOOL_CONFIG
|
||||
@ -36,4 +36,4 @@ class SearchKnowledgeInput(BaseModel):
|
||||
|
||||
def search_local_knowledgebase(database: str, query: str):
|
||||
tool_config = TOOL_CONFIG["search_local_knowledgebase"]
|
||||
return search_knowledgebase(query=query, database=database, config=tool_config)
|
||||
return search_knowledgebase(query=query, database=database, config=tool_config)
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
from langchain_community.tools import YouTubeSearchTool
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
def search_youtube(query: str):
|
||||
tool = YouTubeSearchTool()
|
||||
return tool.run(tool_input=query)
|
||||
|
||||
class YoutubeInput(BaseModel):
|
||||
query: str = Field(description="Query for Videos search")
|
||||
query: str = Field(description="Query for Videos search")
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
# LangChain 的 Shell 工具
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
from langchain_community.tools import ShellTool
|
||||
def shell(query: str):
|
||||
tool = ShellTool()
|
||||
return tool.run(tool_input=query)
|
||||
|
||||
class ShellInput(BaseModel):
|
||||
query: str = Field(description="The command to execute")
|
||||
query: str = Field(description="The command to execute")
|
||||
|
||||
@ -6,7 +6,7 @@ from typing import List
|
||||
import uuid
|
||||
|
||||
from langchain.agents import tool
|
||||
from langchain.pydantic_v1 import Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
import openai
|
||||
from pydantic.fields import FieldInfo
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import base64
|
||||
from io import BytesIO
|
||||
import torch
|
||||
from PIL import Image, ImageDraw
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
from configs import TOOL_CONFIG
|
||||
import re
|
||||
from server.agent.container import container
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
"""
|
||||
简单的单参数输入工具实现,用于查询现在天气的情况
|
||||
"""
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
import requests
|
||||
|
||||
def weather(location: str, api_key: str):
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Langchain 自带的 Wolfram Alpha API 封装
|
||||
from langchain.utilities.wolfram_alpha import WolframAlphaAPIWrapper
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
wolfram_alpha_appid = "your key"
|
||||
def wolfram(query: str):
|
||||
wolfram = WolframAlphaAPIWrapper(wolfram_alpha_appid=wolfram_alpha_appid)
|
||||
@ -8,4 +8,4 @@ def wolfram(query: str):
|
||||
return ans
|
||||
|
||||
class WolframInput(BaseModel):
|
||||
formula: str = Field(description="The formula to be calculated")
|
||||
formula: str = Field(description="The formula to be calculated")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user