Langchain-Chatchat icon indicating copy to clipboard operation
Langchain-Chatchat copied to clipboard

[FEATURE] 怎么实现一个tool,支持解析输入的参数,调用对应的外部url

Open xqxls opened this issue 9 months ago • 1 comments

比如,在输入框输入“打开百度首页”,然后自动新开一个浏览器页面,并且打开百度的首页。 这是我的实现:

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")

xqxls avatar May 13 '24 11:05 xqxls

首先确保这个tool能单独执行 其次,配置可参考我的帖子https://zhuanlan.zhihu.com/p/691243377

KevinFanng avatar May 15 '24 01:05 KevinFanng

这个问题已经被标记为 stale ,因为它已经超过 30 天没有任何活动。

github-actions[bot] avatar Jun 14 '24 21:06 github-actions[bot]