mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-07-03 14:05:26 +02:00
fa01c2a3a6
## Summary - move provider transport families under `providers/transports/` - split OpenAI-chat transport into thin transport, stream runner, tool-call assembly, and recovery modules - split native Anthropic transport into thin transport, stream runner, recovery, and HTTP helper modules - update concrete provider imports, architecture docs, transport import contracts, version, and lockfile ## Verification - `uv run pytest tests/providers/test_streaming_errors.py tests/providers/test_openai_compat_5xx_retry.py tests/providers/test_anthropic_messages.py tests/providers/test_anthropic_messages_429_retry.py tests/providers/test_provider_transport_logging.py tests/providers/test_gemini.py tests/providers/test_nvidia_nim_request.py tests/providers/test_subagent_interception.py tests/contracts/test_import_boundaries.py` - `uv run ruff format` - `./scripts/ci.ps1`
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""Fireworks AI provider using native Anthropic-compatible Messages."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from providers.base import ProviderConfig
|
|
from providers.transports.anthropic_messages import AnthropicMessagesTransport
|
|
|
|
from .request import build_request_body
|
|
|
|
FIREWORKS_BASE_URL = "https://api.fireworks.ai/inference/v1"
|
|
_ANTHROPIC_VERSION = "2023-06-01"
|
|
|
|
|
|
class FireworksProvider(AnthropicMessagesTransport):
|
|
"""Fireworks AI using Anthropic-compatible Messages."""
|
|
|
|
def __init__(self, config: ProviderConfig):
|
|
super().__init__(
|
|
config,
|
|
provider_name="FIREWORKS",
|
|
default_base_url=FIREWORKS_BASE_URL,
|
|
)
|
|
|
|
def _build_request_body(
|
|
self, request: Any, thinking_enabled: bool | None = None
|
|
) -> dict:
|
|
if thinking_enabled is None:
|
|
thinking_enabled = self._is_thinking_enabled(request)
|
|
return build_request_body(
|
|
request,
|
|
thinking_enabled=thinking_enabled,
|
|
)
|
|
|
|
def _request_headers(self) -> dict[str, str]:
|
|
return {
|
|
"Accept": "text/event-stream",
|
|
"Authorization": f"Bearer {self._api_key}",
|
|
"Content-Type": "application/json",
|
|
"anthropic-version": _ANTHROPIC_VERSION,
|
|
}
|
|
|
|
def _model_list_headers(self) -> dict[str, str]:
|
|
return {"Authorization": f"Bearer {self._api_key}"}
|