Files
Kigi-CLI/crates/codegen/kigi-shell/tests/common/mod.rs
T
ZacharyZhang-NY 7efb4b07cc Add DeepSeek platform + ChatCompletions dialect system (provider 3)
The 6th registry row: id "deepseek", DEEPSEEK_API_KEY > auth.json
"deepseek" scope, base https://api.deepseek.com (chat rides
{base}/chat/completions per official docs) with KIGI_DEEPSEEK_BASE_URL
override, enrichment-backed metadata (1M context, 384k output cap,
high/max effort menu).

Structural fix the cycle exposed: kigi's Kimi-specific body adaptation
ran UNCONDITIONALLY on every ChatCompletions request. New ChatCompat
dialect, declared per platform row and threaded through SamplerConfig,
ClientDefaults, and the session-persisted SamplingConfig (serde-default
Kimi keeps restored pre-field sessions and BYOK endpoints byte-identical;
production persist seams copy it; subagents inherit it):
- Kimi: full legacy pipeline (dispatch ≡ legacy pinned)
- DeepSeek: thinking:{type, reasoning_effort} per api-docs.deepseek.com
  (server maps low/medium→high, xhigh→max itself; none disables; absent
  leaves the server default)
- Passthrough: OpenAI-style reasoning_effort scalar untouched (unblocks
  Groq and the rest of the OpenAI-compatible list)

Review-confirmed release blocker fixed: kigi replays Kimi's
reasoning_content (and its private model_id) on input assistant
messages — Kimi consumes these, but DeepSeek documents input
reasoning_content as prefix-mode-only (historically a 400) and other
providers don't know either field. The DeepSeek and Passthrough arms now
strip both; Kimi's own pipeline is untouched. Pinned on both message
shapes.
2026-07-21 07:21:05 -04:00

62 lines
2.2 KiB
Rust

//! Shared helpers for kigi-shell integration tests.
use kigi_shell::sampling::{ApiBackend, Client, SamplerConfig};
/// Create a sampling client configured for a mock server. Shared by the
/// integration tests so the ~30-field `SamplerConfig` literal lives in one
/// place (`SamplerConfig` has no `Default`).
pub fn create_test_client(base_url: &str, api_backend: ApiBackend) -> Client {
create_test_client_with_extra_headers(base_url, api_backend, &[])
}
/// Like [`create_test_client`] but seeds `SamplerConfig::extra_headers`, so a
/// test can assert that session-injected headers reach the wire.
pub fn create_test_client_with_extra_headers(
base_url: &str,
api_backend: ApiBackend,
extra_headers: &[(&str, &str)],
) -> Client {
Client::new(test_sampler_config(base_url, api_backend, extra_headers)).unwrap()
}
/// The shared mock-server `SamplerConfig`; tests needing a non-default field
/// (e.g. `doom_loop_recovery`) mutate the returned value before building the
/// client themselves.
pub fn test_sampler_config(
base_url: &str,
api_backend: ApiBackend,
extra_headers: &[(&str, &str)],
) -> SamplerConfig {
// Shell `Client` is `kigi_sampler::SamplingClient`, which takes a
// `SamplerConfig` directly. Construct one inline here.
SamplerConfig {
api_key: Some("test-api-key".to_string()),
base_url: base_url.to_string(),
model: "test-model".to_string(),
max_completion_tokens: Some(1000),
temperature: Some(0.7),
top_p: None,
api_backend,
auth_scheme: Default::default(),
chat_compat: Default::default(),
extra_headers: extra_headers
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect(),
context_window: 256_000,
force_http1: false,
max_retries: None,
stream_tool_calls: false,
idle_timeout_secs: None,
reasoning_effort: None,
origin_client: None,
attribution_callback: None,
bearer_resolver: None,
supports_backend_search: false,
compactions_remaining: None,
compaction_at_tokens: None,
doom_loop_recovery: None,
header_injector: None,
}
}