@jaypie/llm 1.1.22 → 1.1.24
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/constants.d.ts +42 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +458 -108
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic/AnthropicProvider.class.d.ts +15 -0
- package/dist/providers/anthropic/operate.d.ts +16 -0
- package/dist/providers/anthropic/utils.d.ts +7 -3
- package/dist/providers/openai/types.d.ts +9 -1
- package/dist/providers/openai/utils.d.ts +1 -1
- package/dist/tools/index.d.ts +10 -2
- package/dist/util/naturalZodSchema.d.ts +1 -1
- package/package.json +5 -4
- package/dist/providers/AnthropicProvider.class.d.ts +0 -20
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JsonObject } from "@jaypie/types";
|
|
2
|
+
import { LlmHistory, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmOperateResponse, LlmProvider } from "../../types/LlmProvider.interface.js";
|
|
3
|
+
export declare class AnthropicProvider implements LlmProvider {
|
|
4
|
+
private model;
|
|
5
|
+
private _client?;
|
|
6
|
+
private apiKey?;
|
|
7
|
+
private log;
|
|
8
|
+
private conversationHistory;
|
|
9
|
+
constructor(model?: string, { apiKey }?: {
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
});
|
|
12
|
+
private getClient;
|
|
13
|
+
send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
|
|
14
|
+
operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Anthropic } from "@anthropic-ai/sdk";
|
|
2
|
+
import { LlmHistory, LlmInputMessage, LlmOperateOptions, LlmOperateResponse } from "../../types/LlmProvider.interface.js";
|
|
3
|
+
import { LlmTool } from "../../types/LlmTool.interface.js";
|
|
4
|
+
/**
|
|
5
|
+
* OpenAI request options type that includes model and input properties
|
|
6
|
+
*/
|
|
7
|
+
export type AnthropicRequestOptions = Omit<LlmOperateOptions, "tools"> & {
|
|
8
|
+
model: string;
|
|
9
|
+
input: LlmInputMessage | LlmHistory;
|
|
10
|
+
text?: unknown;
|
|
11
|
+
tools?: Omit<LlmTool, "call">[];
|
|
12
|
+
};
|
|
13
|
+
export declare function operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions, context?: {
|
|
14
|
+
client: Anthropic;
|
|
15
|
+
maxRetries?: number;
|
|
16
|
+
}): Promise<LlmOperateResponse>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { log
|
|
1
|
+
import { log } from "@jaypie/core";
|
|
2
2
|
import Anthropic from "@anthropic-ai/sdk";
|
|
3
3
|
import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
|
|
4
|
+
import { z } from "zod/v4";
|
|
5
|
+
import { JsonObject, NaturalSchema } from "@jaypie/types";
|
|
4
6
|
export declare const getLogger: () => {
|
|
5
7
|
debug: {
|
|
6
8
|
(...args: unknown[]): void;
|
|
@@ -27,14 +29,14 @@ export declare const getLogger: () => {
|
|
|
27
29
|
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
28
30
|
};
|
|
29
31
|
var(key: string | Record<string, unknown>, value?: unknown): void;
|
|
30
|
-
with(tags: Record<string, unknown>): typeof
|
|
32
|
+
with(tags: Record<string, unknown>): typeof log;
|
|
31
33
|
tag(key: string | string[] | Record<string, unknown> | null, value?: string): void;
|
|
32
34
|
untag(tags: string | string[] | Record<string, unknown> | null): void;
|
|
33
35
|
lib(options: {
|
|
34
36
|
level?: string;
|
|
35
37
|
lib?: string;
|
|
36
38
|
tags?: Record<string, unknown>;
|
|
37
|
-
}): typeof
|
|
39
|
+
}): typeof log;
|
|
38
40
|
};
|
|
39
41
|
export declare function initializeClient({ apiKey, }?: {
|
|
40
42
|
apiKey?: string;
|
|
@@ -42,3 +44,5 @@ export declare function initializeClient({ apiKey, }?: {
|
|
|
42
44
|
export declare function formatSystemMessage(systemPrompt: string, { data, placeholders }?: Pick<LlmMessageOptions, "data" | "placeholders">): string;
|
|
43
45
|
export declare function formatUserMessage(message: string, { data, placeholders }?: Pick<LlmMessageOptions, "data" | "placeholders">): Anthropic.MessageParam;
|
|
44
46
|
export declare function prepareMessages(message: string, { data, placeholders }?: LlmMessageOptions): Anthropic.MessageParam[];
|
|
47
|
+
export declare function createTextCompletion(client: Anthropic, messages: Anthropic.MessageParam[], model: string, systemMessage?: string): Promise<string>;
|
|
48
|
+
export declare function createStructuredCompletion(client: Anthropic, messages: Anthropic.MessageParam[], model: string, responseSchema: z.ZodType | NaturalSchema, systemMessage?: string): Promise<JsonObject>;
|
|
@@ -33,10 +33,18 @@ export interface OpenAIFunctionCallOutput {
|
|
|
33
33
|
call_id: string;
|
|
34
34
|
output: string;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Represents a reasoning item in the OpenAI response (GPT-5)
|
|
38
|
+
*/
|
|
39
|
+
export interface OpenAIReasoningItem {
|
|
40
|
+
type: "reasoning";
|
|
41
|
+
id: string;
|
|
42
|
+
content?: string;
|
|
43
|
+
}
|
|
36
44
|
/**
|
|
37
45
|
* Union type for all possible response items
|
|
38
46
|
*/
|
|
39
|
-
export type OpenAIResponseItem = OpenAIFunctionCall | OpenAIMessage | OpenAIFunctionCallOutput;
|
|
47
|
+
export type OpenAIResponseItem = OpenAIFunctionCall | OpenAIMessage | OpenAIFunctionCallOutput | OpenAIReasoningItem;
|
|
40
48
|
/**
|
|
41
49
|
* Represents token usage information in the OpenAI response
|
|
42
50
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { log as defaultLog } from "@jaypie/core";
|
|
2
2
|
import { JsonObject, NaturalSchema } from "@jaypie/types";
|
|
3
3
|
import { OpenAI } from "openai";
|
|
4
|
-
import { z } from "zod";
|
|
4
|
+
import { z } from "zod/v4";
|
|
5
5
|
import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
|
|
6
6
|
export declare const getLogger: () => {
|
|
7
7
|
debug: {
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { Toolkit } from "./Toolkit.class.js";
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
2
|
+
import type { LlmTool } from "../types/LlmTool.interface.js";
|
|
3
|
+
export declare const tools: LlmTool[];
|
|
4
|
+
export declare class JaypieToolkit extends Toolkit {
|
|
5
|
+
readonly random: LlmTool;
|
|
6
|
+
readonly roll: LlmTool;
|
|
7
|
+
readonly time: LlmTool;
|
|
8
|
+
readonly weather: LlmTool;
|
|
9
|
+
constructor(tools: LlmTool[], options?: any);
|
|
10
|
+
}
|
|
11
|
+
export declare const toolkit: JaypieToolkit;
|
|
4
12
|
export { Toolkit };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaypie/llm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.24",
|
|
4
4
|
"description": "Large language model utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Finlayson Studio",
|
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
"typecheck": "tsc --noEmit"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@anthropic-ai/sdk": "^0.
|
|
28
|
+
"@anthropic-ai/sdk": "^0.52.0",
|
|
29
29
|
"@jaypie/aws": "^1.1.15",
|
|
30
|
-
"@jaypie/core": "^1.1.
|
|
30
|
+
"@jaypie/core": "^1.1.2",
|
|
31
31
|
"@jaypie/errors": "^1.1.5",
|
|
32
32
|
"openai": "^4.87.3",
|
|
33
33
|
"openmeteo": "^1.2.0",
|
|
34
34
|
"random": "^5.3.0",
|
|
35
|
+
"z-schema": "^6.0.2",
|
|
35
36
|
"zod": "^3.24.1"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
@@ -40,5 +41,5 @@
|
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "ff4cd0b0f127b7922f4a6532c895b1fb448f56e0"
|
|
44
45
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { JsonObject } from "@jaypie/types";
|
|
2
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
3
|
-
import { LlmHistory, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmOperateResponse, LlmProvider } from "../types/LlmProvider.interface.js";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
export declare class AnthropicProvider implements LlmProvider {
|
|
6
|
-
private model;
|
|
7
|
-
private _client?;
|
|
8
|
-
private apiKey?;
|
|
9
|
-
private log;
|
|
10
|
-
private conversationHistory;
|
|
11
|
-
constructor(model?: string, { apiKey }?: {
|
|
12
|
-
apiKey?: string;
|
|
13
|
-
});
|
|
14
|
-
private getClient;
|
|
15
|
-
createTextCompletion(client: Anthropic, messages: Anthropic.MessageParam[], model: string, systemMessage?: string): Promise<string>;
|
|
16
|
-
createStructuredCompletion(client: Anthropic, messages: Anthropic.MessageParam[], model: string, responseSchema: z.ZodType | JsonObject, systemMessage?: string): Promise<JsonObject>;
|
|
17
|
-
private simplifyZodSchema;
|
|
18
|
-
send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
|
|
19
|
-
operate(input: string | LlmHistory | LlmInputMessage, _options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
20
|
-
}
|