feat: migrate gateway to nestjs

This commit is contained in:
Draculabo committed 2025-12-24 23:26:55 +08:00
1 parent c4a0fa773f
commit e7087bc4b1
18 files changed
+2182 -1161

No files matched your search

@@ -0,0 +1,141 @@
export interface OpenAIChatRequest {
model: string;
messages: OpenAIMessage[];
temperature?: number;
top_p?: number;
max_tokens?: number;
stream?: boolean;
size?: string;
quality?: string;
extra?: Record<string, any>;
}
export interface OpenAIMessage {
role: string;
content: string | OpenAIContentPart[];
name?: string;
}
export interface OpenAIContentPart {
type: 'text' | 'image_url';
text?: string;
image_url?: {
url: string;
};
}
export interface AnthropicChatRequest {
model: string;
messages: AnthropicMessage[];
system?: string | AnthropicSystemBlock[];
max_tokens?: number;
metadata?: any;
stop_sequences?: string[];
stream?: boolean;
temperature?: number;
top_p?: number;
top_k?: number;
}
export interface AnthropicMessage {
role: string;
content: string | AnthropicContent[];
}
export interface AnthropicSystemBlock {
type: string;
text: string;
}
export type AnthropicContent =
| { type: 'text'; text: string }
| { type: 'thinking'; thinking: string; signature?: string }
| { type: 'image'; source: AnthropicImageSource };
export interface AnthropicImageSource {
type: 'base64';
media_type: string;
data: string;
}
export interface GeminiContent {
role: string;
parts: GeminiPart[];
}
export interface GeminiPart {
text?: string;
inlineData?: GeminiInlineData;
thoughtSignature?: string;
}
export interface GeminiInlineData {
mimeType: string;
data: string;
}
export interface GeminiRequest {
contents: GeminiContent[];
systemInstruction?: { parts: GeminiPart[] };
generationConfig?: GeminiGenerationConfig;
}
export interface GeminiGenerationConfig {
temperature?: number;
maxOutputTokens?: number;
topP?: number;
topK?: number;
}
export interface GeminiResponse {
candidates?: GeminiCandidate[];
usageMetadata?: GeminiUsageMetadata;
}
export interface GeminiCandidate {
content?: GeminiContent;
finishReason?: string;
index?: number;
}
export interface GeminiUsageMetadata {
promptTokenCount?: number;
candidatesTokenCount?: number;
totalTokenCount?: number;
}
export interface OpenAIChatResponse {
id: string;
object: string;
created: number;
model: string;
choices: OpenAIChoice[];
usage: {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
}
export interface OpenAIChoice {
index: number;
message: {
role: string;
content: string;
};
finish_reason: string;
}
export interface AnthropicChatResponse {
id: string;
type: string;
role: string;
model: string;
content: AnthropicContent[];
stop_reason: string | null;
stop_sequence: string | null;
usage: {
input_tokens: number;
output_tokens: number;
};
}