@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/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Tool parameters are Zod schemas. Converted to JSON Schema at the provider bounda
|
|
|
43
43
|
| `anthropic` | Claude Opus 4.8, Sonnet 5, Haiku 4.5 | Extended thinking, prompt caching, server-side compaction |
|
|
44
44
|
| `openai` | GPT-4.1, o3, o4-mini | Supports OAuth (codex endpoint) and API keys |
|
|
45
45
|
| `glm` | GLM-5.1, GLM-4.7 | Z.AI platform, OpenAI-compatible |
|
|
46
|
-
| `moonshot` | Kimi K2.7 | Moonshot platform, OpenAI-compatible |
|
|
46
|
+
| `moonshot` | Kimi K3, Kimi K2.7 Code | Moonshot platform, OpenAI-compatible |
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
package/dist/index.cjs
CHANGED
|
@@ -1892,7 +1892,11 @@ async function* runStream2(options) {
|
|
|
1892
1892
|
const providerName = options.provider ?? "openai";
|
|
1893
1893
|
const useStreaming = options.streaming !== false;
|
|
1894
1894
|
const client = createClient2(options);
|
|
1895
|
-
const
|
|
1895
|
+
const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
|
|
1896
|
+
const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
|
|
1897
|
+
const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
|
|
1898
|
+
const hasFixedKimiSampling = isKimiK3 || isKimiK27;
|
|
1899
|
+
const usesThinkingParam = options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
|
|
1896
1900
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
1897
1901
|
const downgradedMessages = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
|
|
1898
1902
|
if (options.provider === "moonshot") {
|
|
@@ -1904,7 +1908,9 @@ async function* runStream2(options) {
|
|
|
1904
1908
|
}
|
|
1905
1909
|
const messages = toOpenAIMessages(downgradedMessages, {
|
|
1906
1910
|
provider: options.provider,
|
|
1907
|
-
|
|
1911
|
+
// K3 and K2.7 preserve reasoning even when the user hides thinking in the
|
|
1912
|
+
// UI; keep assistant tool-call history wire-valid in that display mode.
|
|
1913
|
+
thinking: isKimiK3 || isKimiK27 || !!options.thinking,
|
|
1908
1914
|
supportsImages: options.supportsImages
|
|
1909
1915
|
});
|
|
1910
1916
|
const defaultTemp = options.provider === "glm" ? 0.6 : void 0;
|
|
@@ -1914,10 +1920,10 @@ async function* runStream2(options) {
|
|
|
1914
1920
|
messages,
|
|
1915
1921
|
stream: useStreaming,
|
|
1916
1922
|
...options.maxTokens ? { max_completion_tokens: options.maxTokens } : {},
|
|
1917
|
-
...effectiveTemp != null && !options.thinking ? { temperature: effectiveTemp } : {},
|
|
1918
|
-
...options.topP != null ? { top_p: options.topP } : {},
|
|
1923
|
+
...effectiveTemp != null && !options.thinking && !hasFixedKimiSampling ? { temperature: effectiveTemp } : {},
|
|
1924
|
+
...options.topP != null && !hasFixedKimiSampling ? { top_p: options.topP } : {},
|
|
1919
1925
|
...options.stop ? { stop: options.stop } : {},
|
|
1920
|
-
...options.thinking && !usesThinkingParam ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
|
|
1926
|
+
...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
|
|
1921
1927
|
...options.tools?.length ? { tools: toOpenAITools(options.tools) } : {},
|
|
1922
1928
|
...options.toolChoice && options.tools?.length ? { tool_choice: toOpenAIToolChoice(options.toolChoice) } : {},
|
|
1923
1929
|
...useStreaming ? { stream_options: { include_usage: true } } : {}
|
|
@@ -1927,13 +1933,21 @@ async function* runStream2(options) {
|
|
|
1927
1933
|
paramsAny.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ggcoder");
|
|
1928
1934
|
if (options.provider === "openai" && options.model.startsWith("gpt-5.6")) {
|
|
1929
1935
|
paramsAny.prompt_cache_options = { mode: "implicit", ttl: "30m" };
|
|
1930
|
-
} else if ((options.cacheRetention ?? "short") === "long") {
|
|
1936
|
+
} else if (!isKimiK3 && (options.cacheRetention ?? "short") === "long") {
|
|
1931
1937
|
paramsAny.prompt_cache_retention = "24h";
|
|
1932
1938
|
}
|
|
1933
1939
|
}
|
|
1934
1940
|
if (options.provider === "openai" && options.serviceTier) {
|
|
1935
1941
|
params.service_tier = options.serviceTier;
|
|
1936
1942
|
}
|
|
1943
|
+
if (isKimiK3) {
|
|
1944
|
+
const paramsAny = params;
|
|
1945
|
+
if (isManagedKimiK3) {
|
|
1946
|
+
paramsAny.thinking = { type: "enabled", effort: "max", keep: "all" };
|
|
1947
|
+
} else {
|
|
1948
|
+
paramsAny.reasoning_effort = "max";
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1937
1951
|
if (usesThinkingParam) {
|
|
1938
1952
|
if (options.thinking) {
|
|
1939
1953
|
params.thinking = { type: "enabled" };
|