| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- import { ContentItem, OutputText, Refusal } from "../foundation";
- export interface ChatCompletion {
- id?: string;
- object?: string;
- created?: number;
- model?: string;
- choices?: Choice[];
- usage?: Usage;
- service_tier?: string;
- system_fingerprint?: string
- }
- export interface ChatCompletionChunk {
- id?: string;
- object?: string;
- created?: number;
- model?: string;
- choices?: ChoiceChunk[];
- usage?: Usage;
- service_tier?: string;
- system_fingerprint?: string
- }
- export interface Choice {
- index?: number;
- message?: ChatCompletionMessage;
- logprobs?: Logprobs;
- finish_reason?: string
- }
- export interface ChoiceChunk {
- index?: number;
- delta?: Delta;
- logprobs?: Logprobs;
- finish_reason?: string
- }
- export interface Delta {
- role?: string;
- content?: string;
- refusal?: string;
- function_call?: FunctionCall;
- tool_calls?: ChatCompletionToolCall[]
- }
- interface ChatCompletionMessage {
- role?: string;
- content?: string;
- refusal?: string;
- annotations?: ChatCompletionAnnotation[];
- audio?: Audio;
- function_call?: FunctionCall;
- tool_calls?: ChatCompletionToolCalls[]
- }
- export type ChatCompletionToolCalls = ChatCompletionToolCall | ChatCompletionCustomToolCall
- interface ChatCompletionAnnotation {
- type?: string;
- url_citation?: URLCitation
- }
- interface URLCitation {
- end_index?: number;
- start_index?: number;
- title?: string;
- url?: string
- }
- interface Audio {
- data: string;
- expires_at?: number;
- id?: string;
- transcript?: string
- }
- interface FunctionCall {
- name?: string;
- arguments?: string
- }
- interface ToolCall {
- input?: string;
- name?: string
- }
- export interface ChatCompletionToolCall {
- id?: string;
- index?: number;
- type?: string;
- function?: FunctionCall;
- custom?: ToolCall
- }
- export interface ChatCompletionCustomToolCall {
- id?: string;
- type?: string;
- custom?: ToolCall
- }
- interface Logprobs {
- content?: LogprobsContent[];
- refusal?: LogprobsContent[]
- }
- interface LogprobsContent {
- bytes?: number[];
- logprob?: number;
- token?: string;
- top_logprobs?: LogprobsContent[]
- }
- interface Usage {
- prompt_tokens?: number;
- completion_tokens?: number;
- total_tokens?: number;
- completion_tokens_details?: CompletionTokensDetails;
- prompt_tokens_details?: PromptTokensDetails
- }
- interface CompletionTokensDetails {
- reasoning_tokens?: number;
- audio_tokens?: number;
- accepted_prediction_tokens?: number;
- rejected_prediction_tokens?: number
- }
- interface PromptTokensDetails {
- cached_tokens?: number;
- audio_tokens?: number
- }
- export interface Response {
- id?: string;
- created_at?: number;
- error?: ResponseError;
- incomplete_details?: {
- reason: string
- };
- max_output_tokens?: number;
- max_tool_calls?: number;
- model?: string;
- object?: string;
- output?: ContentItem | ContentItem[];
- output_text?: string;
- parallel_tool_calls?: boolean;
- previous_response_id?: string;
- reasoning?: ResponseReasoning;
- safety_identifier?: string;
- status?: string;
- temperature?: number;
- top_logprobs?: number;
- top_p?: number;
- truncation?: string;
- [x: string]: any
- }
- export interface ResponseError {
- code?: string;
- message?: string
- }
- interface ResponseReasoning {
- effort?: string;
- generate_summary?: string;
- summary?: string
- }
- export interface ResponseChunk {
- type?: string;
- response?: Response;
- sequence_number?: number;
- output_index?: number;
- item?: ContentItem;
- content_index?: number;
- item_id?: string;
- part?: OutputText | Refusal | ReasoningText;
- delta?: string;
- refusal?: string;
- name?: string;
- arguments?: string;
- summary_index?: number;
- text?: string;
- code?: string;
- message?: string;
- param?: string;
- [x: string]: any
- }
- interface ReasoningText {
- text?: string;
- type?: string
- }
- export interface CodeInterpreterCall {
- code?: string;
- status?: string;
- outputs?: {
- logs?: string;
- url?: string;
- type?: string
- }[];
- id?: string;
- container_id?: string;
- type?: string
- }
- export interface ImageGenerationCall {
- id?: string;
- result?: string;
- status?: string;
- type?: string
- }
- // chat completion input
- export interface ChatCompletionInput {
- messages?: ChatCompletionInputMessage[];
- model?: string;
- audio?: {
- format: string;
- voice: string
- };
- function_call?: string | { name: string };
- functions?: { name: string; description: string }[];
- n?: number;
- modalities?: string[];
- [x: string]: any
- }
- export type ChatCompletionInputMessage = DeveloperMessage | SystemMessage | UserMessage | AssistantMessage | ToolMessage | FunctionMessage;
- interface CommonInputItem {
- role?: string;
- name?: string
- }
- interface DeveloperMessage extends CommonInputItem {
- content?: string | { type: string; text: string }[]
- }
- interface SystemMessage extends CommonInputItem {
- content?: string | any[]
- }
- export interface UserMessage extends CommonInputItem {
- content?: string | (ImageContentPart | AudioContentPart | FileContentPart | TextInput)[]
- }
- export interface TextInput {
- text?: string;
- type?: string
- }
- export interface ImageContentPart {
- image_url?: {
- url?: string;
- detail?: string
- };
- type?: string
- }
- export interface AudioContentPart {
- input_audio?: {
- data?: string;
- format?: string
- };
- type?: string
- }
- export interface FileContentPart {
- file?: {
- file_data?: string;
- file_id?: string;
- filename?: string
- };
- type?: string
- }
- interface AssistantMessage extends CommonInputItem {
- audio?: { id: string };
- content?: string | (OutputText | Refusal)[];
- function_call?: { name: string; arguments: string };
- name?: string;
- refusal?: string;
- tool_calls?: (ChatCompletionToolCall | ChatCompletionCustomToolCall)[]
- }
- interface ToolMessage extends CommonInputItem {
- content?: string | any[]
- }
- interface FunctionMessage extends CommonInputItem {
- content?: string
- }
- export interface StreamingResponseState {
- processedSeq: Set<number>;
- outputs: Map<number, ContentItem | null>;
- meta: {
- id?: string;
- model?: string;
- status?: string;
- created_at?: number
- };
- error?: ResponseError;
- buffer: Map<number, ResponseChunk>;
- lastProcessedSeq: number
- }
|