分享一个没什么作为的case #700
Replies: 14 comments
-
为什么你的回答是中文 |
Beta Was this translation helpful? Give feedback.
-
我的几乎跑不出结果。中文输出,用的哪家的模型? |
Beta Was this translation helpful? Give feedback.
-
请问这个跑出结果后不满意还能怎么调优呢? |
Beta Was this translation helpful? Give feedback.
-
应该用的是deepseek |
Beta Was this translation helpful? Give feedback.
-
支持自定义接入deepseek的api key吗 |
Beta Was this translation helpful? Give feedback.
-
支持 deepseek-chat 模型 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
用的是阿里的qwen-max-latest,直接用阿里云百炼的API |
Beta Was this translation helpful? Give feedback.
-
用的是阿里的qwen-max-latest,直接用阿里云百炼的API |
Beta Was this translation helpful? Give feedback.
-
我也想知道 ,找cursor帮帮忙,例如我用cursor把搜索工具换成bing之后就好了一点点。 |
Beta Was this translation helpful? Give feedback.
-
果然这玩意儿还是主要看搜索出来的结果🤔 |
Beta Was this translation helpful? Give feedback.
-
可以分享下怎么做的吗是不是需要一个BingAPIKey |
Beta Was this translation helpful? Give feedback.
-
cursor直接用解析网页的方式来获取结果,没用到API。 bing_search.py放到app/tool下,然后app/agent/manus.py里把google改成bing,添加依赖
import asyncio
import re
import urllib.parse
from typing import List
import aiohttp
from bs4 import BeautifulSoup
from app.tool.base import BaseTool
class BingSearch(BaseTool):
name: str = "bing_search"
description: str = """使用 Bing 搜索并返回相关链接列表。
当你需要查找网络信息、获取最新数据或研究特定主题时使用此工具。
该工具返回与搜索查询匹配的 URL 列表和简短描述。
"""
parameters: dict = {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "(required) 提交给 Bing 的搜索查询。",
},
"num_results": {
"type": "integer",
"description": "(optional) 要返回的搜索结果数量。默认为 10。",
"default": 10,
},
},
"required": ["query"],
}
async def execute(self, query: str, num_results: int = 10) -> List[dict]:
"""
执行 Bing 搜索并返回结果列表。
Args:
query (str): 提交给 Bing 的搜索查询。
num_results (int, optional): 要返回的搜索结果数量。默认为 10。
Returns:
List[dict]: 包含标题、URL和描述的搜索结果列表。
"""
encoded_query = urllib.parse.quote(query)
url = f"https://www.bing.com/search?q={encoded_query}&count={num_results}"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Referer": "https://www.bing.com/",
"Cache-Control": "no-cache",
"Pragma": "no-cache",
}
results = []
try:
async with aiohttp.ClientSession() as session:
async with session.get(url, headers=headers) as response:
if response.status == 200:
html = await response.text()
soup = BeautifulSoup(html, "html.parser")
# 提取搜索结果
search_results = soup.select("li.b_algo")
count = 0
for result in search_results:
if count >= num_results:
break
# 提取标题和链接
title_element = result.select_one("h2 a")
if not title_element:
continue
title = title_element.get_text(strip=True)
link = title_element.get("href", "")
# 提取描述
abstract = ""
abstract_element = result.select_one(".b_caption p")
if abstract_element:
abstract = abstract_element.get_text(strip=True)
results.append({
"title": title,
"url": link,
"description": abstract
})
count += 1
else:
return [{"title": "搜索失败", "url": "", "description": f"HTTP状态码: {response.status}"}]
except Exception as e:
return [{"title": "搜索出错", "url": "", "description": str(e)}]
return results |
Beta Was this translation helpful? Give feedback.
-
跑了几个问题,没有一个完成的,各种报错 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions