import{_ as i,c as a,ae as n,o as t}from"./chunks/framework.BzDBnRMZ.js";const E=JSON.parse('{"title":"network","description":"","frontmatter":{"title":"network","order":100},"headers":[],"relativePath":"dev/api/plugins/builtin_tools/network.md","filePath":"zh/dev/api/plugins/builtin_tools/network.md","lastUpdated":null}'),l={name:"dev/api/plugins/builtin_tools/network.md"};function h(e,s,k,p,r,d){return t(),a("div",null,s[0]||(s[0]=[n(`
nonebot_plugin_marshoai.plugins.builtin_tools.network
@on_function_call(description='使用网页链接(url)获取网页内容摘要,可以让AI上网查询资料').params(url=String(description='网页链接'))
get_web_content(url: str) -> str
说明: 使用网页链接获取网页内容摘要 为什么要获取摘要,不然token超限了
参数:
- url (str): description
返回: str: description
@on_function_call(description='使用网页链接(url)获取网页内容摘要,可以让AI上网查询资料').params(url=String(description='网页链接'))
async def get_web_content(url: str) -> str:
async with AsyncClient(headers=headers) as client:
try:
response = await client.get(url)
if response.status_code == 200:
article = Article(url)
article.download(input_html=response.text)
article.parse()
if article.text:
return article.text
elif article.html:
return await make_html_summary(article.html)
else:
return '未能获取到有效的网页内容'
else:
return '获取网页内容失败' + str(response.status_code)
except Exception as e:
logger.error(f'marsho builtin: 获取网页内容失败: {e}')
return '获取网页内容失败:' + str(e)
return '未能获取到有效的网页内容'