@jaypie/llm 1.2.0 → 1.2.2
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/Llm.d.ts +5 -5
- package/dist/cjs/constants.d.ts +19 -17
- package/dist/cjs/index.cjs +692 -59
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/operate/OperateLoop.d.ts +2 -2
- package/dist/cjs/operate/StreamLoop.d.ts +2 -2
- package/dist/cjs/operate/adapters/GeminiAdapter.d.ts +2 -1
- package/dist/cjs/operate/adapters/OpenAiAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/OpenRouterAdapter.d.ts +12 -2
- package/dist/cjs/operate/input/InputProcessor.d.ts +3 -3
- package/dist/cjs/operate/response/ResponseBuilder.d.ts +14 -1
- package/dist/cjs/types/LlmOperateInput.guards.d.ts +17 -0
- package/dist/cjs/types/LlmProvider.interface.d.ts +48 -2
- package/dist/cjs/upload/detectMimeType.d.ts +16 -0
- package/dist/cjs/upload/extractPdfPages.d.ts +13 -0
- package/dist/cjs/upload/index.d.ts +5 -0
- package/dist/cjs/upload/loadLocalFile.d.ts +6 -0
- package/dist/cjs/upload/loadS3File.d.ts +7 -0
- package/dist/cjs/upload/resolveOperateInput.d.ts +12 -0
- package/dist/cjs/util/extractReasoning.d.ts +14 -0
- package/dist/cjs/util/index.d.ts +1 -0
- package/dist/esm/Llm.d.ts +5 -5
- package/dist/esm/constants.d.ts +19 -17
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +689 -61
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/OperateLoop.d.ts +2 -2
- package/dist/esm/operate/StreamLoop.d.ts +2 -2
- package/dist/esm/operate/adapters/GeminiAdapter.d.ts +2 -1
- package/dist/esm/operate/adapters/OpenAiAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/OpenRouterAdapter.d.ts +12 -2
- package/dist/esm/operate/input/InputProcessor.d.ts +3 -3
- package/dist/esm/operate/response/ResponseBuilder.d.ts +14 -1
- package/dist/esm/types/LlmOperateInput.guards.d.ts +17 -0
- package/dist/esm/types/LlmProvider.interface.d.ts +48 -2
- package/dist/esm/upload/detectMimeType.d.ts +16 -0
- package/dist/esm/upload/extractPdfPages.d.ts +13 -0
- package/dist/esm/upload/index.d.ts +5 -0
- package/dist/esm/upload/loadLocalFile.d.ts +6 -0
- package/dist/esm/upload/loadS3File.d.ts +7 -0
- package/dist/esm/upload/resolveOperateInput.d.ts +12 -0
- package/dist/esm/util/extractReasoning.d.ts +14 -0
- package/dist/esm/util/index.d.ts +1 -0
- package/package.json +7 -6
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { default as Llm } from "./Llm.js";
|
|
2
2
|
export * as LLM from "./constants.js";
|
|
3
|
-
export type { LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider, } from "./types/LlmProvider.interface.js";
|
|
3
|
+
export type { LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider, } from "./types/LlmProvider.interface.js";
|
|
4
4
|
export { LlmMessageRole, LlmMessageType, } from "./types/LlmProvider.interface.js";
|
|
5
|
+
export { isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, } from "./types/LlmOperateInput.guards.js";
|
|
5
6
|
export type { LlmTool } from "./types/LlmTool.interface.js";
|
|
6
7
|
export type { LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, } from "./types/LlmStreamChunk.interface.js";
|
|
7
8
|
export { LlmStreamChunkType } from "./types/LlmStreamChunk.interface.js";
|
|
8
9
|
export { JaypieToolkit, toolkit, Toolkit, tools } from "./tools/index.js";
|
|
10
|
+
export { extractReasoning } from "./util/extractReasoning.js";
|
|
9
11
|
export { GeminiProvider } from "./providers/gemini/index.js";
|
|
10
12
|
export { OpenRouterProvider } from "./providers/openrouter/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LlmHistory, LlmInputMessage, LlmOperateOptions, LlmOperateResponse } from "../types/LlmProvider.interface.js";
|
|
1
|
+
import { LlmHistory, LlmInputMessage, LlmOperateInput, LlmOperateOptions, LlmOperateResponse } from "../types/LlmProvider.interface.js";
|
|
2
2
|
import { ProviderAdapter } from "./adapters/ProviderAdapter.interface.js";
|
|
3
3
|
import { HookRunner } from "./hooks/index.js";
|
|
4
4
|
import { InputProcessor } from "./input/index.js";
|
|
@@ -28,7 +28,7 @@ export declare class OperateLoop {
|
|
|
28
28
|
/**
|
|
29
29
|
* Execute the operate loop for multi-turn conversations with tool calling.
|
|
30
30
|
*/
|
|
31
|
-
execute(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
31
|
+
execute(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
32
32
|
private initializeState;
|
|
33
33
|
private createContext;
|
|
34
34
|
private buildInitialRequest;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LlmHistory, LlmInputMessage, LlmOperateOptions } from "../types/LlmProvider.interface.js";
|
|
1
|
+
import { LlmHistory, LlmInputMessage, LlmOperateInput, LlmOperateOptions } from "../types/LlmProvider.interface.js";
|
|
2
2
|
import { LlmStreamChunk } from "../types/LlmStreamChunk.interface.js";
|
|
3
3
|
import { ProviderAdapter } from "./adapters/ProviderAdapter.interface.js";
|
|
4
4
|
import { HookRunner } from "./hooks/index.js";
|
|
@@ -24,7 +24,7 @@ export declare class StreamLoop {
|
|
|
24
24
|
* Execute the streaming loop for multi-turn conversations with tool calling.
|
|
25
25
|
* Yields stream chunks as they become available.
|
|
26
26
|
*/
|
|
27
|
-
execute(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
|
|
27
|
+
execute(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
|
|
28
28
|
private initializeState;
|
|
29
29
|
private createContext;
|
|
30
30
|
private buildInitialRequest;
|
|
@@ -13,7 +13,7 @@ import { GeminiPart, GeminiRawResponse, GeminiRequest } from "../../providers/ge
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class GeminiAdapter extends BaseProviderAdapter {
|
|
15
15
|
readonly name: "gemini";
|
|
16
|
-
readonly defaultModel: "gemini-
|
|
16
|
+
readonly defaultModel: "gemini-3-pro-preview";
|
|
17
17
|
buildRequest(request: OperateRequest): GeminiRequest;
|
|
18
18
|
formatTools(toolkit: Toolkit, outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
19
19
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
@@ -30,6 +30,7 @@ export declare class GeminiAdapter extends BaseProviderAdapter {
|
|
|
30
30
|
hasStructuredOutput(response: unknown): boolean;
|
|
31
31
|
extractStructuredOutput(response: unknown): JsonObject | undefined;
|
|
32
32
|
private convertMessagesToContents;
|
|
33
|
+
private convertContentToParts;
|
|
33
34
|
private mapRole;
|
|
34
35
|
private hasToolCalls;
|
|
35
36
|
private getFinishReason;
|
|
@@ -12,7 +12,7 @@ import { BaseProviderAdapter } from "./ProviderAdapter.interface.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export declare class OpenAiAdapter extends BaseProviderAdapter {
|
|
14
14
|
readonly name: "openai";
|
|
15
|
-
readonly defaultModel: "gpt-
|
|
15
|
+
readonly defaultModel: "gpt-4.1";
|
|
16
16
|
buildRequest(request: OperateRequest): unknown;
|
|
17
17
|
formatTools(toolkit: Toolkit, _outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
18
18
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
@@ -7,7 +7,7 @@ import { ClassifiedError, OperateRequest, ParsedResponse, ProviderToolDefinition
|
|
|
7
7
|
import { BaseProviderAdapter } from "./ProviderAdapter.interface.js";
|
|
8
8
|
interface OpenRouterMessage {
|
|
9
9
|
role: "system" | "user" | "assistant" | "tool";
|
|
10
|
-
content?: string | null;
|
|
10
|
+
content?: string | OpenRouterContentPart[] | null;
|
|
11
11
|
toolCalls?: OpenRouterToolCall[];
|
|
12
12
|
toolCallId?: string;
|
|
13
13
|
}
|
|
@@ -39,6 +39,9 @@ interface OpenRouterUsage {
|
|
|
39
39
|
prompt_tokens?: number;
|
|
40
40
|
completion_tokens?: number;
|
|
41
41
|
total_tokens?: number;
|
|
42
|
+
completionTokensDetails?: {
|
|
43
|
+
reasoningTokens?: number;
|
|
44
|
+
};
|
|
42
45
|
}
|
|
43
46
|
interface OpenRouterResponse {
|
|
44
47
|
id: string;
|
|
@@ -66,6 +69,13 @@ interface OpenRouterRequest {
|
|
|
66
69
|
};
|
|
67
70
|
user?: string;
|
|
68
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* OpenRouter content part types (text only - images/files not supported)
|
|
74
|
+
*/
|
|
75
|
+
type OpenRouterContentPart = {
|
|
76
|
+
type: "text";
|
|
77
|
+
text: string;
|
|
78
|
+
};
|
|
69
79
|
/**
|
|
70
80
|
* OpenRouterAdapter implements the ProviderAdapter interface for OpenRouter's API.
|
|
71
81
|
* OpenRouter provides a unified API to access hundreds of AI models through OpenAI-compatible endpoints.
|
|
@@ -74,7 +84,7 @@ interface OpenRouterRequest {
|
|
|
74
84
|
*/
|
|
75
85
|
export declare class OpenRouterAdapter extends BaseProviderAdapter {
|
|
76
86
|
readonly name: "openrouter";
|
|
77
|
-
readonly defaultModel: "
|
|
87
|
+
readonly defaultModel: "z-ai/glm-4.7";
|
|
78
88
|
buildRequest(request: OperateRequest): OpenRouterRequest;
|
|
79
89
|
formatTools(toolkit: Toolkit, outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
80
90
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LlmHistory, LlmInputMessage, LlmOperateOptions } from "../../types/LlmProvider.interface.js";
|
|
1
|
+
import { LlmHistory, LlmInputMessage, LlmOperateInput, LlmOperateOptions } from "../../types/LlmProvider.interface.js";
|
|
2
2
|
export interface ProcessedInput {
|
|
3
3
|
/** The processed history with all messages formatted */
|
|
4
4
|
history: LlmHistory;
|
|
@@ -15,11 +15,11 @@ export declare class InputProcessor {
|
|
|
15
15
|
/**
|
|
16
16
|
* Process input with placeholders, history merging, and system message handling
|
|
17
17
|
*
|
|
18
|
-
* @param input - The raw input (string, message, or
|
|
18
|
+
* @param input - The raw input (string, message, history, or LlmOperateInput)
|
|
19
19
|
* @param options - The operate options containing data, history, system, etc.
|
|
20
20
|
* @returns Processed input with all transformations applied
|
|
21
21
|
*/
|
|
22
|
-
process(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): ProcessedInput
|
|
22
|
+
process(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): Promise<ProcessedInput>;
|
|
23
23
|
/**
|
|
24
24
|
* Format input and apply placeholders if data is provided
|
|
25
25
|
*/
|
|
@@ -45,6 +45,18 @@ export declare class ResponseBuilder {
|
|
|
45
45
|
* Append items to the output
|
|
46
46
|
*/
|
|
47
47
|
appendToOutput(...items: LlmOutput): this;
|
|
48
|
+
/**
|
|
49
|
+
* Set the reasoning array
|
|
50
|
+
*/
|
|
51
|
+
setReasoning(reasoning: string[]): this;
|
|
52
|
+
/**
|
|
53
|
+
* Append reasoning text items
|
|
54
|
+
*/
|
|
55
|
+
appendToReasoning(...items: string[]): this;
|
|
56
|
+
/**
|
|
57
|
+
* Get the current reasoning array
|
|
58
|
+
*/
|
|
59
|
+
getReasoning(): string[];
|
|
48
60
|
/**
|
|
49
61
|
* Add a raw provider response
|
|
50
62
|
*/
|
|
@@ -78,7 +90,8 @@ export declare class ResponseBuilder {
|
|
|
78
90
|
*/
|
|
79
91
|
incomplete(): this;
|
|
80
92
|
/**
|
|
81
|
-
* Build and return the final response object
|
|
93
|
+
* Build and return the final response object.
|
|
94
|
+
* Automatically extracts reasoning from history if not already set.
|
|
82
95
|
*/
|
|
83
96
|
build(): LlmOperateResponse;
|
|
84
97
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage } from "./LlmProvider.interface.js";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if an item is an LlmOperateInputFile
|
|
4
|
+
*/
|
|
5
|
+
export declare function isLlmOperateInputFile(item: unknown): item is LlmOperateInputFile;
|
|
6
|
+
/**
|
|
7
|
+
* Type guard to check if an item is an LlmOperateInputImage
|
|
8
|
+
*/
|
|
9
|
+
export declare function isLlmOperateInputImage(item: unknown): item is LlmOperateInputImage;
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to check if an item is an LlmOperateInputContent
|
|
12
|
+
*/
|
|
13
|
+
export declare function isLlmOperateInputContent(item: unknown): item is LlmOperateInputContent;
|
|
14
|
+
/**
|
|
15
|
+
* Type guard to check if input is an LlmOperateInput array
|
|
16
|
+
*/
|
|
17
|
+
export declare function isLlmOperateInput(input: unknown): input is LlmOperateInput;
|
|
@@ -56,6 +56,51 @@ export interface LlmInputMessage {
|
|
|
56
56
|
role: LlmMessageRole;
|
|
57
57
|
type?: LlmMessageType.Message;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* File input that can be loaded from local filesystem, S3, or provided as base64 data.
|
|
61
|
+
* For PDFs, specific pages can be extracted via the `pages` property.
|
|
62
|
+
* If the file extension is an image type, it will be treated as an image internally.
|
|
63
|
+
*/
|
|
64
|
+
export interface LlmOperateInputFile {
|
|
65
|
+
/** Path or filename (extension determines type via /\.(\w+)$/) */
|
|
66
|
+
file: string;
|
|
67
|
+
/** S3 bucket name (if present, load from S3) */
|
|
68
|
+
bucket?: string;
|
|
69
|
+
/** Specific pages to extract from PDF (omit = all pages) */
|
|
70
|
+
pages?: number[];
|
|
71
|
+
/** Base64 data (if present, use directly instead of loading from file) */
|
|
72
|
+
data?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Image input that can be loaded from local filesystem, S3, or provided as base64 data.
|
|
76
|
+
*/
|
|
77
|
+
export interface LlmOperateInputImage {
|
|
78
|
+
/** Path or filename */
|
|
79
|
+
image: string;
|
|
80
|
+
/** S3 bucket name (if present, load from S3) */
|
|
81
|
+
bucket?: string;
|
|
82
|
+
/** Base64 data (if present, use directly instead of loading from file) */
|
|
83
|
+
data?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Content item in LlmOperateInput array.
|
|
87
|
+
* Can be a string (text), file object, or image object.
|
|
88
|
+
*/
|
|
89
|
+
export type LlmOperateInputContent = string | LlmOperateInputFile | LlmOperateInputImage;
|
|
90
|
+
/**
|
|
91
|
+
* Simplified input format for operate() that supports automatic file resolution.
|
|
92
|
+
* Files/images are loaded from local filesystem, S3, or provided data.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const input: LlmOperateInput = [
|
|
97
|
+
* "Extract text from these documents",
|
|
98
|
+
* { file: "document.pdf", bucket: "my-bucket", pages: [1, 2, 3] },
|
|
99
|
+
* { image: "photo.png" }, // loads from local filesystem
|
|
100
|
+
* ];
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export type LlmOperateInput = LlmOperateInputContent[];
|
|
59
104
|
export interface LlmOutputContentText {
|
|
60
105
|
annotations?: AnyValue[];
|
|
61
106
|
text: string;
|
|
@@ -188,13 +233,14 @@ export interface LlmOperateResponse {
|
|
|
188
233
|
model?: string;
|
|
189
234
|
output: LlmOutput;
|
|
190
235
|
provider?: string;
|
|
236
|
+
reasoning: string[];
|
|
191
237
|
responses: JsonReturn[];
|
|
192
238
|
status: LlmResponseStatus;
|
|
193
239
|
usage: LlmUsage;
|
|
194
240
|
}
|
|
195
241
|
export interface LlmProvider {
|
|
196
|
-
operate?(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
242
|
+
operate?(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
197
243
|
send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
|
|
198
|
-
stream?(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
|
|
244
|
+
stream?(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
|
|
199
245
|
}
|
|
200
246
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract file extension from a path or filename
|
|
3
|
+
*/
|
|
4
|
+
export declare function getFileExtension(filePath: string): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Determine MIME type from file extension
|
|
7
|
+
*/
|
|
8
|
+
export declare function getMimeType(filePath: string): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Check if a file path has an image extension
|
|
11
|
+
*/
|
|
12
|
+
export declare function isImageExtension(filePath: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a file path has a PDF extension
|
|
15
|
+
*/
|
|
16
|
+
export declare function isPdfExtension(filePath: string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract specific pages from a PDF buffer
|
|
3
|
+
* @param pdfBytes - Buffer containing the PDF data
|
|
4
|
+
* @param pages - Array of page numbers to extract (1-indexed)
|
|
5
|
+
* @returns Buffer containing a new PDF with only the specified pages
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractPdfPages(pdfBytes: Buffer, pages: number[]): Promise<Buffer>;
|
|
8
|
+
/**
|
|
9
|
+
* Get the total number of pages in a PDF
|
|
10
|
+
* @param pdfBytes - Buffer containing the PDF data
|
|
11
|
+
* @returns Total number of pages
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPdfPageCount(pdfBytes: Buffer): Promise<number>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getFileExtension, getMimeType, isImageExtension, isPdfExtension, } from "./detectMimeType.js";
|
|
2
|
+
export { extractPdfPages, getPdfPageCount } from "./extractPdfPages.js";
|
|
3
|
+
export { loadLocalFile } from "./loadLocalFile.js";
|
|
4
|
+
export { loadS3File } from "./loadS3File.js";
|
|
5
|
+
export { resolveOperateInput } from "./resolveOperateInput.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LlmInputMessage, LlmOperateInput } from "../types/LlmProvider.interface.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve LlmOperateInput to LlmInputMessage
|
|
4
|
+
*
|
|
5
|
+
* This function takes the simplified LlmOperateInput format and resolves
|
|
6
|
+
* all files/images from their sources (provided data, S3, or local filesystem),
|
|
7
|
+
* converting them to the standard LlmInputMessage format.
|
|
8
|
+
*
|
|
9
|
+
* @param input - LlmOperateInput array
|
|
10
|
+
* @returns LlmInputMessage ready for LLM providers
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveOperateInput(input: LlmOperateInput): Promise<LlmInputMessage>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LlmHistory } from "../types/LlmProvider.interface.js";
|
|
2
|
+
/**
|
|
3
|
+
* Extracts reasoning text from LLM history items.
|
|
4
|
+
*
|
|
5
|
+
* Reasoning items may have text in different locations depending on the provider:
|
|
6
|
+
* - OpenAI: `summary` array with objects containing `text` property (type: "reasoning")
|
|
7
|
+
* - OpenAI: `content` property on reasoning items (type: "reasoning")
|
|
8
|
+
* - Anthropic: `thinking` property on thinking items (type: "thinking")
|
|
9
|
+
* - OpenRouter/z-ai: `reasoning` property on message items
|
|
10
|
+
*
|
|
11
|
+
* @param history - The LLM history array to extract reasoning from
|
|
12
|
+
* @returns Array of reasoning text strings
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractReasoning(history: LlmHistory): string[];
|
package/dist/cjs/util/index.d.ts
CHANGED
package/dist/esm/Llm.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JsonObject } from "@jaypie/types";
|
|
2
2
|
import { LlmProviderName } from "./constants.js";
|
|
3
|
-
import {
|
|
3
|
+
import { LlmHistory, LlmInputMessage, LlmMessageOptions, LlmOperateInput, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider } from "./types/LlmProvider.interface.js";
|
|
4
4
|
import { LlmStreamChunk } from "./types/LlmStreamChunk.interface.js";
|
|
5
5
|
declare class Llm implements LlmProvider {
|
|
6
6
|
private _provider;
|
|
@@ -9,19 +9,19 @@ declare class Llm implements LlmProvider {
|
|
|
9
9
|
constructor(providerName?: LlmProviderName | string, options?: LlmOptions);
|
|
10
10
|
private createProvider;
|
|
11
11
|
send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
|
|
12
|
-
operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
13
|
-
stream(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
|
|
12
|
+
operate(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
13
|
+
stream(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
|
|
14
14
|
static send(message: string, options?: LlmMessageOptions & {
|
|
15
15
|
llm?: LlmProviderName;
|
|
16
16
|
apiKey?: string;
|
|
17
17
|
model?: string;
|
|
18
18
|
}): Promise<string | JsonObject>;
|
|
19
|
-
static operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions & {
|
|
19
|
+
static operate(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions & {
|
|
20
20
|
llm?: LlmProviderName;
|
|
21
21
|
apiKey?: string;
|
|
22
22
|
model?: string;
|
|
23
23
|
}): Promise<LlmOperateResponse>;
|
|
24
|
-
static stream(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions & {
|
|
24
|
+
static stream(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions & {
|
|
25
25
|
llm?: LlmProviderName;
|
|
26
26
|
apiKey?: string;
|
|
27
27
|
model?: string;
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare const PROVIDER: {
|
|
2
2
|
readonly OPENROUTER: {
|
|
3
3
|
readonly MODEL: {
|
|
4
|
-
readonly DEFAULT: "
|
|
5
|
-
readonly SMALL: "
|
|
6
|
-
readonly LARGE: "
|
|
7
|
-
readonly TINY: "
|
|
4
|
+
readonly DEFAULT: "z-ai/glm-4.7";
|
|
5
|
+
readonly SMALL: "z-ai/glm-4.7";
|
|
6
|
+
readonly LARGE: "z-ai/glm-4.7";
|
|
7
|
+
readonly TINY: "z-ai/glm-4.7";
|
|
8
8
|
};
|
|
9
9
|
readonly MODEL_MATCH_WORDS: readonly ["openrouter"];
|
|
10
10
|
readonly NAME: "openrouter";
|
|
@@ -17,17 +17,19 @@ export declare const PROVIDER: {
|
|
|
17
17
|
};
|
|
18
18
|
readonly GEMINI: {
|
|
19
19
|
readonly MODEL: {
|
|
20
|
-
readonly DEFAULT: "gemini-
|
|
21
|
-
readonly
|
|
22
|
-
readonly
|
|
20
|
+
readonly DEFAULT: "gemini-3-pro-preview";
|
|
21
|
+
readonly LARGE: "gemini-3-pro-preview";
|
|
22
|
+
readonly SMALL: "gemini-3-flash-preview";
|
|
23
23
|
readonly TINY: "gemini-2.0-flash-lite";
|
|
24
|
-
readonly
|
|
24
|
+
readonly GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview";
|
|
25
|
+
readonly GEMINI_3_PRO_PREVIEW: "gemini-3-pro-preview";
|
|
25
26
|
readonly GEMINI_2_5_FLASH: "gemini-2.5-flash";
|
|
27
|
+
readonly GEMINI_2_5_PRO: "gemini-2.5-pro";
|
|
26
28
|
readonly GEMINI_2_0_FLASH: "gemini-2.0-flash";
|
|
27
29
|
readonly GEMINI_2_0_FLASH_LITE: "gemini-2.0-flash-lite";
|
|
28
|
-
readonly GEMINI_1_5_PRO: "gemini-1.5-pro";
|
|
29
30
|
readonly GEMINI_1_5_FLASH: "gemini-1.5-flash";
|
|
30
31
|
readonly GEMINI_1_5_FLASH_8B: "gemini-1.5-flash-8b";
|
|
32
|
+
readonly GEMINI_1_5_PRO: "gemini-1.5-pro";
|
|
31
33
|
};
|
|
32
34
|
readonly MODEL_MATCH_WORDS: readonly ["gemini", "google"];
|
|
33
35
|
readonly NAME: "gemini";
|
|
@@ -77,10 +79,10 @@ export declare const PROVIDER: {
|
|
|
77
79
|
};
|
|
78
80
|
readonly OPENAI: {
|
|
79
81
|
readonly MODEL: {
|
|
80
|
-
readonly DEFAULT: "gpt-
|
|
81
|
-
readonly SMALL: "gpt-
|
|
82
|
-
readonly LARGE: "gpt-
|
|
83
|
-
readonly TINY: "gpt-
|
|
82
|
+
readonly DEFAULT: "gpt-4.1";
|
|
83
|
+
readonly SMALL: "gpt-4.1-mini";
|
|
84
|
+
readonly LARGE: "gpt-4.1";
|
|
85
|
+
readonly TINY: "gpt-4.1-nano";
|
|
84
86
|
readonly GPT_5: "gpt-5";
|
|
85
87
|
readonly GPT_5_MINI: "gpt-5-mini";
|
|
86
88
|
readonly GPT_5_NANO: "gpt-5-nano";
|
|
@@ -108,10 +110,10 @@ export type LlmProviderName = typeof PROVIDER.ANTHROPIC.NAME | typeof PROVIDER.G
|
|
|
108
110
|
export declare const DEFAULT: {
|
|
109
111
|
readonly PROVIDER: {
|
|
110
112
|
readonly MODEL: {
|
|
111
|
-
readonly DEFAULT: "gpt-
|
|
112
|
-
readonly SMALL: "gpt-
|
|
113
|
-
readonly LARGE: "gpt-
|
|
114
|
-
readonly TINY: "gpt-
|
|
113
|
+
readonly DEFAULT: "gpt-4.1";
|
|
114
|
+
readonly SMALL: "gpt-4.1-mini";
|
|
115
|
+
readonly LARGE: "gpt-4.1";
|
|
116
|
+
readonly TINY: "gpt-4.1-nano";
|
|
115
117
|
readonly GPT_5: "gpt-5";
|
|
116
118
|
readonly GPT_5_MINI: "gpt-5-mini";
|
|
117
119
|
readonly GPT_5_NANO: "gpt-5-nano";
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { default as Llm } from "./Llm.js";
|
|
2
2
|
export * as LLM from "./constants.js";
|
|
3
|
-
export type { LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider, } from "./types/LlmProvider.interface.js";
|
|
3
|
+
export type { LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider, } from "./types/LlmProvider.interface.js";
|
|
4
4
|
export { LlmMessageRole, LlmMessageType, } from "./types/LlmProvider.interface.js";
|
|
5
|
+
export { isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, } from "./types/LlmOperateInput.guards.js";
|
|
5
6
|
export type { LlmTool } from "./types/LlmTool.interface.js";
|
|
6
7
|
export type { LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, } from "./types/LlmStreamChunk.interface.js";
|
|
7
8
|
export { LlmStreamChunkType } from "./types/LlmStreamChunk.interface.js";
|
|
8
9
|
export { JaypieToolkit, toolkit, Toolkit, tools } from "./tools/index.js";
|
|
10
|
+
export { extractReasoning } from "./util/extractReasoning.js";
|
|
9
11
|
export { GeminiProvider } from "./providers/gemini/index.js";
|
|
10
12
|
export { OpenRouterProvider } from "./providers/openrouter/index.js";
|