@jaypie/llm 1.1.27 → 1.1.30-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants.d.ts +22 -1
- package/dist/cjs/index.cjs +2399 -988
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/operate/OperateLoop.d.ts +61 -0
- package/dist/cjs/operate/adapters/AnthropicAdapter.d.ts +32 -0
- package/dist/cjs/operate/adapters/GeminiAdapter.d.ts +37 -0
- package/dist/cjs/operate/adapters/OpenAiAdapter.d.ts +30 -0
- package/dist/cjs/operate/adapters/ProviderAdapter.interface.d.ts +177 -0
- package/dist/cjs/operate/adapters/index.d.ts +5 -0
- package/dist/cjs/operate/hooks/HookRunner.d.ts +78 -0
- package/dist/cjs/operate/hooks/index.d.ts +2 -0
- package/dist/cjs/operate/index.d.ts +14 -0
- package/dist/cjs/operate/input/InputProcessor.d.ts +40 -0
- package/dist/cjs/operate/input/index.d.ts +2 -0
- package/dist/cjs/operate/response/ResponseBuilder.d.ts +89 -0
- package/dist/cjs/operate/response/index.d.ts +2 -0
- package/dist/cjs/operate/retry/RetryExecutor.d.ts +39 -0
- package/dist/cjs/operate/retry/RetryPolicy.d.ts +35 -0
- package/dist/cjs/operate/retry/index.d.ts +4 -0
- package/dist/cjs/operate/types.d.ts +136 -0
- package/dist/cjs/providers/anthropic/AnthropicProvider.class.d.ts +2 -0
- package/dist/cjs/providers/gemini/GeminiProvider.class.d.ts +17 -0
- package/dist/cjs/providers/gemini/index.d.ts +3 -0
- package/dist/cjs/providers/gemini/types.d.ts +185 -0
- package/dist/cjs/providers/gemini/utils.d.ts +51 -0
- package/dist/cjs/providers/openai/OpenAiProvider.class.d.ts +2 -0
- package/dist/esm/constants.d.ts +22 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2392 -982
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/OperateLoop.d.ts +61 -0
- package/dist/esm/operate/adapters/AnthropicAdapter.d.ts +32 -0
- package/dist/esm/operate/adapters/GeminiAdapter.d.ts +37 -0
- package/dist/esm/operate/adapters/OpenAiAdapter.d.ts +30 -0
- package/dist/esm/operate/adapters/ProviderAdapter.interface.d.ts +177 -0
- package/dist/esm/operate/adapters/index.d.ts +5 -0
- package/dist/esm/operate/hooks/HookRunner.d.ts +78 -0
- package/dist/esm/operate/hooks/index.d.ts +2 -0
- package/dist/esm/operate/index.d.ts +14 -0
- package/dist/esm/operate/input/InputProcessor.d.ts +40 -0
- package/dist/esm/operate/input/index.d.ts +2 -0
- package/dist/esm/operate/response/ResponseBuilder.d.ts +89 -0
- package/dist/esm/operate/response/index.d.ts +2 -0
- package/dist/esm/operate/retry/RetryExecutor.d.ts +39 -0
- package/dist/esm/operate/retry/RetryPolicy.d.ts +35 -0
- package/dist/esm/operate/retry/index.d.ts +4 -0
- package/dist/esm/operate/types.d.ts +136 -0
- package/dist/esm/providers/anthropic/AnthropicProvider.class.d.ts +2 -0
- package/dist/esm/providers/gemini/GeminiProvider.class.d.ts +17 -0
- package/dist/esm/providers/gemini/index.d.ts +3 -0
- package/dist/esm/providers/gemini/types.d.ts +185 -0
- package/dist/esm/providers/gemini/utils.d.ts +51 -0
- package/dist/esm/providers/openai/OpenAiProvider.class.d.ts +2 -0
- package/package.json +11 -7
- package/LICENSE.txt +0 -21
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { JsonObject } from "@jaypie/types";
|
|
2
|
+
import { LlmHistory, LlmMessageType, LlmOperateOptions, LlmUsageItem } from "../types/LlmProvider.interface.js";
|
|
3
|
+
import { Toolkit } from "../tools/Toolkit.class.js";
|
|
4
|
+
/**
|
|
5
|
+
* Standardized tool call representation across providers
|
|
6
|
+
*/
|
|
7
|
+
export interface StandardToolCall {
|
|
8
|
+
/** Unique identifier for this tool call */
|
|
9
|
+
callId: string;
|
|
10
|
+
/** Name of the tool being called */
|
|
11
|
+
name: string;
|
|
12
|
+
/** JSON string of arguments */
|
|
13
|
+
arguments: string;
|
|
14
|
+
/** Original provider-specific tool call object */
|
|
15
|
+
raw: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Standardized tool result to send back to the provider
|
|
19
|
+
*/
|
|
20
|
+
export interface StandardToolResult {
|
|
21
|
+
/** The call ID this result corresponds to */
|
|
22
|
+
callId: string;
|
|
23
|
+
/** JSON string of the result */
|
|
24
|
+
output: string;
|
|
25
|
+
/** Whether the tool call was successful */
|
|
26
|
+
success: boolean;
|
|
27
|
+
/** Error message if the tool call failed */
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parsed response from a provider API call
|
|
32
|
+
*/
|
|
33
|
+
export interface ParsedResponse {
|
|
34
|
+
/** The text content of the response, if any */
|
|
35
|
+
content?: string | JsonObject;
|
|
36
|
+
/** Whether the response contains tool calls */
|
|
37
|
+
hasToolCalls: boolean;
|
|
38
|
+
/** The stop reason from the provider */
|
|
39
|
+
stopReason?: string;
|
|
40
|
+
/** Usage information for this response */
|
|
41
|
+
usage?: LlmUsageItem;
|
|
42
|
+
/** Raw provider response for storage */
|
|
43
|
+
raw: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Context passed to hooks and utilities during the operate loop
|
|
47
|
+
*/
|
|
48
|
+
export interface OperateContext {
|
|
49
|
+
/** The hooks configuration */
|
|
50
|
+
hooks: LlmOperateOptions["hooks"];
|
|
51
|
+
/** The operate options */
|
|
52
|
+
options: LlmOperateOptions;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Provider-agnostic request options
|
|
56
|
+
* Each adapter will convert this to provider-specific format
|
|
57
|
+
*/
|
|
58
|
+
export interface OperateRequest {
|
|
59
|
+
/** The model to use */
|
|
60
|
+
model: string;
|
|
61
|
+
/** The conversation history/messages */
|
|
62
|
+
messages: LlmHistory;
|
|
63
|
+
/** System instructions (if separate from messages) */
|
|
64
|
+
system?: string;
|
|
65
|
+
/** Additional instructions to append */
|
|
66
|
+
instructions?: string;
|
|
67
|
+
/** Tools available for the model */
|
|
68
|
+
tools?: ProviderToolDefinition[];
|
|
69
|
+
/** Structured output format */
|
|
70
|
+
format?: JsonObject;
|
|
71
|
+
/** Provider-specific options */
|
|
72
|
+
providerOptions?: JsonObject;
|
|
73
|
+
/** User identifier for tracking */
|
|
74
|
+
user?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Tool definition in provider-agnostic format
|
|
78
|
+
*/
|
|
79
|
+
export interface ProviderToolDefinition {
|
|
80
|
+
/** Tool name */
|
|
81
|
+
name: string;
|
|
82
|
+
/** Tool description */
|
|
83
|
+
description: string;
|
|
84
|
+
/** JSON Schema for parameters */
|
|
85
|
+
parameters: JsonObject;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Categories of errors for retry logic
|
|
89
|
+
*/
|
|
90
|
+
export declare enum ErrorCategory {
|
|
91
|
+
/** Error is transient and can be retried */
|
|
92
|
+
Retryable = "retryable",
|
|
93
|
+
/** Error is due to rate limiting */
|
|
94
|
+
RateLimit = "rate_limit",
|
|
95
|
+
/** Error cannot be recovered from */
|
|
96
|
+
Unrecoverable = "unrecoverable",
|
|
97
|
+
/** Error type is unknown */
|
|
98
|
+
Unknown = "unknown"
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Classified error with metadata
|
|
102
|
+
*/
|
|
103
|
+
export interface ClassifiedError {
|
|
104
|
+
/** The original error */
|
|
105
|
+
error: unknown;
|
|
106
|
+
/** Category of the error */
|
|
107
|
+
category: ErrorCategory;
|
|
108
|
+
/** Whether a retry should be attempted */
|
|
109
|
+
shouldRetry: boolean;
|
|
110
|
+
/** Suggested delay before retry (if applicable) */
|
|
111
|
+
suggestedDelayMs?: number;
|
|
112
|
+
}
|
|
113
|
+
import type { ResponseBuilder } from "./response/ResponseBuilder.js";
|
|
114
|
+
/**
|
|
115
|
+
* Internal state of the operate loop
|
|
116
|
+
*/
|
|
117
|
+
export interface OperateLoopState {
|
|
118
|
+
/** Current conversation input/messages */
|
|
119
|
+
currentInput: LlmHistory;
|
|
120
|
+
/** Current turn number (0-indexed, incremented at start of each turn) */
|
|
121
|
+
currentTurn: number;
|
|
122
|
+
/** Formatted output schema for structured output */
|
|
123
|
+
formattedFormat?: JsonObject;
|
|
124
|
+
/** Formatted tools for the provider */
|
|
125
|
+
formattedTools?: ProviderToolDefinition[];
|
|
126
|
+
/** Maximum allowed turns */
|
|
127
|
+
maxTurns: number;
|
|
128
|
+
/** Response builder instance */
|
|
129
|
+
responseBuilder: ResponseBuilder;
|
|
130
|
+
/** The toolkit for tool calls */
|
|
131
|
+
toolkit?: Toolkit;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Re-export message type for convenience in adapters
|
|
135
|
+
*/
|
|
136
|
+
export { LlmMessageType };
|
|
@@ -3,6 +3,7 @@ import { LlmHistory, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmO
|
|
|
3
3
|
export declare class AnthropicProvider implements LlmProvider {
|
|
4
4
|
private model;
|
|
5
5
|
private _client?;
|
|
6
|
+
private _operateLoop?;
|
|
6
7
|
private apiKey?;
|
|
7
8
|
private log;
|
|
8
9
|
private conversationHistory;
|
|
@@ -10,6 +11,7 @@ export declare class AnthropicProvider implements LlmProvider {
|
|
|
10
11
|
apiKey?: string;
|
|
11
12
|
});
|
|
12
13
|
private getClient;
|
|
14
|
+
private getOperateLoop;
|
|
13
15
|
send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
|
|
14
16
|
operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
15
17
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JsonObject } from "@jaypie/types";
|
|
2
|
+
import { LlmHistory, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmOperateResponse, LlmProvider } from "../../types/LlmProvider.interface.js";
|
|
3
|
+
export declare class GeminiProvider implements LlmProvider {
|
|
4
|
+
private model;
|
|
5
|
+
private _client?;
|
|
6
|
+
private _operateLoop?;
|
|
7
|
+
private apiKey?;
|
|
8
|
+
private log;
|
|
9
|
+
private conversationHistory;
|
|
10
|
+
constructor(model?: string, { apiKey }?: {
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
});
|
|
13
|
+
private getClient;
|
|
14
|
+
private getOperateLoop;
|
|
15
|
+
send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
|
|
16
|
+
operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { JsonObject } from "@jaypie/types";
|
|
2
|
+
import { LlmMessageRole } from "../../types/LlmProvider.interface.js";
|
|
3
|
+
export declare const ROLE_MAP: Record<LlmMessageRole, "user" | "model">;
|
|
4
|
+
/**
|
|
5
|
+
* A part of content - can be text, function call, or function response
|
|
6
|
+
*/
|
|
7
|
+
export interface GeminiPart {
|
|
8
|
+
text?: string;
|
|
9
|
+
thought?: boolean;
|
|
10
|
+
thoughtSignature?: string;
|
|
11
|
+
functionCall?: GeminiFunctionCall;
|
|
12
|
+
functionResponse?: GeminiFunctionResponse;
|
|
13
|
+
inlineData?: {
|
|
14
|
+
mimeType: string;
|
|
15
|
+
data: string;
|
|
16
|
+
};
|
|
17
|
+
fileData?: {
|
|
18
|
+
mimeType?: string;
|
|
19
|
+
fileUri: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A function call made by the model
|
|
24
|
+
*/
|
|
25
|
+
export interface GeminiFunctionCall {
|
|
26
|
+
name?: string;
|
|
27
|
+
args?: Record<string, unknown>;
|
|
28
|
+
id?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A response to a function call
|
|
32
|
+
*/
|
|
33
|
+
export interface GeminiFunctionResponse {
|
|
34
|
+
name: string;
|
|
35
|
+
response: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Content represents a message in the conversation
|
|
39
|
+
*/
|
|
40
|
+
export interface GeminiContent {
|
|
41
|
+
role: "user" | "model";
|
|
42
|
+
parts?: GeminiPart[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Function declaration for tools
|
|
46
|
+
*/
|
|
47
|
+
export interface GeminiFunctionDeclaration {
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
parameters: JsonObject;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Tool definition containing function declarations
|
|
54
|
+
*/
|
|
55
|
+
export interface GeminiTool {
|
|
56
|
+
functionDeclarations?: GeminiFunctionDeclaration[];
|
|
57
|
+
googleSearch?: Record<string, unknown>;
|
|
58
|
+
codeExecution?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Configuration for a generate content request
|
|
62
|
+
* This is a simplified internal type - we use the SDK's actual types at runtime
|
|
63
|
+
*/
|
|
64
|
+
export interface GeminiGenerateContentConfig {
|
|
65
|
+
systemInstruction?: string;
|
|
66
|
+
tools?: GeminiTool[];
|
|
67
|
+
toolConfig?: {
|
|
68
|
+
functionCallingConfig?: {
|
|
69
|
+
mode?: "AUTO" | "ANY" | "NONE";
|
|
70
|
+
allowedFunctionNames?: string[];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
responseMimeType?: string;
|
|
74
|
+
responseJsonSchema?: JsonObject;
|
|
75
|
+
temperature?: number;
|
|
76
|
+
topP?: number;
|
|
77
|
+
topK?: number;
|
|
78
|
+
maxOutputTokens?: number;
|
|
79
|
+
stopSequences?: string[];
|
|
80
|
+
candidateCount?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Request structure for generateContent API
|
|
84
|
+
*/
|
|
85
|
+
export interface GeminiRequest {
|
|
86
|
+
model: string;
|
|
87
|
+
contents: GeminiContent[];
|
|
88
|
+
config?: GeminiGenerateContentConfig;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Usage metadata from the response
|
|
92
|
+
*/
|
|
93
|
+
export interface GeminiUsageMetadata {
|
|
94
|
+
promptTokenCount?: number;
|
|
95
|
+
candidatesTokenCount?: number;
|
|
96
|
+
totalTokenCount?: number;
|
|
97
|
+
thoughtsTokenCount?: number;
|
|
98
|
+
cachedContentTokenCount?: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A response candidate from the model
|
|
102
|
+
*/
|
|
103
|
+
export interface GeminiCandidate {
|
|
104
|
+
content?: GeminiContent;
|
|
105
|
+
finishReason?: string;
|
|
106
|
+
index?: number;
|
|
107
|
+
safetyRatings?: Array<{
|
|
108
|
+
category: string;
|
|
109
|
+
probability: string;
|
|
110
|
+
blocked?: boolean;
|
|
111
|
+
}>;
|
|
112
|
+
citationMetadata?: {
|
|
113
|
+
citations?: Array<{
|
|
114
|
+
startIndex?: number;
|
|
115
|
+
endIndex?: number;
|
|
116
|
+
uri?: string;
|
|
117
|
+
title?: string;
|
|
118
|
+
license?: string;
|
|
119
|
+
publicationDate?: {
|
|
120
|
+
year?: number;
|
|
121
|
+
month?: number;
|
|
122
|
+
day?: number;
|
|
123
|
+
};
|
|
124
|
+
}>;
|
|
125
|
+
};
|
|
126
|
+
tokenCount?: number;
|
|
127
|
+
avgLogprobs?: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Prompt feedback from the API
|
|
131
|
+
*/
|
|
132
|
+
export interface GeminiPromptFeedback {
|
|
133
|
+
blockReason?: string;
|
|
134
|
+
safetyRatings?: Array<{
|
|
135
|
+
category: string;
|
|
136
|
+
probability: string;
|
|
137
|
+
blocked?: boolean;
|
|
138
|
+
}>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Raw response from Gemini API
|
|
142
|
+
*/
|
|
143
|
+
export interface GeminiRawResponse {
|
|
144
|
+
candidates?: GeminiCandidate[];
|
|
145
|
+
promptFeedback?: GeminiPromptFeedback;
|
|
146
|
+
usageMetadata?: GeminiUsageMetadata;
|
|
147
|
+
modelVersion?: string;
|
|
148
|
+
responseId?: string;
|
|
149
|
+
createTime?: string;
|
|
150
|
+
text?: string;
|
|
151
|
+
functionCalls?: GeminiFunctionCall[];
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Error information from Gemini API
|
|
155
|
+
*/
|
|
156
|
+
export interface GeminiErrorInfo {
|
|
157
|
+
status?: number;
|
|
158
|
+
code?: number;
|
|
159
|
+
message?: string;
|
|
160
|
+
details?: Array<{
|
|
161
|
+
"@type"?: string;
|
|
162
|
+
reason?: string;
|
|
163
|
+
domain?: string;
|
|
164
|
+
metadata?: Record<string, string>;
|
|
165
|
+
}>;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Finish reasons returned by Gemini
|
|
169
|
+
*/
|
|
170
|
+
export declare const FINISH_REASON: {
|
|
171
|
+
readonly FINISH_REASON_UNSPECIFIED: "FINISH_REASON_UNSPECIFIED";
|
|
172
|
+
readonly STOP: "STOP";
|
|
173
|
+
readonly MAX_TOKENS: "MAX_TOKENS";
|
|
174
|
+
readonly SAFETY: "SAFETY";
|
|
175
|
+
readonly RECITATION: "RECITATION";
|
|
176
|
+
readonly LANGUAGE: "LANGUAGE";
|
|
177
|
+
readonly OTHER: "OTHER";
|
|
178
|
+
readonly BLOCKLIST: "BLOCKLIST";
|
|
179
|
+
readonly PROHIBITED_CONTENT: "PROHIBITED_CONTENT";
|
|
180
|
+
readonly SPII: "SPII";
|
|
181
|
+
readonly MALFORMED_FUNCTION_CALL: "MALFORMED_FUNCTION_CALL";
|
|
182
|
+
readonly IMAGE_SAFETY: "IMAGE_SAFETY";
|
|
183
|
+
readonly UNEXPECTED_TOOL_CALL: "UNEXPECTED_TOOL_CALL";
|
|
184
|
+
};
|
|
185
|
+
export type GeminiFinishReason = (typeof FINISH_REASON)[keyof typeof FINISH_REASON];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { log as defaultLog } from "@jaypie/core";
|
|
2
|
+
import { GoogleGenAI } from "@google/genai";
|
|
3
|
+
import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
|
|
4
|
+
export declare const getLogger: () => {
|
|
5
|
+
debug: {
|
|
6
|
+
(...args: unknown[]): void;
|
|
7
|
+
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
8
|
+
};
|
|
9
|
+
error: {
|
|
10
|
+
(...args: unknown[]): void;
|
|
11
|
+
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
12
|
+
};
|
|
13
|
+
fatal: {
|
|
14
|
+
(...args: unknown[]): void;
|
|
15
|
+
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
16
|
+
};
|
|
17
|
+
info: {
|
|
18
|
+
(...args: unknown[]): void;
|
|
19
|
+
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
20
|
+
};
|
|
21
|
+
trace: {
|
|
22
|
+
(...args: unknown[]): void;
|
|
23
|
+
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
24
|
+
};
|
|
25
|
+
warn: {
|
|
26
|
+
(...args: unknown[]): void;
|
|
27
|
+
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
28
|
+
};
|
|
29
|
+
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
30
|
+
with(tags: Record<string, unknown>): typeof defaultLog;
|
|
31
|
+
tag(key: string | string[] | Record<string, unknown> | null, value?: string): void;
|
|
32
|
+
untag(tags: string | string[] | Record<string, unknown> | null): void;
|
|
33
|
+
lib(options: {
|
|
34
|
+
level?: string;
|
|
35
|
+
lib?: string;
|
|
36
|
+
tags?: Record<string, unknown>;
|
|
37
|
+
}): typeof defaultLog;
|
|
38
|
+
};
|
|
39
|
+
export declare function initializeClient({ apiKey, }?: {
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
}): Promise<GoogleGenAI>;
|
|
42
|
+
export interface ChatMessage {
|
|
43
|
+
role: "user" | "model";
|
|
44
|
+
content: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function formatSystemMessage(systemPrompt: string, { data, placeholders }?: Pick<LlmMessageOptions, "data" | "placeholders">): string;
|
|
47
|
+
export declare function formatUserMessage(message: string, { data, placeholders }?: Pick<LlmMessageOptions, "data" | "placeholders">): ChatMessage;
|
|
48
|
+
export declare function prepareMessages(message: string, { data, placeholders }?: LlmMessageOptions): {
|
|
49
|
+
messages: ChatMessage[];
|
|
50
|
+
systemInstruction?: string;
|
|
51
|
+
};
|
|
@@ -3,6 +3,7 @@ import { LlmHistory, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmO
|
|
|
3
3
|
export declare class OpenAiProvider implements LlmProvider {
|
|
4
4
|
private model;
|
|
5
5
|
private _client?;
|
|
6
|
+
private _operateLoop?;
|
|
6
7
|
private apiKey?;
|
|
7
8
|
private log;
|
|
8
9
|
private conversationHistory;
|
|
@@ -10,6 +11,7 @@ export declare class OpenAiProvider implements LlmProvider {
|
|
|
10
11
|
apiKey?: string;
|
|
11
12
|
});
|
|
12
13
|
private getClient;
|
|
14
|
+
private getOperateLoop;
|
|
13
15
|
send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
|
|
14
16
|
operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
15
17
|
}
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
export declare const PROVIDER: {
|
|
2
|
+
readonly GEMINI: {
|
|
3
|
+
readonly MODEL: {
|
|
4
|
+
readonly DEFAULT: "gemini-2.5-flash";
|
|
5
|
+
readonly SMALL: "gemini-2.5-flash";
|
|
6
|
+
readonly LARGE: "gemini-2.5-pro";
|
|
7
|
+
readonly TINY: "gemini-2.0-flash-lite";
|
|
8
|
+
readonly GEMINI_2_5_PRO: "gemini-2.5-pro";
|
|
9
|
+
readonly GEMINI_2_5_FLASH: "gemini-2.5-flash";
|
|
10
|
+
readonly GEMINI_2_0_FLASH: "gemini-2.0-flash";
|
|
11
|
+
readonly GEMINI_2_0_FLASH_LITE: "gemini-2.0-flash-lite";
|
|
12
|
+
readonly GEMINI_1_5_PRO: "gemini-1.5-pro";
|
|
13
|
+
readonly GEMINI_1_5_FLASH: "gemini-1.5-flash";
|
|
14
|
+
readonly GEMINI_1_5_FLASH_8B: "gemini-1.5-flash-8b";
|
|
15
|
+
};
|
|
16
|
+
readonly MODEL_MATCH_WORDS: readonly ["gemini", "google"];
|
|
17
|
+
readonly NAME: "gemini";
|
|
18
|
+
readonly ROLE: {
|
|
19
|
+
readonly MODEL: "model";
|
|
20
|
+
readonly USER: "user";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
2
23
|
readonly ANTHROPIC: {
|
|
3
24
|
readonly MODEL: {
|
|
4
25
|
readonly DEFAULT: "claude-opus-4-1";
|
|
@@ -67,7 +88,7 @@ export declare const PROVIDER: {
|
|
|
67
88
|
readonly NAME: "openai";
|
|
68
89
|
};
|
|
69
90
|
};
|
|
70
|
-
export type LlmProviderName = typeof PROVIDER.
|
|
91
|
+
export type LlmProviderName = typeof PROVIDER.ANTHROPIC.NAME | typeof PROVIDER.GEMINI.NAME | typeof PROVIDER.OPENAI.NAME;
|
|
71
92
|
export declare const DEFAULT: {
|
|
72
93
|
readonly PROVIDER: {
|
|
73
94
|
readonly MODEL: {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export type { LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentI
|
|
|
4
4
|
export { LlmMessageRole, LlmMessageType, } from "./types/LlmProvider.interface.js";
|
|
5
5
|
export type { LlmTool } from "./types/LlmTool.interface.js";
|
|
6
6
|
export { JaypieToolkit, toolkit, Toolkit, tools } from "./tools/index.js";
|
|
7
|
+
export { GeminiProvider } from "./providers/gemini/index.js";
|