File size: 2,244 Bytes
0eedb5a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
// OpenAI API Types
export interface ChatCompletionMessage {
role: "system" | "user" | "assistant" | "tool";
content: string | null;
name?: string;
tool_calls?: ToolCall[];
tool_call_id?: string;
}
export interface FunctionDefinition {
name: string;
description?: string;
parameters?: {
type: "object";
properties: Record<string, any>;
required?: string[];
};
}
export interface ToolDefinition {
type: "function";
function: FunctionDefinition;
}
export interface ToolCall {
id: string;
type: "function";
function: {
name: string;
arguments: string;
};
}
export type ToolChoice =
| "none"
| "auto"
| "required"
| { type: "function"; function: { name: string } };
export interface ChatCompletionRequest {
model: string;
messages: ChatCompletionMessage[];
temperature?: number;
max_tokens?: number;
stream?: boolean;
top_p?: number;
frequency_penalty?: number;
presence_penalty?: number;
stop?: string | string[];
tools?: ToolDefinition[];
tool_choice?: ToolChoice;
}
export interface ChatCompletionChoice {
index: number;
message: ChatCompletionMessage;
finish_reason: "stop" | "length" | "content_filter" | "tool_calls" | null;
}
export interface ChatCompletionResponse {
id: string;
object: "chat.completion";
created: number;
model: string;
choices: ChatCompletionChoice[];
usage: {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
}
export interface ChatCompletionStreamChoice {
index: number;
delta: {
role?: "assistant";
content?: string;
tool_calls?: ToolCall[];
};
finish_reason: "stop" | "length" | "content_filter" | "tool_calls" | null;
}
export interface ChatCompletionStreamResponse {
id: string;
object: "chat.completion.chunk";
created: number;
model: string;
choices: ChatCompletionStreamChoice[];
}
export interface Model {
id: string;
object: "model";
created: number;
owned_by: string;
}
export interface ModelsResponse {
object: "list";
data: Model[];
}
// Duck.ai specific types
export interface VQDResponse {
vqd: string;
hash: string;
}
export interface DuckAIRequest {
model: string;
messages: ChatCompletionMessage[];
}
|