Skip to content

Commit

Permalink
added check to limit headers that can be used
Browse files Browse the repository at this point in the history
  • Loading branch information
vedpatwardhan committed Jul 22, 2024
1 parent 802b345 commit 132a9fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions unify/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from unify.exceptions import BadRequestError, UnifyError, status_error_map
from unify.utils import ( # noqa:WPS450
_available_dynamic_modes,
_available_extra_headers,
_validate_api_key,
_validate_endpoint,
)
Expand Down Expand Up @@ -178,6 +179,7 @@ def generate( # noqa: WPS234, WPS211
else:
raise UnifyError("You must provider either the user_prompt or messages!")

extra_headers = {key: extra_headers[key] for key in _available_extra_headers}
if stream:
return self._generate_stream(
contents,
Expand Down Expand Up @@ -480,6 +482,7 @@ async def generate( # noqa: WPS234, WPS211
else:
raise UnifyError("You must provide either the user_prompt or messages!")

extra_headers = {key: extra_headers[key] for key in _available_extra_headers}
if stream:
return self._generate_stream(
contents,
Expand Down
4 changes: 4 additions & 0 deletions unify/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"tks-per-sec",
]

_available_extra_headers = [
"anthropic-beta"
]

_base_url = "https://api.unify.ai/v0"


Expand Down

0 comments on commit 132a9fd

Please sign in to comment.