Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider Headers (azure, anthropic and mistral) #222

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions portkey_ai/api_resources/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ def __init__(
azure_resource_name: Optional[str] = None,
azure_deployment_id: Optional[str] = None,
azure_api_version: Optional[str] = None,
azure_endpoint_name: Optional[str] = None,
huggingface_base_url: Optional[str] = None,
http_client: Optional[httpx.Client] = None,
request_timeout: Optional[int] = None,
strict_open_ai_compliance: Optional[bool] = None,
anthropic_beta: Optional[str] = None,
anthropic_version: Optional[str] = None,
mistral_fim_completion: Optional[str] = None,
**kwargs,
) -> None:
self.api_key = api_key or default_api_key()
Expand All @@ -102,11 +105,14 @@ def __init__(
self.azure_resource_name = azure_resource_name
self.azure_deployment_id = azure_deployment_id
self.azure_api_version = azure_api_version
self.azure_endpoint_name = azure_endpoint_name
self.huggingface_base_url = huggingface_base_url
self.cache_namespace = cache_namespace
self.request_timeout = request_timeout
self.strict_open_ai_compliance = strict_open_ai_compliance
self.anthropic_beta = anthropic_beta
self.anthropic_version = anthropic_version
self.mistral_fim_completion = mistral_fim_completion
self.kwargs = kwargs

self.custom_headers = createHeaders(
Expand All @@ -132,11 +138,14 @@ def __init__(
azure_resource_name=azure_resource_name,
azure_deployment_id=azure_deployment_id,
azure_api_version=azure_api_version,
azure_endpoint_name=azure_endpoint_name,
huggingface_base_url=huggingface_base_url,
cache_namespace=cache_namespace,
request_timeout=request_timeout,
strict_open_ai_compliance=strict_open_ai_compliance,
anthropic_beta=anthropic_beta,
anthropic_version=anthropic_version,
mistral_fim_completion=mistral_fim_completion,
**kwargs,
)

Expand Down Expand Up @@ -565,11 +574,14 @@ def __init__(
azure_resource_name: Optional[str] = None,
azure_deployment_id: Optional[str] = None,
azure_api_version: Optional[str] = None,
azure_endpoint_name: Optional[str] = None,
huggingface_base_url: Optional[str] = None,
http_client: Optional[httpx.AsyncClient] = None,
request_timeout: Optional[int] = None,
strict_open_ai_compliance: Optional[bool] = None,
anthropic_beta: Optional[str] = None,
anthropic_version: Optional[str] = None,
mistral_fim_completion: Optional[str] = None,
**kwargs,
) -> None:
self.api_key = api_key or default_api_key()
Expand All @@ -595,11 +607,14 @@ def __init__(
self.azure_resource_name = azure_resource_name
self.azure_deployment_id = azure_deployment_id
self.azure_api_version = azure_api_version
self.azure_endpoint_name = azure_endpoint_name
self.huggingface_base_url = huggingface_base_url
self.cache_namespace = cache_namespace
self.request_timeout = request_timeout
self.strict_open_ai_compliance = strict_open_ai_compliance
self.anthropic_beta = anthropic_beta
self.anthropic_version = anthropic_version
self.mistral_fim_completion = mistral_fim_completion
self.kwargs = kwargs

self.custom_headers = createHeaders(
Expand All @@ -625,11 +640,14 @@ def __init__(
azure_resource_name=azure_resource_name,
azure_deployment_id=azure_deployment_id,
azure_api_version=azure_api_version,
azure_endpoint_name=azure_endpoint_name,
huggingface_base_url=huggingface_base_url,
cache_namespace=cache_namespace,
request_timeout=request_timeout,
strict_open_ai_compliance=strict_open_ai_compliance,
anthropic_beta=anthropic_beta,
anthropic_version=anthropic_version,
mistral_fim_completion=mistral_fim_completion,
**kwargs,
)

Expand Down
26 changes: 26 additions & 0 deletions portkey_ai/api_resources/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ def __init__(
azure_resource_name: Optional[str] = None,
azure_deployment_id: Optional[str] = None,
azure_api_version: Optional[str] = None,
azure_endpoint_name: Optional[str] = None,
huggingface_base_url: Optional[str] = None,
http_client: Optional[httpx.Client] = None,
request_timeout: Optional[int] = None,
strict_open_ai_compliance: Optional[bool] = None,
anthropic_beta: Optional[str] = None,
anthropic_version: Optional[str] = None,
mistral_fim_completion: Optional[str] = None,
**kwargs,
) -> None:
super().__init__(
Expand All @@ -98,12 +101,15 @@ def __init__(
azure_resource_name=azure_resource_name,
azure_deployment_id=azure_deployment_id,
azure_api_version=azure_api_version,
azure_endpoint_name=azure_endpoint_name,
huggingface_base_url=huggingface_base_url,
cache_namespace=cache_namespace,
http_client=http_client,
request_timeout=request_timeout,
strict_open_ai_compliance=strict_open_ai_compliance,
anthropic_beta=anthropic_beta,
anthropic_version=anthropic_version,
mistral_fim_completion=mistral_fim_completion,
**kwargs,
)

Expand Down Expand Up @@ -158,11 +164,14 @@ def copy(
azure_resource_name: Optional[str] = None,
azure_deployment_id: Optional[str] = None,
azure_api_version: Optional[str] = None,
azure_endpoint_name: Optional[str] = None,
huggingface_base_url: Optional[str] = None,
http_client: Optional[httpx.Client] = None,
request_timeout: Optional[int] = None,
strict_open_ai_compliance: Optional[bool] = None,
anthropic_beta: Optional[str] = None,
anthropic_version: Optional[str] = None,
mistral_fim_completion: Optional[str] = None,
**kwargs,
) -> Portkey:
return self.__class__(
Expand All @@ -189,13 +198,17 @@ def copy(
azure_resource_name=azure_resource_name or self.azure_resource_name,
azure_deployment_id=azure_deployment_id or self.azure_deployment_id,
azure_api_version=azure_api_version or self.azure_api_version,
azure_endpoint_name=azure_endpoint_name or self.azure_endpoint_name,
huggingface_base_url=huggingface_base_url or self.huggingface_base_url,
cache_namespace=cache_namespace or self.cache_namespace,
http_client=http_client or self._client,
request_timeout=request_timeout or self.request_timeout,
strict_open_ai_compliance=strict_open_ai_compliance
or self.strict_open_ai_compliance,
anthropic_beta=anthropic_beta or self.anthropic_beta,
anthropic_version=anthropic_version or self.anthropic_version,
mistral_fim_completion=mistral_fim_completion
or self.mistral_fim_completion,
**self.kwargs,
**kwargs,
)
Expand Down Expand Up @@ -261,11 +274,14 @@ def __init__(
azure_resource_name: Optional[str] = None,
azure_deployment_id: Optional[str] = None,
azure_api_version: Optional[str] = None,
azure_endpoint_name: Optional[str] = None,
huggingface_base_url: Optional[str] = None,
http_client: Optional[httpx.AsyncClient] = None,
request_timeout: Optional[int] = None,
strict_open_ai_compliance: Optional[bool] = None,
anthropic_beta: Optional[str] = None,
anthropic_version: Optional[str] = None,
mistral_fim_completion: Optional[str] = None,
**kwargs,
) -> None:
super().__init__(
Expand All @@ -292,12 +308,15 @@ def __init__(
azure_resource_name=azure_resource_name,
azure_deployment_id=azure_deployment_id,
azure_api_version=azure_api_version,
azure_endpoint_name=azure_endpoint_name,
huggingface_base_url=huggingface_base_url,
cache_namespace=cache_namespace,
http_client=http_client,
request_timeout=request_timeout,
strict_open_ai_compliance=strict_open_ai_compliance,
anthropic_beta=anthropic_beta,
anthropic_version=anthropic_version,
mistral_fim_completion=mistral_fim_completion,
**kwargs,
)

Expand Down Expand Up @@ -352,11 +371,14 @@ def copy(
azure_resource_name: Optional[str] = None,
azure_deployment_id: Optional[str] = None,
azure_api_version: Optional[str] = None,
azure_endpoint_name: Optional[str] = None,
huggingface_base_url: Optional[str] = None,
http_client: Optional[httpx.AsyncClient] = None,
request_timeout: Optional[int] = None,
strict_open_ai_compliance: Optional[bool] = None,
anthropic_beta: Optional[str] = None,
anthropic_version: Optional[str] = None,
mistral_fim_completion: Optional[str] = None,
**kwargs,
) -> AsyncPortkey:
return self.__class__(
Expand All @@ -383,13 +405,17 @@ def copy(
azure_resource_name=azure_resource_name or self.azure_resource_name,
azure_deployment_id=azure_deployment_id or self.azure_deployment_id,
azure_api_version=azure_api_version or self.azure_api_version,
azure_endpoint_name=azure_endpoint_name or self.azure_endpoint_name,
huggingface_base_url=huggingface_base_url or self.huggingface_base_url,
cache_namespace=cache_namespace or self.cache_namespace,
http_client=http_client or self._client,
request_timeout=request_timeout or self.request_timeout,
strict_open_ai_compliance=strict_open_ai_compliance
or self.strict_open_ai_compliance,
anthropic_beta=anthropic_beta or self.anthropic_beta,
anthropic_version=anthropic_version or self.anthropic_version,
mistral_fim_completion=mistral_fim_completion
or self.mistral_fim_completion,
**self.kwargs,
**kwargs,
)
Expand Down
3 changes: 3 additions & 0 deletions portkey_ai/api_resources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,13 @@ class Constructs(BaseModel):
azure_resource_name: Optional[str] = None
azure_deployment_id: Optional[str] = None
azure_api_version: Optional[str] = None
azure_endpoint_name: Optional[str] = None
huggingface_base_url: Optional[str] = None
cache_namespace: Optional[str] = None
request_timeout: Optional[int] = None
anthropic_beta: Optional[str] = None
anthropic_version: Optional[str] = None
mistral_fim_completion: Optional[bool] = None


class LLMOptions(Constructs, ConversationInput, ModelParams):
Expand Down
Loading