Add quick LLM provider setup
This commit is contained in:
@@ -138,11 +138,7 @@ def _call_anthropic_messages(model: ModelConfig, rag_result: RagResult) -> str:
|
||||
_put_if_not_none(payload, "top_k", model.top_k)
|
||||
payload.update(_load_extra_params(model.extra_params))
|
||||
|
||||
headers = {
|
||||
"x-api-key": model.api_key,
|
||||
"anthropic-version": model.api_version or "2023-06-01",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
headers = _anthropic_headers(model)
|
||||
try:
|
||||
response = httpx.post(
|
||||
_resolve_anthropic_endpoint(model),
|
||||
@@ -263,6 +259,19 @@ def _auth_headers(model: ModelConfig) -> dict[str, str]:
|
||||
return headers
|
||||
|
||||
|
||||
def _anthropic_headers(model: ModelConfig) -> dict[str, str]:
|
||||
headers = {"Content-Type": "application/json"}
|
||||
if model.auth_type == "bearer":
|
||||
headers["Authorization"] = f"Bearer {model.api_key}"
|
||||
else:
|
||||
headers["x-api-key"] = model.api_key
|
||||
if model.api_version:
|
||||
headers["anthropic-version"] = model.api_version
|
||||
elif model.provider == "anthropic":
|
||||
headers["anthropic-version"] = "2023-06-01"
|
||||
return headers
|
||||
|
||||
|
||||
def _decimal_to_float(value: Any) -> float | None:
|
||||
return float(value) if value is not None else None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user