chore(api/core): apply ruff reformatting (#7624)

This commit is contained in:
Bowen Liang
2024-09-10 17:00:20 +08:00
committed by GitHub
parent 178730266d
commit 2cf1187b32
724 changed files with 21180 additions and 21123 deletions

View File

@@ -13,12 +13,8 @@ class SearXNGProvider(BuiltinToolProviderController):
"credentials": credentials,
}
).invoke(
user_id='',
tool_parameters={
"query": "SearXNG",
"limit": 1,
"search_type": "general"
},
user_id="",
tool_parameters={"query": "SearXNG", "limit": 1, "search_type": "general"},
)
except Exception as e:
raise ToolProviderCredentialValidationError(str(e))

View File

@@ -23,18 +23,21 @@ class SearXNGSearchTool(BuiltinTool):
ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation.
"""
host = self.runtime.credentials.get('searxng_base_url')
host = self.runtime.credentials.get("searxng_base_url")
if not host:
raise Exception('SearXNG api is required')
raise Exception("SearXNG api is required")
response = requests.get(host, params={
"q": tool_parameters.get('query'),
"format": "json",
"categories": tool_parameters.get('search_type', 'general')
})
response = requests.get(
host,
params={
"q": tool_parameters.get("query"),
"format": "json",
"categories": tool_parameters.get("search_type", "general"),
},
)
if response.status_code != 200:
raise Exception(f'Error {response.status_code}: {response.text}')
raise Exception(f"Error {response.status_code}: {response.text}")
res = response.json().get("results", [])
if not res: