chore: apply ruff's pyflakes linter rules (#2420)
This commit is contained in:
parent
1b04382a9b
commit
14a19a3da9
34 changed files with 91 additions and 86 deletions
|
|
@ -39,13 +39,13 @@ class ToolModelManager:
|
|||
)
|
||||
|
||||
if not model_instance:
|
||||
raise InvokeModelError(f'Model not found')
|
||||
raise InvokeModelError('Model not found')
|
||||
|
||||
llm_model = cast(LargeLanguageModel, model_instance.model_type_instance)
|
||||
schema = llm_model.get_model_schema(model_instance.model, model_instance.credentials)
|
||||
|
||||
if not schema:
|
||||
raise InvokeModelError(f'No model schema found')
|
||||
raise InvokeModelError('No model schema found')
|
||||
|
||||
max_tokens = schema.model_properties.get(ModelPropertyKey.CONTEXT_SIZE, None)
|
||||
if max_tokens is None:
|
||||
|
|
@ -69,7 +69,7 @@ class ToolModelManager:
|
|||
)
|
||||
|
||||
if not model_instance:
|
||||
raise InvokeModelError(f'Model not found')
|
||||
raise InvokeModelError('Model not found')
|
||||
|
||||
llm_model = cast(LargeLanguageModel, model_instance.model_type_instance)
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ class ToolModelManager:
|
|||
except InvokeConnectionError as e:
|
||||
raise InvokeModelError(f'Invoke connection error: {e}')
|
||||
except InvokeAuthorizationError as e:
|
||||
raise InvokeModelError(f'Invoke authorization error')
|
||||
raise InvokeModelError('Invoke authorization error')
|
||||
except InvokeServerUnavailableError as e:
|
||||
raise InvokeModelError(f'Invoke server unavailable error: {e}')
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -66,5 +66,5 @@ class YahooFinanceAnalyticsTool(BuiltinTool):
|
|||
try:
|
||||
return self.create_text_message(str(summary_df.to_dict()))
|
||||
except (HTTPError, ReadTimeout):
|
||||
return self.create_text_message(f'There is a internet connection problem. Please try again later.')
|
||||
return self.create_text_message('There is a internet connection problem. Please try again later.')
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class YahooFinanceSearchTickerTool(BuiltinTool):
|
|||
try:
|
||||
return self.run(ticker=query, user_id=user_id)
|
||||
except (HTTPError, ReadTimeout):
|
||||
return self.create_text_message(f'There is a internet connection problem. Please try again later.')
|
||||
return self.create_text_message('There is a internet connection problem. Please try again later.')
|
||||
|
||||
def run(self, ticker: str, user_id: str) -> ToolInvokeMessage:
|
||||
company = yfinance.Ticker(ticker)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class YahooFinanceSearchTickerTool(BuiltinTool):
|
|||
try:
|
||||
return self.create_text_message(self.run(ticker=query))
|
||||
except (HTTPError, ReadTimeout):
|
||||
return self.create_text_message(f'There is a internet connection problem. Please try again later.')
|
||||
return self.create_text_message('There is a internet connection problem. Please try again later.')
|
||||
|
||||
def run(self, ticker: str) -> str:
|
||||
return str(Ticker(ticker).info)
|
||||
|
|
@ -221,7 +221,7 @@ class Tool(BaseModel, ABC):
|
|||
result += f"result link: {response.message}. please tell user to check it."
|
||||
elif response.type == ToolInvokeMessage.MessageType.IMAGE_LINK or \
|
||||
response.type == ToolInvokeMessage.MessageType.IMAGE:
|
||||
result += f"image has been created and sent to user already, you should tell user to check it now."
|
||||
result += "image has been created and sent to user already, you should tell user to check it now."
|
||||
elif response.type == ToolInvokeMessage.MessageType.BLOB:
|
||||
if len(response.message) > 114:
|
||||
result += str(response.message[:114]) + '...'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue