mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-19 07:46:53 +08:00
chore(api/core): apply ruff reformatting (#7624)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user