feat: implement protocol parity and harden upstream handling (#88)
* feat: implement protocol parity and harden upstream handling * docs(agents): add lodash-es utility method and named import guideline
This commit is contained in:
23 files changed
+4408
-654
No files matched your search
@@ -7,13 +7,18 @@ export interface OpenAIChatRequest {
|
||||
stream?: boolean;
|
||||
size?: string;
|
||||
quality?: string;
|
||||
extra?: Record<string, any>;
|
||||
tools?: OpenAITool[];
|
||||
tool_choice?: string | { type: string; function?: { name: string } };
|
||||
response_format?: { type?: string };
|
||||
extra?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface OpenAIMessage {
|
||||
role: string;
|
||||
content: string | OpenAIContentPart[];
|
||||
name?: string;
|
||||
tool_calls?: OpenAIToolCall[];
|
||||
tool_call_id?: string;
|
||||
}
|
||||
|
||||
export interface OpenAIContentPart {
|
||||
@@ -24,12 +29,32 @@ export interface OpenAIContentPart {
|
||||
};
|
||||
}
|
||||
|
||||
export interface OpenAITool {
|
||||
type: 'function';
|
||||
function: {
|
||||
name: string;
|
||||
description?: string;
|
||||
parameters?: Record<string, unknown>;
|
||||
};
|
||||
}
|
||||
|
||||
export interface OpenAIToolCall {
|
||||
id: string;
|
||||
type: 'function';
|
||||
function: {
|
||||
name: string;
|
||||
arguments: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AnthropicChatRequest {
|
||||
model: string;
|
||||
messages: AnthropicMessage[];
|
||||
system?: string | AnthropicSystemBlock[];
|
||||
max_tokens?: number;
|
||||
metadata?: any;
|
||||
tools?: AnthropicTool[];
|
||||
thinking?: AnthropicThinkingConfig;
|
||||
metadata?: Record<string, unknown>;
|
||||
stop_sequences?: string[];
|
||||
stream?: boolean;
|
||||
temperature?: number;
|
||||
@@ -37,6 +62,18 @@ export interface AnthropicChatRequest {
|
||||
top_k?: number;
|
||||
}
|
||||
|
||||
export interface AnthropicTool {
|
||||
name: string;
|
||||
description?: string;
|
||||
input_schema?: Record<string, unknown>;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface AnthropicThinkingConfig {
|
||||
type: 'enabled' | string;
|
||||
budget_tokens?: number;
|
||||
}
|
||||
|
||||
export interface AnthropicMessage {
|
||||
role: string;
|
||||
content: string | AnthropicContent[];
|
||||
@@ -50,7 +87,21 @@ export interface AnthropicSystemBlock {
|
||||
export type AnthropicContent =
|
||||
| { type: 'text'; text: string }
|
||||
| { type: 'thinking'; thinking: string; signature?: string }
|
||||
| { type: 'image'; source: AnthropicImageSource };
|
||||
| { type: 'image'; source: AnthropicImageSource }
|
||||
| {
|
||||
type: 'tool_use';
|
||||
id: string;
|
||||
name: string;
|
||||
input: Record<string, unknown>;
|
||||
signature?: string;
|
||||
}
|
||||
| {
|
||||
type: 'tool_result';
|
||||
tool_use_id: string;
|
||||
content: string | AnthropicContent[];
|
||||
is_error?: boolean;
|
||||
}
|
||||
| { type: 'redacted_thinking'; data: string };
|
||||
|
||||
export interface AnthropicImageSource {
|
||||
type: 'base64';
|
||||
@@ -102,6 +153,16 @@ export interface GeminiUsageMetadata {
|
||||
promptTokenCount?: number;
|
||||
candidatesTokenCount?: number;
|
||||
totalTokenCount?: number;
|
||||
thoughtsTokenCount?: number;
|
||||
promptTokensDetails?: Array<{
|
||||
modality?: string;
|
||||
tokenCount?: number;
|
||||
}>;
|
||||
candidatesTokensDetails?: Array<{
|
||||
modality?: string;
|
||||
tokenCount?: number;
|
||||
}>;
|
||||
trafficType?: string;
|
||||
}
|
||||
|
||||
export interface OpenAIChatResponse {
|
||||
@@ -121,9 +182,11 @@ export interface OpenAIChoice {
|
||||
index: number;
|
||||
message: {
|
||||
role: string;
|
||||
content: string;
|
||||
content: string | null;
|
||||
tool_calls?: OpenAIToolCall[];
|
||||
reasoning_content?: string;
|
||||
};
|
||||
finish_reason: string;
|
||||
finish_reason: string | null;
|
||||
}
|
||||
|
||||
export interface AnthropicChatResponse {
|
||||
@@ -133,9 +196,11 @@ export interface AnthropicChatResponse {
|
||||
model: string;
|
||||
content: AnthropicContent[];
|
||||
stop_reason: string | null;
|
||||
stop_sequence: string | null;
|
||||
stop_sequence?: string | null;
|
||||
usage: {
|
||||
input_tokens: number;
|
||||
output_tokens: number;
|
||||
cache_creation_input_tokens?: number;
|
||||
cache_read_input_tokens?: number;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user