@mariozechner/pi-ai 0.5.10
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/README.md +231 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +72 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.generated.d.ts +2890 -0
- package/dist/models.generated.d.ts.map +1 -0
- package/dist/models.generated.js +2889 -0
- package/dist/models.generated.js.map +1 -0
- package/dist/models.js +71 -0
- package/dist/models.js.map +1 -0
- package/dist/providers/anthropic.d.ts +23 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +312 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/google.d.ts +20 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +337 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/openai-completions.d.ts +21 -0
- package/dist/providers/openai-completions.d.ts.map +1 -0
- package/dist/providers/openai-completions.js +304 -0
- package/dist/providers/openai-completions.js.map +1 -0
- package/dist/providers/openai-responses.d.ts +16 -0
- package/dist/providers/openai-responses.d.ts.map +1 -0
- package/dist/providers/openai-responses.js +261 -0
- package/dist/providers/openai-responses.js.map +1 -0
- package/dist/types.d.ts +119 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export interface LLMOptions {
|
|
2
|
+
temperature?: number;
|
|
3
|
+
maxTokens?: number;
|
|
4
|
+
onText?: (text: string, complete: boolean) => void;
|
|
5
|
+
onThinking?: (thinking: string, complete: boolean) => void;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}
|
|
8
|
+
export interface LLM<T extends LLMOptions> {
|
|
9
|
+
complete(request: Context, options?: T): Promise<AssistantMessage>;
|
|
10
|
+
getModel(): Model;
|
|
11
|
+
}
|
|
12
|
+
export interface TextContent {
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ImageContent {
|
|
17
|
+
type: "image";
|
|
18
|
+
data: string;
|
|
19
|
+
mimeType: string;
|
|
20
|
+
}
|
|
21
|
+
export interface UserMessage {
|
|
22
|
+
role: "user";
|
|
23
|
+
content: string | (TextContent | ImageContent)[];
|
|
24
|
+
}
|
|
25
|
+
export interface AssistantMessage {
|
|
26
|
+
role: "assistant";
|
|
27
|
+
thinking?: string;
|
|
28
|
+
thinkingSignature?: string;
|
|
29
|
+
content?: string;
|
|
30
|
+
toolCalls?: {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
arguments: Record<string, any>;
|
|
34
|
+
}[];
|
|
35
|
+
provider: string;
|
|
36
|
+
model: string;
|
|
37
|
+
usage: Usage;
|
|
38
|
+
stopReason: StopReason;
|
|
39
|
+
error?: string | Error;
|
|
40
|
+
}
|
|
41
|
+
export interface ToolResultMessage {
|
|
42
|
+
role: "toolResult";
|
|
43
|
+
content: string;
|
|
44
|
+
toolCallId: string;
|
|
45
|
+
isError: boolean;
|
|
46
|
+
}
|
|
47
|
+
export type Message = UserMessage | AssistantMessage | ToolResultMessage;
|
|
48
|
+
export interface Tool {
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
parameters: Record<string, any>;
|
|
52
|
+
}
|
|
53
|
+
export interface Context {
|
|
54
|
+
systemPrompt?: string;
|
|
55
|
+
messages: Message[];
|
|
56
|
+
tools?: Tool[];
|
|
57
|
+
}
|
|
58
|
+
export type Event = {
|
|
59
|
+
type: "start";
|
|
60
|
+
model: string;
|
|
61
|
+
provider: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "text";
|
|
64
|
+
content: string;
|
|
65
|
+
delta: string;
|
|
66
|
+
} | {
|
|
67
|
+
type: "thinking";
|
|
68
|
+
content: string;
|
|
69
|
+
delta: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: "toolCall";
|
|
72
|
+
toolCall: ToolCall;
|
|
73
|
+
} | {
|
|
74
|
+
type: "usage";
|
|
75
|
+
usage: Usage;
|
|
76
|
+
} | {
|
|
77
|
+
type: "done";
|
|
78
|
+
reason: StopReason;
|
|
79
|
+
message: AssistantMessage;
|
|
80
|
+
} | {
|
|
81
|
+
type: "error";
|
|
82
|
+
error: Error;
|
|
83
|
+
};
|
|
84
|
+
export interface ToolCall {
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
arguments: Record<string, any>;
|
|
88
|
+
}
|
|
89
|
+
export interface Usage {
|
|
90
|
+
input: number;
|
|
91
|
+
output: number;
|
|
92
|
+
cacheRead: number;
|
|
93
|
+
cacheWrite: number;
|
|
94
|
+
cost: {
|
|
95
|
+
input: number;
|
|
96
|
+
output: number;
|
|
97
|
+
cacheRead: number;
|
|
98
|
+
cacheWrite: number;
|
|
99
|
+
total: number;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export type StopReason = "stop" | "length" | "toolUse" | "safety" | "error";
|
|
103
|
+
export interface Model {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
provider: string;
|
|
107
|
+
baseUrl?: string;
|
|
108
|
+
reasoning: boolean;
|
|
109
|
+
input: ("text" | "image")[];
|
|
110
|
+
cost: {
|
|
111
|
+
input: number;
|
|
112
|
+
output: number;
|
|
113
|
+
cacheRead: number;
|
|
114
|
+
cacheWrite: number;
|
|
115
|
+
};
|
|
116
|
+
contextWindow: number;
|
|
117
|
+
maxTokens: number;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IAC1B,WAAW,CAAC,EAAE,MAAM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A;CAAE,CAAC;AAEnC,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,KAAK;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;CACF;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAG5E,MAAM,WAAW,KAAK;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC5B,IAAI,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mariozechner/pi-ai",
|
|
3
|
+
"version": "0.5.10",
|
|
4
|
+
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"generate-models": "npx tsx scripts/generate-models.ts",
|
|
15
|
+
"build": "npm run generate-models && tsc -p tsconfig.build.json",
|
|
16
|
+
"check": "biome check --write .",
|
|
17
|
+
"test": "vitest --run",
|
|
18
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@anthropic-ai/sdk": "^0.60.0",
|
|
22
|
+
"@google/genai": "^1.15.0",
|
|
23
|
+
"chalk": "^5.5.0",
|
|
24
|
+
"openai": "^5.15.0"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"ai",
|
|
28
|
+
"llm",
|
|
29
|
+
"openai",
|
|
30
|
+
"anthropic",
|
|
31
|
+
"gemini",
|
|
32
|
+
"unified",
|
|
33
|
+
"api"
|
|
34
|
+
],
|
|
35
|
+
"author": "Mario Zechner",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/badlogic/pi-mono.git",
|
|
40
|
+
"directory": "packages/ai"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=20.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^24.3.0",
|
|
47
|
+
"canvas": "^3.2.0",
|
|
48
|
+
"vitest": "^3.2.4"
|
|
49
|
+
}
|
|
50
|
+
}
|