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

@@ -32,17 +32,14 @@ class TwilioAPIWrapper(BaseModel):
must be empty.
"""
@field_validator('client', mode='before')
@field_validator("client", mode="before")
@classmethod
def set_validator(cls, values: dict) -> dict:
"""Validate that api key and python package exists in environment."""
try:
from twilio.rest import Client
except ImportError:
raise ImportError(
"Could not import twilio python package. "
"Please install it with `pip install twilio`."
)
raise ImportError("Could not import twilio python package. " "Please install it with `pip install twilio`.")
account_sid = values.get("account_sid")
auth_token = values.get("auth_token")
values["from_number"] = values.get("from_number")
@@ -91,9 +88,7 @@ class SendMessageTool(BuiltinTool):
if to_number.startswith("whatsapp:"):
from_number = f"whatsapp: {from_number}"
twilio = TwilioAPIWrapper(
account_sid=account_sid, auth_token=auth_token, from_number=from_number
)
twilio = TwilioAPIWrapper(account_sid=account_sid, auth_token=auth_token, from_number=from_number)
# Sending the message through Twilio
result = twilio.run(message, to_number)

View File

@@ -14,7 +14,7 @@ class TwilioProvider(BuiltinToolProviderController):
account_sid = credentials["account_sid"]
auth_token = credentials["auth_token"]
from_number = credentials["from_number"]
# Initialize twilio client
client = Client(account_sid, auth_token)
@@ -27,4 +27,3 @@ class TwilioProvider(BuiltinToolProviderController):
raise ToolProviderCredentialValidationError(f"Missing required credential: {e}") from e
except Exception as e:
raise ToolProviderCredentialValidationError(str(e))