| 1 | import { |
| 2 | ChatCompletion, |
| 3 | ChatCompletionChunk, |
| 4 | ChatCompletionCreateParamsNonStreaming, |
| 5 | ChatCompletionCreateParamsStreaming, |
| 6 | Completion, |
| 7 | CompletionCreateParamsNonStreaming, |
| 8 | CompletionCreateParamsStreaming, |
| 9 | CreateEmbeddingResponse, |
| 10 | EmbeddingCreateParams, |
| 11 | Model, |
| 12 | } from "openai/resources/index"; |
| 13 | |
| 14 | export interface FimCreateParamsStreaming |
| 15 | extends CompletionCreateParamsStreaming { |
| 16 | suffix: string; |
| 17 | } |
| 18 | |
| 19 | export interface RerankCreateParams { |
| 20 | query: string; |
| 21 | documents: string[]; |
| 22 | model: string; |
| 23 | top_k?: number; |
| 24 | } |
| 25 | |
| 26 | export interface CreateRerankItem { |
| 27 | relevance_score: number; |
| 28 | index: number; |
| 29 | } |
| 30 | |
| 31 | export interface CreateRerankResponse { |
| 32 | object: "list"; |
| 33 | data: CreateRerankItem[]; |
| 34 | model: string; |
| 35 | usage: { |
| 36 | total_tokens: number; |
| 37 | }; |
| 38 | } |
| 39 | |
| 40 | export interface BaseLlmApi { |
| 41 | // Chat, no stream |
| 42 | chatCompletionNonStream( |
| 43 | body: ChatCompletionCreateParamsNonStreaming, |
| 44 | signal: AbortSignal, |
| 45 | ): Promise<ChatCompletion>; |
| 46 | |
| 47 | // Chat, stream |
| 48 | chatCompletionStream( |
| 49 | body: ChatCompletionCreateParamsStreaming, |
| 50 | signal: AbortSignal, |
| 51 | ): AsyncGenerator<ChatCompletionChunk>; |
| 52 | |
| 53 | // Completion, no stream |
| 54 | completionNonStream( |
| 55 | body: CompletionCreateParamsNonStreaming, |
| 56 | signal: AbortSignal, |
| 57 | ): Promise<Completion>; |
| 58 | |
| 59 | // Completion, stream |
| 60 | completionStream( |
| 61 | body: CompletionCreateParamsStreaming, |
| 62 | signal: AbortSignal, |
| 63 | ): AsyncGenerator<Completion>; |
| 64 | |
| 65 | // FIM, stream |
| 66 | fimStream( |
| 67 | body: FimCreateParamsStreaming, |
| 68 | signal: AbortSignal, |
| 69 | ): AsyncGenerator<ChatCompletionChunk>; |
| 70 | |
| 71 | // Embeddings |
| 72 | embed(body: EmbeddingCreateParams): Promise<CreateEmbeddingResponse>; |
| 73 | |
| 74 | // Reranking |
| 75 | rerank(body: RerankCreateParams): Promise<CreateRerankResponse>; |
| 76 | |
| 77 | // List Models |
| 78 | list(): Promise<Model[]>; |
| 79 | } |