Skip to content

Commit

Permalink
remove static function
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdullah13521 committed Dec 4, 2024
1 parent d1faf6c commit cd468b3
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions web/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,22 +1278,18 @@ def validate_input_data(self) -> Self:
is_base64 = re.match(base64_pattern, value) and len(value) % 4 == 0

# Validate URL
is_url = self.is_valid_url(value)
try:
parsed = urlparse(value)
is_url = all([parsed.scheme, parsed.netloc])
except Exception:
is_url = False

Check warning on line 1285 in web/api/views.py

View check run for this annotation

Codecov / codecov/patch

web/api/views.py#L1284-L1285

Added lines #L1284 - L1285 were not covered by tests

if not (is_base64 or is_url):
raise ValueError(
"Each input must be a valid base64 string or a URL. Please use our Python SDK if you want to provide a file path."
)
return self

@staticmethod
def is_valid_url(url: str) -> bool:
try:
parsed = urlparse(url)
return all([parsed.scheme, parsed.netloc])
except Exception:
return False


class EmbeddingsOut(Schema):
_object: str
Expand Down

0 comments on commit cd468b3

Please sign in to comment.