|
1 | 1 | // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. |
2 | 2 |
|
3 | | -import type { |
4 | | - AIMessage, |
5 | | - AIRequestOptions, |
6 | | - AIResult, |
7 | | - AIStreamEvent, |
8 | | -} from '@objectstack/spec/contracts'; |
9 | | - |
10 | | -/** |
11 | | - * LLM Provider Adapter Interface |
12 | | - * |
13 | | - * Adapters translate between the ObjectStack AI protocol and concrete |
14 | | - * LLM provider SDKs (OpenAI, Anthropic, Ollama, etc.). |
15 | | - * |
16 | | - * Each adapter is a thin wrapper — all orchestration, conversation |
17 | | - * management, and tool execution logic lives in the AI service layer. |
18 | | - */ |
19 | | -export interface LLMAdapter { |
20 | | - /** Unique adapter identifier (e.g. 'openai', 'anthropic', 'memory') */ |
21 | | - readonly name: string; |
22 | | - |
23 | | - /** |
24 | | - * Generate a chat completion. |
25 | | - * @param messages - Conversation messages |
26 | | - * @param options - Request configuration (includes tool definitions) |
27 | | - */ |
28 | | - chat(messages: AIMessage[], options?: AIRequestOptions): Promise<AIResult>; |
29 | | - |
30 | | - /** |
31 | | - * Generate a text completion from a single prompt. |
32 | | - * @param prompt - Input prompt string |
33 | | - * @param options - Request configuration |
34 | | - */ |
35 | | - complete(prompt: string, options?: AIRequestOptions): Promise<AIResult>; |
36 | | - |
37 | | - /** |
38 | | - * Stream a chat completion as an async iterable of events. |
39 | | - * Implementations that do not support streaming may omit this method. |
40 | | - */ |
41 | | - streamChat?(messages: AIMessage[], options?: AIRequestOptions): AsyncIterable<AIStreamEvent>; |
42 | | - |
43 | | - /** |
44 | | - * Generate embedding vectors. |
45 | | - */ |
46 | | - embed?(input: string | string[], model?: string): Promise<number[][]>; |
47 | | - |
48 | | - /** |
49 | | - * List models available through this adapter. |
50 | | - */ |
51 | | - listModels?(): Promise<string[]>; |
52 | | -} |
| 3 | +export type { LLMAdapter } from '@objectstack/spec/contracts'; |
0 commit comments