@kenkaiiii/gg-ai 5.17.0 → 5.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +20 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1832,7 +1832,11 @@ async function* runStream2(options) {
|
|
|
1832
1832
|
const providerName = options.provider ?? "openai";
|
|
1833
1833
|
const useStreaming = options.streaming !== false;
|
|
1834
1834
|
const client = createClient2(options);
|
|
1835
|
-
const
|
|
1835
|
+
const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
|
|
1836
|
+
const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
|
|
1837
|
+
const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
|
|
1838
|
+
const hasFixedKimiSampling = isKimiK3 || isKimiK27;
|
|
1839
|
+
const usesThinkingParam = options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
|
|
1836
1840
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
1837
1841
|
const downgradedMessages = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
|
|
1838
1842
|
if (options.provider === "moonshot") {
|
|
@@ -1844,7 +1848,9 @@ async function* runStream2(options) {
|
|
|
1844
1848
|
}
|
|
1845
1849
|
const messages = toOpenAIMessages(downgradedMessages, {
|
|
1846
1850
|
provider: options.provider,
|
|
1847
|
-
|
|
1851
|
+
// K3 and K2.7 preserve reasoning even when the user hides thinking in the
|
|
1852
|
+
// UI; keep assistant tool-call history wire-valid in that display mode.
|
|
1853
|
+
thinking: isKimiK3 || isKimiK27 || !!options.thinking,
|
|
1848
1854
|
supportsImages: options.supportsImages
|
|
1849
1855
|
});
|
|
1850
1856
|
const defaultTemp = options.provider === "glm" ? 0.6 : void 0;
|
|
@@ -1854,10 +1860,10 @@ async function* runStream2(options) {
|
|
|
1854
1860
|
messages,
|
|
1855
1861
|
stream: useStreaming,
|
|
1856
1862
|
...options.maxTokens ? { max_completion_tokens: options.maxTokens } : {},
|
|
1857
|
-
...effectiveTemp != null && !options.thinking ? { temperature: effectiveTemp } : {},
|
|
1858
|
-
...options.topP != null ? { top_p: options.topP } : {},
|
|
1863
|
+
...effectiveTemp != null && !options.thinking && !hasFixedKimiSampling ? { temperature: effectiveTemp } : {},
|
|
1864
|
+
...options.topP != null && !hasFixedKimiSampling ? { top_p: options.topP } : {},
|
|
1859
1865
|
...options.stop ? { stop: options.stop } : {},
|
|
1860
|
-
...options.thinking && !usesThinkingParam ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
|
|
1866
|
+
...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
|
|
1861
1867
|
...options.tools?.length ? { tools: toOpenAITools(options.tools) } : {},
|
|
1862
1868
|
...options.toolChoice && options.tools?.length ? { tool_choice: toOpenAIToolChoice(options.toolChoice) } : {},
|
|
1863
1869
|
...useStreaming ? { stream_options: { include_usage: true } } : {}
|
|
@@ -1867,13 +1873,21 @@ async function* runStream2(options) {
|
|
|
1867
1873
|
paramsAny.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ggcoder");
|
|
1868
1874
|
if (options.provider === "openai" && options.model.startsWith("gpt-5.6")) {
|
|
1869
1875
|
paramsAny.prompt_cache_options = { mode: "implicit", ttl: "30m" };
|
|
1870
|
-
} else if ((options.cacheRetention ?? "short") === "long") {
|
|
1876
|
+
} else if (!isKimiK3 && (options.cacheRetention ?? "short") === "long") {
|
|
1871
1877
|
paramsAny.prompt_cache_retention = "24h";
|
|
1872
1878
|
}
|
|
1873
1879
|
}
|
|
1874
1880
|
if (options.provider === "openai" && options.serviceTier) {
|
|
1875
1881
|
params.service_tier = options.serviceTier;
|
|
1876
1882
|
}
|
|
1883
|
+
if (isKimiK3) {
|
|
1884
|
+
const paramsAny = params;
|
|
1885
|
+
if (isManagedKimiK3) {
|
|
1886
|
+
paramsAny.thinking = { type: "enabled", effort: "max", keep: "all" };
|
|
1887
|
+
} else {
|
|
1888
|
+
paramsAny.reasoning_effort = "max";
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1877
1891
|
if (usesThinkingParam) {
|
|
1878
1892
|
if (options.thinking) {
|
|
1879
1893
|
params.thinking = { type: "enabled" };
|