mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-20 15:40:29 +01:00
dd510f99e0
`CloudLlmTokenProvider` returned `anyhow::Result`, and
`authenticated_llm_request` reported every failure, including failing to
mint an LLM token, as `LanguageModelCompletionError::HttpSend`. An
expired session (401) or a missing subscription (402) during token
minting therefore looked like a connectivity problem: the agent panel
showed a stream error, and retry logic treated it as transient.
Downstream consumers (Delta) had to dig typed errors back out of the
`anyhow` chain to recover the real cause.
This PR:
- Changes `CloudLlmTokenProvider::cached_token`/`refresh_token` to
return `Result<String, ClientApiError>`, and
`Client::{cached,refresh,clear_and_refresh}_llm_token` to match.
- Adds `LlmRequestError`, returned by `authenticated_llm_request`, which
separates token acquisition failures from building or sending the
request.
- Adds `LlmRequestError::into_completion_error`, which maps:
- `Unauthorized`/`NotSignedIn` to a Zed `Authentication` rejection (not
retried),
- a token-endpoint 402 to the existing `PaymentRequired` rejection,
- other token-endpoint statuses by HTTP status (for example 403 to
`Permission`, 5xx to retryable `InternalServer`),
- connection failures and send failures to `HttpSend`, as before.
In Zed, a token failure caused by an expired session now shows the agent
panel's authentication error instead of a stream error. Messages stay
neutral about whose credentials were rejected so callers can choose
wording from the category.
Release Notes:
- Improved the agent panel error shown when a Zed sign-in has expired.
37 lines
970 B
TOML
37 lines
970 B
TOML
[package]
|
|
name = "language_models_cloud"
|
|
version = "0.1.0"
|
|
edition.workspace = true
|
|
publish.workspace = true
|
|
license = "GPL-3.0-or-later"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[lib]
|
|
path = "src/language_models_cloud.rs"
|
|
doctest = false
|
|
|
|
[dependencies]
|
|
anthropic = { workspace = true, features = ["schemars"] }
|
|
anyhow.workspace = true
|
|
cloud_api_client.workspace = true
|
|
cloud_llm_client.workspace = true
|
|
futures.workspace = true
|
|
google_ai = { workspace = true, features = ["schemars"] }
|
|
gpui.workspace = true
|
|
http_client.workspace = true
|
|
language_model.workspace = true
|
|
log.workspace = true
|
|
open_ai = { workspace = true, features = ["schemars"] }
|
|
schemars.workspace = true
|
|
semver.workspace = true
|
|
serde.workspace = true
|
|
serde_json.workspace = true
|
|
thiserror.workspace = true
|
|
|
|
[dev-dependencies]
|
|
gpui = { workspace = true, features = ["test-support"] }
|
|
http_client = { workspace = true, features = ["test-support"] }
|
|
language_model = { workspace = true, features = ["test-support"] }
|