@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/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaypie/llm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.30-rc.0",
|
|
4
4
|
"description": "Large language model utilities",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/finlaysonstudio/jaypie"
|
|
8
|
+
},
|
|
5
9
|
"license": "MIT",
|
|
6
10
|
"author": "Finlayson Studio",
|
|
7
11
|
"type": "module",
|
|
@@ -27,21 +31,21 @@
|
|
|
27
31
|
"typecheck": "tsc --noEmit"
|
|
28
32
|
},
|
|
29
33
|
"dependencies": {
|
|
30
|
-
"@anthropic-ai/sdk": "^0.
|
|
34
|
+
"@anthropic-ai/sdk": "^0.71.0",
|
|
35
|
+
"@google/genai": "^1.30.0",
|
|
31
36
|
"@jaypie/aws": "^1.1.15",
|
|
32
37
|
"@jaypie/core": "^1.1.2",
|
|
33
|
-
"@jaypie/errors": "^1.1.
|
|
34
|
-
"openai": "^
|
|
38
|
+
"@jaypie/errors": "^1.1.6",
|
|
39
|
+
"openai": "^6.9.1",
|
|
35
40
|
"openmeteo": "^1.2.0",
|
|
36
41
|
"random": "^5.3.0",
|
|
37
42
|
"z-schema": "^6.0.2",
|
|
38
|
-
"zod": "^
|
|
43
|
+
"zod": "^4.1.13"
|
|
39
44
|
},
|
|
40
45
|
"devDependencies": {
|
|
41
46
|
"@jaypie/types": "^0.1.3"
|
|
42
47
|
},
|
|
43
48
|
"publishConfig": {
|
|
44
49
|
"access": "public"
|
|
45
|
-
}
|
|
46
|
-
"gitHead": "0e8414490636bbda8f9f21bd2946d391500318a5"
|
|
50
|
+
}
|
|
47
51
|
}
|
package/LICENSE.txt
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Finlayson Studio, LLC
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|