1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Where a z.ai GLM request goes (#1350).
//!
//! z.ai has two documented hosts that behave differently under a long
//! stream: `api.z.ai` closes an idle streaming connection after roughly 30s,
//! `open.bigmodel.cn` does not. The factory used to hardcode the former while
//! the README named the latter, so a user following the docs got a host they
//! never chose. A configured `base_url` on `[providers.zhipu]` now wins, the
//! same way it does for Moonshot; the default stays on `api.z.ai`, which is
//! what the code has always used.
//!
//! Pure so the resolution is testable without a config or a client.
const DEFAULT_HOST: &str = "https://api.z.ai";
/// The path z.ai serves each endpoint type under. `coding` is the Coding
/// Plan channel; anything else is the general API.
/// The API root, from a configured `base_url` or the endpoint-type default.
/// A configured value may be the root or the full chat URL; either way the
/// root is what comes back, without a trailing slash.
/// The chat-completions URL the provider posts to.
pub
/// The `/models` URL the onboarding wizard lists from, on the same host and
/// channel the chat URL resolves to, so the list matches what the key can
/// actually reach.
pub
/// Seconds of inter-chunk silence to tolerate before the stream is treated as
/// dropped, when `stream_idle_timeout_secs` is not configured.
///
/// `api.z.ai` closes an idle streaming connection at roughly 30s; the generic
/// remote default is 20s. On that host our own timer fired first and the client
/// reported "connection likely dropped" about a socket that was still open
/// (#1666). Sitting above the host's documented cut makes the server's close the
/// thing we observe, instead of our guess about it.
///
/// `None` for any other host, including `open.bigmodel.cn`, which has no idle
/// cut and therefore no host-specific reason to move off the generic default.
pub