* improv: eslint config * chore: temporarily disable rules * fix: negated conditions * improv: disable linting when testing * fix: too many parameters errors * fix: complexity errors * fix: complexity * fix: complexity * fix: complexity * fix: complexity * fix: unused imports * fix: imports * fix: complexity * fix: complexity * fix: linter errors * fix: complexity * fix: linter errors * fix: linter errors * fix: complexity * fix: linter errors * fix: linter errors * fix: complexity * fix: imports * fix: complexity * fix: complexity * fix: type errors * fix: lint * fix: lint * fix: file length * fix: lint * fix: failing tests * fix: prettier
31 lines
990 B
TypeScript
31 lines
990 B
TypeScript
import { CompletionOptions } from "@continuedev/config-yaml";
|
|
import type { ChatCompletionCreateParamsStreaming } from "openai/resources.mjs";
|
|
|
|
import { ToolCallPreview } from "./tools/types.js";
|
|
|
|
export interface StreamCallbacks {
|
|
onContent?: (content: string) => void;
|
|
onContentComplete?: (content: string) => void;
|
|
onToolStart?: (toolName: string, toolArgs?: any) => void;
|
|
onToolResult?: (result: string, toolName: string) => void;
|
|
onToolError?: (error: string, toolName?: string) => void;
|
|
onToolPermissionRequest?: (
|
|
toolName: string,
|
|
toolArgs: any,
|
|
requestId: string,
|
|
preview?: ToolCallPreview[],
|
|
) => void;
|
|
}
|
|
|
|
export function getDefaultCompletionOptions(
|
|
opts?: CompletionOptions,
|
|
): Partial<ChatCompletionCreateParamsStreaming> {
|
|
if (!opts) return {};
|
|
return {
|
|
max_tokens: opts.maxTokens,
|
|
temperature: opts.temperature,
|
|
frequency_penalty: opts.frequencyPenalty,
|
|
presence_penalty: opts.presencePenalty,
|
|
top_p: opts.topP,
|
|
};
|
|
}
|