-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathai-provider.interface.ts
More file actions
80 lines (65 loc) · 1.86 KB
/
ai-provider.interface.ts
File metadata and controls
80 lines (65 loc) · 1.86 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { BaseMessage } from '@langchain/core/messages';
import { IterableReadableStream } from '@langchain/core/utils/stream';
export interface AIProviderConfig {
modelId?: string;
temperature?: number;
maxTokens?: number;
streaming?: boolean;
}
export interface AIToolDefinition {
name: string;
description: string;
parameters: Record<string, unknown>;
}
export interface AIToolCall {
id: string;
name: string;
arguments: Record<string, unknown>;
}
export interface AIToolResult {
toolCallId: string;
result: string;
}
export interface AIStreamChunk {
type: 'text' | 'tool_call' | 'tool_result' | 'done';
content?: string;
toolCall?: AIToolCall;
responseId?: string;
}
export interface AICompletionResult {
content: string;
toolCalls?: AIToolCall[];
responseId?: string;
}
export interface IAIProvider {
generateCompletion(prompt: string, config?: AIProviderConfig): Promise<string>;
generateChatCompletion(messages: BaseMessage[], config?: AIProviderConfig): Promise<AICompletionResult>;
generateStreamingCompletion(
messages: BaseMessage[],
config?: AIProviderConfig,
): Promise<IterableReadableStream<AIStreamChunk>>;
generateWithTools(
messages: BaseMessage[],
tools: AIToolDefinition[],
config?: AIProviderConfig,
): Promise<AICompletionResult>;
generateStreamingWithTools(
messages: BaseMessage[],
tools: AIToolDefinition[],
config?: AIProviderConfig,
): Promise<IterableReadableStream<AIStreamChunk>>;
continueWithToolResults(
messages: BaseMessage[],
toolResults: AIToolResult[],
tools: AIToolDefinition[],
config?: AIProviderConfig,
): Promise<AICompletionResult>;
continueStreamingWithToolResults(
messages: BaseMessage[],
toolResults: AIToolResult[],
tools: AIToolDefinition[],
config?: AIProviderConfig,
): Promise<IterableReadableStream<AIStreamChunk>>;
getProviderName(): string;
getDefaultModelId(): string;
}