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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add anthropic_version header for AnthropicProvider #11056

Merged
merged 1 commit into from Feb 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions mlflow/gateway/config.py
Expand Up @@ -167,6 +167,7 @@ def validate_field_compatibility(cls, config: Dict[str, Any]):

class AnthropicConfig(ConfigModel):
anthropic_api_key: str
anthropic_version: str = "2023-06-01"

# pylint: disable=no-self-argument
@validator("anthropic_api_key", pre=True)
Expand Down
5 changes: 4 additions & 1 deletion mlflow/gateway/providers/anthropic.py
Expand Up @@ -104,7 +104,10 @@ def __init__(self, config: RouteConfig) -> None:
if config.model.config is None or not isinstance(config.model.config, AnthropicConfig):
raise TypeError(f"Invalid config type {config.model.config}")
self.anthropic_config: AnthropicConfig = config.model.config
self.headers = {"x-api-key": self.anthropic_config.anthropic_api_key}
self.headers = {
"x-api-key": self.anthropic_config.anthropic_api_key,
"anthropic-version": self.anthropic_config.anthropic_version,
}
self.base_url = "https://api.anthropic.com/v1/"

async def completions(self, payload: completions.RequestPayload) -> completions.ResponsePayload:
Expand Down