summaryrefslogtreecommitdiff
path: root/src/types/index.ts
blob: b27645758cf98248a3bd505d9c7a4322cf7bffe8 (plain)
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
import type OpenAI from "openai";
import type { AsyncRes } from "sortug";
export type ChatMessage = {
  author: string;
  text: string;
  sent: number;
  reasoning?: string;
};

// openai
export type OChoice = OpenAI.Chat.Completions.ChatCompletion.Choice;
export type OChunk = OpenAI.Chat.Completions.ChatCompletionChunk.Choice;
export type OMessage = OpenAI.Chat.Completions.ChatCompletionMessageParam;
export type ContentType = { text: string } | { audio: Response };
export type AIModelChoice =
  | { name: "deepseek" | "chatgpt" | "claude" | "gemini" | "grok" }
  | { other: { baseURL: string; apiKey: string } };
export interface AIModelAPI {
  setModel: (model: string) => void;
  tokenizer: (text: string) => number;
  maxTokens: number;

  send: (systemPrompt: string, input: ChatMessage[]) => AsyncRes<string[]>;
  stream: (
    systemPrompt: string,
    input: ChatMessage[],
    handler: (data: any) => void,
  ) => void;
}