mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
chore(lint): fix quotes for f-string formatting by bumping ruff to 0.9.x (#12702)
This commit is contained in:
@ -167,8 +167,7 @@ class AppQueueManager:
|
||||
else:
|
||||
if isinstance(data, DeclarativeMeta) or hasattr(data, "_sa_instance_state"):
|
||||
raise TypeError(
|
||||
"Critical Error: Passing SQLAlchemy Model instances "
|
||||
"that cause thread safety issues is not allowed."
|
||||
"Critical Error: Passing SQLAlchemy Model instances that cause thread safety issues is not allowed."
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ class MessageCycleManage:
|
||||
|
||||
# get extension
|
||||
if "." in message_file.url:
|
||||
extension = f'.{message_file.url.split(".")[-1]}'
|
||||
extension = f".{message_file.url.split('.')[-1]}"
|
||||
if len(extension) > 10:
|
||||
extension = ".bin"
|
||||
else:
|
||||
|
||||
@ -62,8 +62,9 @@ class ApiExternalDataTool(ExternalDataTool):
|
||||
|
||||
if not api_based_extension:
|
||||
raise ValueError(
|
||||
"[External data tool] API query failed, variable: {}, "
|
||||
"error: api_based_extension_id is invalid".format(self.variable)
|
||||
"[External data tool] API query failed, variable: {}, error: api_based_extension_id is invalid".format(
|
||||
self.variable
|
||||
)
|
||||
)
|
||||
|
||||
# decrypt api_key
|
||||
|
||||
@ -90,7 +90,7 @@ class File(BaseModel):
|
||||
def markdown(self) -> str:
|
||||
url = self.generate_url()
|
||||
if self.type == FileType.IMAGE:
|
||||
text = f''
|
||||
text = f""
|
||||
else:
|
||||
text = f"[{self.filename or url}]({url})"
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ class AzureOpenAILargeLanguageModel(_CommonAzureOpenAI, LargeLanguageModel):
|
||||
ai_model_entity = self._get_ai_model_entity(base_model_name=base_model_name, model=model)
|
||||
|
||||
if not ai_model_entity:
|
||||
raise CredentialsValidateFailedError(f'Base Model Name {credentials["base_model_name"]} is invalid')
|
||||
raise CredentialsValidateFailedError(f"Base Model Name {credentials['base_model_name']} is invalid")
|
||||
|
||||
try:
|
||||
client = AzureOpenAI(**self._to_credential_kwargs(credentials))
|
||||
|
||||
@ -130,7 +130,7 @@ class AzureOpenAITextEmbeddingModel(_CommonAzureOpenAI, TextEmbeddingModel):
|
||||
raise CredentialsValidateFailedError("Base Model Name is required")
|
||||
|
||||
if not self._get_ai_model_entity(credentials["base_model_name"], model):
|
||||
raise CredentialsValidateFailedError(f'Base Model Name {credentials["base_model_name"]} is invalid')
|
||||
raise CredentialsValidateFailedError(f"Base Model Name {credentials['base_model_name']} is invalid")
|
||||
|
||||
try:
|
||||
credentials_kwargs = self._to_credential_kwargs(credentials)
|
||||
|
||||
@ -162,9 +162,9 @@ class HuggingfaceHubTextEmbeddingModel(_CommonHuggingfaceHub, TextEmbeddingModel
|
||||
@staticmethod
|
||||
def _check_endpoint_url_model_repository_name(credentials: dict, model_name: str):
|
||||
try:
|
||||
url = f'{HUGGINGFACE_ENDPOINT_API}{credentials["huggingface_namespace"]}'
|
||||
url = f"{HUGGINGFACE_ENDPOINT_API}{credentials['huggingface_namespace']}"
|
||||
headers = {
|
||||
"Authorization": f'Bearer {credentials["huggingfacehub_api_token"]}',
|
||||
"Authorization": f"Bearer {credentials['huggingfacehub_api_token']}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
|
||||
@ -257,8 +257,7 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
|
||||
for index, response in enumerate(responses):
|
||||
if response.status_code not in {200, HTTPStatus.OK}:
|
||||
raise ServiceUnavailableError(
|
||||
f"Failed to invoke model {model}, status code: {response.status_code}, "
|
||||
f"message: {response.message}"
|
||||
f"Failed to invoke model {model}, status code: {response.status_code}, message: {response.message}"
|
||||
)
|
||||
|
||||
resp_finish_reason = response.output.choices[0].finish_reason
|
||||
|
||||
@ -146,7 +146,7 @@ class TritonInferenceAILargeLanguageModel(LargeLanguageModel):
|
||||
elif credentials["completion_type"] == "completion":
|
||||
completion_type = LLMMode.COMPLETION.value
|
||||
else:
|
||||
raise ValueError(f'completion_type {credentials["completion_type"]} is not supported')
|
||||
raise ValueError(f"completion_type {credentials['completion_type']} is not supported")
|
||||
|
||||
entity = AIModelEntity(
|
||||
model=model,
|
||||
|
||||
@ -41,15 +41,15 @@ class BaiduAccessToken:
|
||||
resp = response.json()
|
||||
if "error" in resp:
|
||||
if resp["error"] == "invalid_client":
|
||||
raise InvalidAPIKeyError(f'Invalid API key or secret key: {resp["error_description"]}')
|
||||
raise InvalidAPIKeyError(f"Invalid API key or secret key: {resp['error_description']}")
|
||||
elif resp["error"] == "unknown_error":
|
||||
raise InternalServerError(f'Internal server error: {resp["error_description"]}')
|
||||
raise InternalServerError(f"Internal server error: {resp['error_description']}")
|
||||
elif resp["error"] == "invalid_request":
|
||||
raise BadRequestError(f'Bad request: {resp["error_description"]}')
|
||||
raise BadRequestError(f"Bad request: {resp['error_description']}")
|
||||
elif resp["error"] == "rate_limit_exceeded":
|
||||
raise RateLimitReachedError(f'Rate limit reached: {resp["error_description"]}')
|
||||
raise RateLimitReachedError(f"Rate limit reached: {resp['error_description']}")
|
||||
else:
|
||||
raise Exception(f'Unknown error: {resp["error_description"]}')
|
||||
raise Exception(f"Unknown error: {resp['error_description']}")
|
||||
|
||||
return resp["access_token"]
|
||||
|
||||
|
||||
@ -406,7 +406,7 @@ class XinferenceAILargeLanguageModel(LargeLanguageModel):
|
||||
elif credentials["completion_type"] == "completion":
|
||||
completion_type = LLMMode.COMPLETION.value
|
||||
else:
|
||||
raise ValueError(f'completion_type {credentials["completion_type"]} is not supported')
|
||||
raise ValueError(f"completion_type {credentials['completion_type']} is not supported")
|
||||
else:
|
||||
extra_args = XinferenceHelper.get_xinference_extra_parameter(
|
||||
server_url=credentials["server_url"],
|
||||
@ -472,7 +472,7 @@ class XinferenceAILargeLanguageModel(LargeLanguageModel):
|
||||
api_key = credentials.get("api_key") or "abc"
|
||||
|
||||
client = OpenAI(
|
||||
base_url=f'{credentials["server_url"]}/v1',
|
||||
base_url=f"{credentials['server_url']}/v1",
|
||||
api_key=api_key,
|
||||
max_retries=int(credentials.get("max_retries") or DEFAULT_MAX_RETRIES),
|
||||
timeout=int(credentials.get("invoke_timeout") or DEFAULT_INVOKE_TIMEOUT),
|
||||
|
||||
@ -31,7 +31,7 @@ class FirecrawlApp:
|
||||
"markdown": data.get("markdown"),
|
||||
}
|
||||
else:
|
||||
raise Exception(f'Failed to scrape URL. Error: {response_data["error"]}')
|
||||
raise Exception(f"Failed to scrape URL. Error: {response_data['error']}")
|
||||
|
||||
elif response.status_code in {402, 409, 500}:
|
||||
error_message = response.json().get("error", "Unknown error occurred")
|
||||
|
||||
@ -358,8 +358,7 @@ class NotionExtractor(BaseExtractor):
|
||||
|
||||
if not data_source_binding:
|
||||
raise Exception(
|
||||
f"No notion data source binding found for tenant {tenant_id} "
|
||||
f"and notion workspace {notion_workspace_id}"
|
||||
f"No notion data source binding found for tenant {tenant_id} and notion workspace {notion_workspace_id}"
|
||||
)
|
||||
|
||||
return cast(str, data_source_binding.access_token)
|
||||
|
||||
@ -127,7 +127,7 @@ class AIPPTGenerateToolAdapter:
|
||||
|
||||
response = response.json()
|
||||
if response.get("code") != 0:
|
||||
raise Exception(f'Failed to create task: {response.get("msg")}')
|
||||
raise Exception(f"Failed to create task: {response.get('msg')}")
|
||||
|
||||
return response.get("data", {}).get("id")
|
||||
|
||||
@ -222,7 +222,7 @@ class AIPPTGenerateToolAdapter:
|
||||
elif model == "wenxin":
|
||||
response = response.json()
|
||||
if response.get("code") != 0:
|
||||
raise Exception(f'Failed to generate content: {response.get("msg")}')
|
||||
raise Exception(f"Failed to generate content: {response.get('msg')}")
|
||||
|
||||
return response.get("data", "")
|
||||
|
||||
@ -254,7 +254,7 @@ class AIPPTGenerateToolAdapter:
|
||||
|
||||
response = response.json()
|
||||
if response.get("code") != 0:
|
||||
raise Exception(f'Failed to generate ppt: {response.get("msg")}')
|
||||
raise Exception(f"Failed to generate ppt: {response.get('msg')}")
|
||||
|
||||
id = response.get("data", {}).get("id")
|
||||
cover_url = response.get("data", {}).get("cover_url")
|
||||
@ -270,7 +270,7 @@ class AIPPTGenerateToolAdapter:
|
||||
|
||||
response = response.json()
|
||||
if response.get("code") != 0:
|
||||
raise Exception(f'Failed to generate ppt: {response.get("msg")}')
|
||||
raise Exception(f"Failed to generate ppt: {response.get('msg')}")
|
||||
|
||||
export_code = response.get("data")
|
||||
if not export_code:
|
||||
@ -290,7 +290,7 @@ class AIPPTGenerateToolAdapter:
|
||||
|
||||
response = response.json()
|
||||
if response.get("code") != 0:
|
||||
raise Exception(f'Failed to generate ppt: {response.get("msg")}')
|
||||
raise Exception(f"Failed to generate ppt: {response.get('msg')}")
|
||||
|
||||
if response.get("msg") == "导出中":
|
||||
current_iteration += 1
|
||||
@ -343,7 +343,7 @@ class AIPPTGenerateToolAdapter:
|
||||
raise Exception(f"Failed to connect to aippt: {response.text}")
|
||||
response = response.json()
|
||||
if response.get("code") != 0:
|
||||
raise Exception(f'Failed to connect to aippt: {response.get("msg")}')
|
||||
raise Exception(f"Failed to connect to aippt: {response.get('msg')}")
|
||||
|
||||
token = response.get("data", {}).get("token")
|
||||
expire = response.get("data", {}).get("time_expire")
|
||||
@ -379,7 +379,7 @@ class AIPPTGenerateToolAdapter:
|
||||
if cls._style_cache[key]["expire"] < now:
|
||||
del cls._style_cache[key]
|
||||
|
||||
key = f'{credentials["aippt_access_key"]}#@#{user_id}'
|
||||
key = f"{credentials['aippt_access_key']}#@#{user_id}"
|
||||
if key in cls._style_cache:
|
||||
return cls._style_cache[key]["colors"], cls._style_cache[key]["styles"]
|
||||
|
||||
@ -396,11 +396,11 @@ class AIPPTGenerateToolAdapter:
|
||||
response = response.json()
|
||||
|
||||
if response.get("code") != 0:
|
||||
raise Exception(f'Failed to connect to aippt: {response.get("msg")}')
|
||||
raise Exception(f"Failed to connect to aippt: {response.get('msg')}")
|
||||
|
||||
colors = [
|
||||
{
|
||||
"id": f'id-{item.get("id")}',
|
||||
"id": f"id-{item.get('id')}",
|
||||
"name": item.get("name"),
|
||||
"en_name": item.get("en_name", item.get("name")),
|
||||
}
|
||||
@ -408,7 +408,7 @@ class AIPPTGenerateToolAdapter:
|
||||
]
|
||||
styles = [
|
||||
{
|
||||
"id": f'id-{item.get("id")}',
|
||||
"id": f"id-{item.get('id')}",
|
||||
"name": item.get("title"),
|
||||
}
|
||||
for item in response.get("data", {}).get("suit_style") or []
|
||||
@ -454,7 +454,7 @@ class AIPPTGenerateToolAdapter:
|
||||
response = response.json()
|
||||
|
||||
if response.get("code") != 0:
|
||||
raise Exception(f'Failed to connect to aippt: {response.get("msg")}')
|
||||
raise Exception(f"Failed to connect to aippt: {response.get('msg')}")
|
||||
|
||||
if len(response.get("data", {}).get("list") or []) > 0:
|
||||
return response.get("data", {}).get("list")[0].get("id")
|
||||
|
||||
@ -229,8 +229,7 @@ class NovaReelTool(BuiltinTool):
|
||||
|
||||
if async_mode:
|
||||
return self.create_text_message(
|
||||
f"Video generation started.\nInvocation ARN: {invocation_arn}\n"
|
||||
f"Video will be available at: {video_uri}"
|
||||
f"Video generation started.\nInvocation ARN: {invocation_arn}\nVideo will be available at: {video_uri}"
|
||||
)
|
||||
|
||||
return self._wait_for_completion(bedrock, s3_client, invocation_arn)
|
||||
|
||||
@ -65,7 +65,7 @@ class BaiduFieldTranslateTool(BuiltinTool, BaiduTranslateToolBase):
|
||||
if "trans_result" in result:
|
||||
result_text = result["trans_result"][0]["dst"]
|
||||
else:
|
||||
result_text = f'{result["error_code"]}: {result["error_msg"]}'
|
||||
result_text = f"{result['error_code']}: {result['error_msg']}"
|
||||
|
||||
return self.create_text_message(str(result_text))
|
||||
except requests.RequestException as e:
|
||||
|
||||
@ -52,7 +52,7 @@ class BaiduLanguageTool(BuiltinTool, BaiduTranslateToolBase):
|
||||
|
||||
result_text = ""
|
||||
if result["error_code"] != 0:
|
||||
result_text = f'{result["error_code"]}: {result["error_msg"]}'
|
||||
result_text = f"{result['error_code']}: {result['error_msg']}"
|
||||
else:
|
||||
result_text = result["data"]["src"]
|
||||
result_text = self.mapping_result(description_language, result_text)
|
||||
|
||||
@ -58,7 +58,7 @@ class BaiduTranslateTool(BuiltinTool, BaiduTranslateToolBase):
|
||||
if "trans_result" in result:
|
||||
result_text = result["trans_result"][0]["dst"]
|
||||
else:
|
||||
result_text = f'{result["error_code"]}: {result["error_msg"]}'
|
||||
result_text = f"{result['error_code']}: {result['error_msg']}"
|
||||
|
||||
return self.create_text_message(str(result_text))
|
||||
except requests.RequestException as e:
|
||||
|
||||
@ -30,7 +30,7 @@ class BingSearchTool(BuiltinTool):
|
||||
headers = {"Ocp-Apim-Subscription-Key": subscription_key, "Accept-Language": accept_language}
|
||||
|
||||
query = quote(query)
|
||||
server_url = f'{server_url}?q={query}&mkt={market_code}&count={limit}&responseFilter={",".join(filters)}'
|
||||
server_url = f"{server_url}?q={query}&mkt={market_code}&count={limit}&responseFilter={','.join(filters)}"
|
||||
response = get(server_url, headers=headers)
|
||||
|
||||
if response.status_code != 200:
|
||||
@ -47,23 +47,23 @@ class BingSearchTool(BuiltinTool):
|
||||
results = []
|
||||
if search_results:
|
||||
for result in search_results:
|
||||
url = f': {result["url"]}' if "url" in result else ""
|
||||
results.append(self.create_text_message(text=f'{result["name"]}{url}'))
|
||||
url = f": {result['url']}" if "url" in result else ""
|
||||
results.append(self.create_text_message(text=f"{result['name']}{url}"))
|
||||
|
||||
if entities:
|
||||
for entity in entities:
|
||||
url = f': {entity["url"]}' if "url" in entity else ""
|
||||
results.append(self.create_text_message(text=f'{entity.get("name", "")}{url}'))
|
||||
url = f": {entity['url']}" if "url" in entity else ""
|
||||
results.append(self.create_text_message(text=f"{entity.get('name', '')}{url}"))
|
||||
|
||||
if news:
|
||||
for news_item in news:
|
||||
url = f': {news_item["url"]}' if "url" in news_item else ""
|
||||
results.append(self.create_text_message(text=f'{news_item.get("name", "")}{url}'))
|
||||
url = f": {news_item['url']}" if "url" in news_item else ""
|
||||
results.append(self.create_text_message(text=f"{news_item.get('name', '')}{url}"))
|
||||
|
||||
if related_searches:
|
||||
for related in related_searches:
|
||||
url = f': {related["displayText"]}' if "displayText" in related else ""
|
||||
results.append(self.create_text_message(text=f'{related.get("displayText", "")}{url}'))
|
||||
url = f": {related['displayText']}" if "displayText" in related else ""
|
||||
results.append(self.create_text_message(text=f"{related.get('displayText', '')}{url}"))
|
||||
|
||||
return results
|
||||
elif result_type == "json":
|
||||
@ -106,29 +106,29 @@ class BingSearchTool(BuiltinTool):
|
||||
text = ""
|
||||
if search_results:
|
||||
for i, result in enumerate(search_results):
|
||||
text += f'{i + 1}: {result.get("name", "")} - {result.get("snippet", "")}\n'
|
||||
text += f"{i + 1}: {result.get('name', '')} - {result.get('snippet', '')}\n"
|
||||
|
||||
if computation and "expression" in computation and "value" in computation:
|
||||
text += "\nComputation:\n"
|
||||
text += f'{computation["expression"]} = {computation["value"]}\n'
|
||||
text += f"{computation['expression']} = {computation['value']}\n"
|
||||
|
||||
if entities:
|
||||
text += "\nEntities:\n"
|
||||
for entity in entities:
|
||||
url = f'- {entity["url"]}' if "url" in entity else ""
|
||||
text += f'{entity.get("name", "")}{url}\n'
|
||||
url = f"- {entity['url']}" if "url" in entity else ""
|
||||
text += f"{entity.get('name', '')}{url}\n"
|
||||
|
||||
if news:
|
||||
text += "\nNews:\n"
|
||||
for news_item in news:
|
||||
url = f'- {news_item["url"]}' if "url" in news_item else ""
|
||||
text += f'{news_item.get("name", "")}{url}\n'
|
||||
url = f"- {news_item['url']}" if "url" in news_item else ""
|
||||
text += f"{news_item.get('name', '')}{url}\n"
|
||||
|
||||
if related_searches:
|
||||
text += "\n\nRelated Searches:\n"
|
||||
for related in related_searches:
|
||||
url = f'- {related["webSearchUrl"]}' if "webSearchUrl" in related else ""
|
||||
text += f'{related.get("displayText", "")}{url}\n'
|
||||
url = f"- {related['webSearchUrl']}" if "webSearchUrl" in related else ""
|
||||
text += f"{related.get('displayText', '')}{url}\n"
|
||||
|
||||
return self.create_text_message(text=self.summary(user_id=user_id, content=text))
|
||||
|
||||
|
||||
@ -83,5 +83,5 @@ class DIDApp:
|
||||
if status["status"] == "done":
|
||||
return status
|
||||
elif status["status"] == "error" or status["status"] == "rejected":
|
||||
raise HTTPError(f'Talks {id} failed: {status["status"]} {status.get("error", {}).get("description")}')
|
||||
raise HTTPError(f"Talks {id} failed: {status['status']} {status.get('error', {}).get('description')}")
|
||||
time.sleep(poll_interval)
|
||||
|
||||
@ -74,7 +74,7 @@ class FirecrawlApp:
|
||||
if response is None:
|
||||
raise HTTPError("Failed to initiate crawl after multiple retries")
|
||||
elif response.get("success") == False:
|
||||
raise HTTPError(f'Failed to crawl: {response.get("error")}')
|
||||
raise HTTPError(f"Failed to crawl: {response.get('error')}")
|
||||
job_id: str = response["id"]
|
||||
if wait:
|
||||
return self._monitor_job_status(job_id=job_id, poll_interval=poll_interval)
|
||||
@ -100,7 +100,7 @@ class FirecrawlApp:
|
||||
if status["status"] == "completed":
|
||||
return status
|
||||
elif status["status"] == "failed":
|
||||
raise HTTPError(f'Job {job_id} failed: {status["error"]}')
|
||||
raise HTTPError(f"Job {job_id} failed: {status['error']}")
|
||||
time.sleep(poll_interval)
|
||||
|
||||
|
||||
|
||||
@ -37,8 +37,9 @@ class GaodeRepositoriesTool(BuiltinTool):
|
||||
CityCode = City_data["districts"][0]["adcode"]
|
||||
weatherInfo_response = s.request(
|
||||
method="GET",
|
||||
url="{url}/weather/weatherInfo?city={citycode}&extensions=all&key={apikey}&output=json"
|
||||
"".format(url=api_domain, citycode=CityCode, apikey=self.runtime.credentials.get("api_key")),
|
||||
url="{url}/weather/weatherInfo?city={citycode}&extensions=all&key={apikey}&output=json".format(
|
||||
url=api_domain, citycode=CityCode, apikey=self.runtime.credentials.get("api_key")
|
||||
),
|
||||
)
|
||||
weatherInfo_data = weatherInfo_response.json()
|
||||
if weatherInfo_response.status_code == 200 and weatherInfo_data.get("info") == "OK":
|
||||
|
||||
@ -110,7 +110,7 @@ class ListWorksheetRecordsTool(BuiltinTool):
|
||||
result["rows"].append(self.get_row_field_value(row, schema))
|
||||
return self.create_text_message(json.dumps(result, ensure_ascii=False))
|
||||
else:
|
||||
result_text = f"Found {result['total']} rows in worksheet \"{worksheet_name}\"."
|
||||
result_text = f'Found {result["total"]} rows in worksheet "{worksheet_name}".'
|
||||
if result["total"] > 0:
|
||||
result_text += (
|
||||
f" The following are {min(limit, result['total'])}"
|
||||
|
||||
@ -28,4 +28,4 @@ class BaseStabilityAuthorization:
|
||||
"""
|
||||
This method is responsible for generating the authorization headers.
|
||||
"""
|
||||
return {"Authorization": f'Bearer {credentials.get("api_key", "")}'}
|
||||
return {"Authorization": f"Bearer {credentials.get('api_key', '')}"}
|
||||
|
||||
@ -38,7 +38,7 @@ class VannaProvider(BuiltinToolProviderController):
|
||||
tool_parameters={
|
||||
"model": "chinook",
|
||||
"db_type": "SQLite",
|
||||
"url": f'{self._get_protocol_and_main_domain(credentials["base_url"])}/Chinook.sqlite',
|
||||
"url": f"{self._get_protocol_and_main_domain(credentials['base_url'])}/Chinook.sqlite",
|
||||
"query": "What are the top 10 customers by sales?",
|
||||
},
|
||||
)
|
||||
|
||||
@ -84,9 +84,9 @@ class ApiTool(Tool):
|
||||
if "api_key_header_prefix" in credentials:
|
||||
api_key_header_prefix = credentials["api_key_header_prefix"]
|
||||
if api_key_header_prefix == "basic" and credentials["api_key_value"]:
|
||||
credentials["api_key_value"] = f'Basic {credentials["api_key_value"]}'
|
||||
credentials["api_key_value"] = f"Basic {credentials['api_key_value']}"
|
||||
elif api_key_header_prefix == "bearer" and credentials["api_key_value"]:
|
||||
credentials["api_key_value"] = f'Bearer {credentials["api_key_value"]}'
|
||||
credentials["api_key_value"] = f"Bearer {credentials['api_key_value']}"
|
||||
elif api_key_header_prefix == "custom":
|
||||
pass
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ class ToolFileMessageTransformer:
|
||||
user_id=user_id, tenant_id=tenant_id, conversation_id=conversation_id, file_url=message.message
|
||||
)
|
||||
|
||||
url = f'/files/tools/{file.id}{guess_extension(file.mimetype) or ".png"}'
|
||||
url = f"/files/tools/{file.id}{guess_extension(file.mimetype) or '.png'}"
|
||||
|
||||
result.append(
|
||||
ToolInvokeMessage(
|
||||
@ -122,4 +122,4 @@ class ToolFileMessageTransformer:
|
||||
|
||||
@classmethod
|
||||
def get_tool_file_url(cls, tool_file_id: str, extension: Optional[str]) -> str:
|
||||
return f'/files/tools/{tool_file_id}{extension or ".bin"}'
|
||||
return f"/files/tools/{tool_file_id}{extension or '.bin'}"
|
||||
|
||||
@ -149,7 +149,7 @@ class ApiBasedToolSchemaParser:
|
||||
if not path:
|
||||
path = str(uuid.uuid4())
|
||||
|
||||
interface["operation"]["operationId"] = f'{path}_{interface["method"]}'
|
||||
interface["operation"]["operationId"] = f"{path}_{interface['method']}"
|
||||
|
||||
bundles.append(
|
||||
ApiToolBundle(
|
||||
|
||||
@ -253,9 +253,9 @@ class Executor:
|
||||
)
|
||||
if executor_response.size > threshold_size:
|
||||
raise ResponseSizeError(
|
||||
f'{"File" if executor_response.is_file else "Text"} size is too large,'
|
||||
f' max size is {threshold_size / 1024 / 1024:.2f} MB,'
|
||||
f' but current size is {executor_response.readable_size}.'
|
||||
f"{'File' if executor_response.is_file else 'Text'} size is too large,"
|
||||
f" max size is {threshold_size / 1024 / 1024:.2f} MB,"
|
||||
f" but current size is {executor_response.readable_size}."
|
||||
)
|
||||
|
||||
return executor_response
|
||||
@ -338,7 +338,7 @@ class Executor:
|
||||
if self.auth.config and self.auth.config.header:
|
||||
authorization_header = self.auth.config.header
|
||||
if k.lower() == authorization_header.lower():
|
||||
raw += f'{k}: {"*" * len(v)}\r\n'
|
||||
raw += f"{k}: {'*' * len(v)}\r\n"
|
||||
continue
|
||||
raw += f"{k}: {v}\r\n"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user