Langchain-Chatchat
Langchain-Chatchat copied to clipboard
[FEATURE] 怎么实现一个tool,支持解析输入的参数,调用对应的外部url
比如,在输入框输入“打开百度首页”,然后自动新开一个浏览器页面,并且打开百度的首页。 这是我的实现:
from langchain.prompts import PromptTemplate
from langchain.chains import LLMMathChain
from server.agent import model_container
from pydantic import BaseModel, Field
PROMPT = PromptTemplate(
input_variables=["url"],
template="新开一个谷歌浏览器窗口,打开{url}这个url对应的网站"
)
def myfunc(url: str):
webbrowser.open("https://www.baidu.com")
model = model_container.MODEL
llm_chain = LLMChain(model,PROMPT)
llm_chain.run(url)
return ans
class MyfuncInput(BaseModel):
url: str = Field(description="打开url")
首先确保这个tool能单独执行 其次,配置可参考我的帖子https://zhuanlan.zhihu.com/p/691243377
这个问题已经被标记为 stale
,因为它已经超过 30 天没有任何活动。