Back ChatSnowflake() with the Cortex REST API: thin Anthropic/OpenAI provider subclasses, model-name dispatch, credentials-callable auth
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- ai, backend-api-design
Direzione di ricerca
Leggi prima chatlas/_provider_bedrock.py e chatlas/_provider_posit.py per confrontare la costruzione delle sottoclassi, il dispatch dei modelli e la gestione delle credenziali. Poi esamina lo SnowflakeProvider esistente e i relativi test o punti di ingresso, se presenti. Il lavoro è completo quando entrambi i percorsi della Cortex REST API, l’autenticazione Bearer invocabile, il dispatch, il comportamento di transizione e le differenze documentate di osservabilità sono stati risolti e testati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Proposal: back ChatSnowflake() with the Cortex REST API, delegating to AnthropicProvider/OpenAICompletionsProvider
Context
claude-sonnet-5 on Snowflake Cortex sends extended thinking blocks that the current SnowflakeProvider (built on snowflake-ml-python's CompleteRequest) never had to handle. Supporting them requires Snowflake-specific parsing/merging logic for thinking + signature fragments that duplicates what AnthropicProvider already does. Every future Anthropic (or OpenAI) feature Snowflake adopts — redacted thinking, interleaved thinking, server tools, new delta types — will require another patch against Snowflake's proprietary, undocumented streaming format, which the provider's own comments already flag as unstable. (Short-term fix for the immediate crash: branch fix/snowflake-anthropic-thinking-delta.)
The opportunity
Snowflake's Cortex REST API exposes two industry-standard endpoints:
| Chat Completions API | Messages API | |
|---|---|---|
| Compatibility | OpenAI Chat Completions | Anthropic Messages API |
| Endpoint | /api/v2/cortex/v1/chat/completions |
/api/v2/cortex/v1/messages |
| Models | All (Claude, OpenAI, Llama, Mistral, ...) | Claude only (incl. claude-sonnet-5) |
| SDK | openai |
anthropic |
Both are explicitly documented to work with the stock SDKs by overriding base_url and setting a Bearer token. The Messages API supports adaptive/extended thinking with signatures that round-trip in multi-turn conversations, proper SSE streaming, Anthropic-format tool calling, prompt caching, structured output, and anthropic-beta headers (interleaved thinking, effort, etc.).
Proposal
Combine two patterns already in chatlas:
Subclassing mechanics from BedrockMessagesProvider (chatlas/_provider_bedrock.py): thin subclasses that customize client construction and inherit everything else.
@no_file_management # no Files API on the gateway
class SnowflakeAnthropicProvider(AnthropicProvider):
"""Reaches Snowflake Cortex's Anthropic Messages API."""
# ~60 lines: anthropic.Anthropic with
# base_url="https://<account>.snowflakecomputing.com/api/v2/cortex"
class SnowflakeOpenAIProvider(OpenAICompletionsProvider):
"""Reaches Snowflake Cortex's OpenAI Chat Completions API."""
# base_url="https://<account>.snowflakecomputing.com/api/v2/cortex/v1"
Dispatch and auth ergonomics from ChatPosit (chatlas/_provider_posit.py):
- Dispatch by model name, not an
api=param.ChatPositselects its Anthropic vs OpenAI provider viamodel.startswith("claude"). Snowflake's endpoint coverage is cleanly partitioned by model family (Claude → Messages, everything else → Chat Completions), so unlike Bedrock — whereapi=exists because the APIs overlap in model coverage — no explicitapi=argument is needed. (An optional override could still force the legacy path during a transition period.) - A
credentials: Callable[[], str]parameter + an httpx auth flow that swaps the SDK's defaultx-api-keyheader forAuthorization: Bearer <token>— exactly what Snowflake requires, per its own docs. Because the callable is invoked per request, expiring tokens (OAuth, key-pair JWT) are naturally supported. One callable serves both REST flavors.
Benefits:
- All Anthropic/OpenAI thinking, tool-use, and streaming logic is inherited, not duplicated; future Snowflake-adopted features arrive for free.
- Thinking signatures round-trip correctly in multi-turn tool loops (the
CompleteRequestpath currently dropsContentThinkingwhen re-serializing history). - End state mirrors
ChatPosit: two thin provider subclasses plus auth, and thesnowflake-ml-pythondependency — along with its janky stream-merging code — can be deprecated rather than patched.
Open questions / costs
- Auth is the main work. The REST API needs a Bearer token: PAT (simplest for users), OAuth, or key-pair JWT (
X-Snowflake-Authorization-Token-Type: KEYPAIR_JWT; the header is optional since Snowflake sniffs token type). To preserve the currentconnections.toml/private_key_fileergonomics, chatlas should ship a default credentials helper that mints/refreshes a JWT from the existing connection params. Session tokens should be discouraged: their expiration surfaces as HTTP 200 with error code390112, which would need a response-body-inspecting error hook. - Observability differs: REST API calls don't write to
AI_OBSERVABILITY_EVENTS; usage moves toCORTEX_REST_API_USAGE_HISTORY. Worth documenting. - Transition plan: keep the legacy provider as the default initially, gate the new path behind opt-in (or new-model dispatch), and deprecate once the auth story is proven.
Related
- Short-term thinking-delta fix on the legacy path: branch
fix/snowflake-anthropic-thinking-delta
- Lingua principale
- Python
- Stelle
- 179
- Fork
- 32
- Merge medio
- 1g 3h
- PR unite (30g)
- 10
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di posit-dev/chatlas
-
A streaming text delta that repeats everything streamed so far is missing from the recorded turnForse già presa @cpsievert l’ha presa 81 giorni fa. Apertaai-triage:done Priority: Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
ai-triage:needs-review documentation
Difficoltà 2/5 1-2 giorni Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
ai-triage:done Priority: Low
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di posit-dev/chatlas
Issue simili
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[TV SHOW]: Dynasty (1981)Apertacountry:US rating:6 request-theme type:TV SHOW
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
LizardByte/ThemerrDB#10501 · 1 commento ·
-
triage/confirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
agentscope-ai/agentscope#4563 ·
I maintainer di solito rispondono entro 2 giorni
-
comp/desktop desktop/chat P3 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
NousResearch/hermes-agent#164451 ·
I maintainer di solito rispondono entro 1 giorno
-
external integration integration-submission
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
langchain-ai/docs#8426 ·
I maintainer di solito rispondono entro 1 giorno