mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-17 01:04:39 +00:00
- Copy all pi-mono source into apps/companion-os/ - Update Dockerfile to COPY pre-built binary instead of downloading from GitHub Releases - Update deploy-staging.yml to build pi from source (bun compile) before Docker build - Add apps/companion-os/** to path triggers - No more cross-repo dispatch needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import type {
|
|
Api,
|
|
Model,
|
|
SimpleStreamOptions,
|
|
StreamOptions,
|
|
ThinkingBudgets,
|
|
ThinkingLevel,
|
|
} from "../types.js";
|
|
|
|
export function buildBaseOptions(
|
|
model: Model<Api>,
|
|
options?: SimpleStreamOptions,
|
|
apiKey?: string,
|
|
): StreamOptions {
|
|
return {
|
|
temperature: options?.temperature,
|
|
maxTokens: options?.maxTokens || Math.min(model.maxTokens, 32000),
|
|
signal: options?.signal,
|
|
apiKey: apiKey || options?.apiKey,
|
|
cacheRetention: options?.cacheRetention,
|
|
sessionId: options?.sessionId,
|
|
headers: options?.headers,
|
|
onPayload: options?.onPayload,
|
|
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
metadata: options?.metadata,
|
|
};
|
|
}
|
|
|
|
export function clampReasoning(
|
|
effort: ThinkingLevel | undefined,
|
|
): Exclude<ThinkingLevel, "xhigh"> | undefined {
|
|
return effort === "xhigh" ? "high" : effort;
|
|
}
|
|
|
|
export function adjustMaxTokensForThinking(
|
|
baseMaxTokens: number,
|
|
modelMaxTokens: number,
|
|
reasoningLevel: ThinkingLevel,
|
|
customBudgets?: ThinkingBudgets,
|
|
): { maxTokens: number; thinkingBudget: number } {
|
|
const defaultBudgets: ThinkingBudgets = {
|
|
minimal: 1024,
|
|
low: 2048,
|
|
medium: 8192,
|
|
high: 16384,
|
|
};
|
|
const budgets = { ...defaultBudgets, ...customBudgets };
|
|
|
|
const minOutputTokens = 1024;
|
|
const level = clampReasoning(reasoningLevel)!;
|
|
let thinkingBudget = budgets[level]!;
|
|
const maxTokens = Math.min(baseMaxTokens + thinkingBudget, modelMaxTokens);
|
|
|
|
if (maxTokens <= thinkingBudget) {
|
|
thinkingBudget = Math.max(0, maxTokens - minOutputTokens);
|
|
}
|
|
|
|
return { maxTokens, thinkingBudget };
|
|
}
|