ai 0.0.0-85f9a635-20240518005312 → 0.0.0-9477ebb9-20250403064906
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/CHANGELOG.md +3521 -0
- package/README.md +112 -22
- package/dist/index.d.mts +3697 -1642
- package/dist/index.d.ts +3697 -1642
- package/dist/index.js +7201 -2942
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7249 -2963
- package/dist/index.mjs.map +1 -1
- package/mcp-stdio/create-child-process.test.ts +92 -0
- package/mcp-stdio/create-child-process.ts +21 -0
- package/mcp-stdio/dist/index.d.mts +169 -0
- package/mcp-stdio/dist/index.d.ts +169 -0
- package/mcp-stdio/dist/index.js +352 -0
- package/mcp-stdio/dist/index.js.map +1 -0
- package/mcp-stdio/dist/index.mjs +337 -0
- package/mcp-stdio/dist/index.mjs.map +1 -0
- package/mcp-stdio/get-environment.ts +43 -0
- package/mcp-stdio/index.ts +4 -0
- package/mcp-stdio/mcp-stdio-transport.test.ts +262 -0
- package/mcp-stdio/mcp-stdio-transport.ts +157 -0
- package/package.json +46 -103
- package/react/dist/index.d.mts +10 -557
- package/react/dist/index.d.ts +10 -574
- package/react/dist/index.js +6 -1397
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +10 -1384
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/index.d.ts +432 -199
- package/rsc/dist/rsc-server.d.mts +431 -199
- package/rsc/dist/rsc-server.mjs +1599 -1357
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.d.mts +30 -23
- package/rsc/dist/rsc-shared.mjs +70 -108
- package/rsc/dist/rsc-shared.mjs.map +1 -1
- package/test/dist/index.d.mts +65 -0
- package/test/dist/index.d.ts +65 -0
- package/test/dist/index.js +121 -0
- package/test/dist/index.js.map +1 -0
- package/test/dist/index.mjs +94 -0
- package/test/dist/index.mjs.map +1 -0
- package/prompts/dist/index.d.mts +0 -324
- package/prompts/dist/index.d.ts +0 -324
- package/prompts/dist/index.js +0 -178
- package/prompts/dist/index.js.map +0 -1
- package/prompts/dist/index.mjs +0 -146
- package/prompts/dist/index.mjs.map +0 -1
- package/react/dist/index.server.d.mts +0 -17
- package/react/dist/index.server.d.ts +0 -17
- package/react/dist/index.server.js +0 -50
- package/react/dist/index.server.js.map +0 -1
- package/react/dist/index.server.mjs +0 -23
- package/react/dist/index.server.mjs.map +0 -1
- package/solid/dist/index.d.mts +0 -408
- package/solid/dist/index.d.ts +0 -408
- package/solid/dist/index.js +0 -1072
- package/solid/dist/index.js.map +0 -1
- package/solid/dist/index.mjs +0 -1044
- package/solid/dist/index.mjs.map +0 -1
- package/svelte/dist/index.d.mts +0 -484
- package/svelte/dist/index.d.ts +0 -484
- package/svelte/dist/index.js +0 -1778
- package/svelte/dist/index.js.map +0 -1
- package/svelte/dist/index.mjs +0 -1749
- package/svelte/dist/index.mjs.map +0 -1
- package/vue/dist/index.d.mts +0 -402
- package/vue/dist/index.d.ts +0 -402
- package/vue/dist/index.js +0 -1072
- package/vue/dist/index.js.map +0 -1
- package/vue/dist/index.mjs +0 -1034
- package/vue/dist/index.mjs.map +0 -1
package/prompts/dist/index.d.ts
DELETED
@@ -1,324 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
Typed tool call that is returned by generateText and streamText.
|
3
|
-
It contains the tool call ID, the tool name, and the tool arguments.
|
4
|
-
*/
|
5
|
-
interface ToolCall$1<NAME extends string, ARGS> {
|
6
|
-
/**
|
7
|
-
ID of the tool call. This ID is used to match the tool call with the tool result.
|
8
|
-
*/
|
9
|
-
toolCallId: string;
|
10
|
-
/**
|
11
|
-
Name of the tool that is being called.
|
12
|
-
*/
|
13
|
-
toolName: NAME;
|
14
|
-
/**
|
15
|
-
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
16
|
-
*/
|
17
|
-
args: ARGS;
|
18
|
-
}
|
19
|
-
|
20
|
-
/**
|
21
|
-
Typed tool result that is returned by generateText and streamText.
|
22
|
-
It contains the tool call ID, the tool name, the tool arguments, and the tool result.
|
23
|
-
*/
|
24
|
-
interface ToolResult<NAME extends string, ARGS, RESULT> {
|
25
|
-
/**
|
26
|
-
ID of the tool call. This ID is used to match the tool call with the tool result.
|
27
|
-
*/
|
28
|
-
toolCallId: string;
|
29
|
-
/**
|
30
|
-
Name of the tool that was called.
|
31
|
-
*/
|
32
|
-
toolName: NAME;
|
33
|
-
/**
|
34
|
-
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
35
|
-
*/
|
36
|
-
args: ARGS;
|
37
|
-
/**
|
38
|
-
Result of the tool call. This is the result of the tool's execution.
|
39
|
-
*/
|
40
|
-
result: RESULT;
|
41
|
-
}
|
42
|
-
|
43
|
-
interface FunctionCall {
|
44
|
-
/**
|
45
|
-
* The arguments to call the function with, as generated by the model in JSON
|
46
|
-
* format. Note that the model does not always generate valid JSON, and may
|
47
|
-
* hallucinate parameters not defined by your function schema. Validate the
|
48
|
-
* arguments in your code before calling your function.
|
49
|
-
*/
|
50
|
-
arguments?: string;
|
51
|
-
/**
|
52
|
-
* The name of the function to call.
|
53
|
-
*/
|
54
|
-
name?: string;
|
55
|
-
}
|
56
|
-
/**
|
57
|
-
* The tool calls generated by the model, such as function calls.
|
58
|
-
*/
|
59
|
-
interface ToolCall {
|
60
|
-
id: string;
|
61
|
-
type: string;
|
62
|
-
function: {
|
63
|
-
name: string;
|
64
|
-
arguments: string;
|
65
|
-
};
|
66
|
-
}
|
67
|
-
/**
|
68
|
-
Tool invocations are either tool calls or tool results. For each assistant tool call,
|
69
|
-
there is one tool invocation. While the call is in progress, the invocation is a tool call.
|
70
|
-
Once the call is complete, the invocation is a tool result.
|
71
|
-
*/
|
72
|
-
type ToolInvocation = ToolCall$1<string, any> | ToolResult<string, any, any>;
|
73
|
-
/**
|
74
|
-
* Shared types between the API and UI packages.
|
75
|
-
*/
|
76
|
-
interface Message {
|
77
|
-
id: string;
|
78
|
-
tool_call_id?: string;
|
79
|
-
createdAt?: Date;
|
80
|
-
content: string;
|
81
|
-
/**
|
82
|
-
@deprecated Use AI SDK RSC instead: https://sdk.vercel.ai/docs/ai-sdk-rsc
|
83
|
-
*/
|
84
|
-
ui?: string | JSX.Element | JSX.Element[] | null | undefined;
|
85
|
-
role: 'system' | 'user' | 'assistant' | 'function' | 'data' | 'tool';
|
86
|
-
/**
|
87
|
-
*
|
88
|
-
* If the message has a role of `function`, the `name` field is the name of the function.
|
89
|
-
* Otherwise, the name field should not be set.
|
90
|
-
*/
|
91
|
-
name?: string;
|
92
|
-
/**
|
93
|
-
* If the assistant role makes a function call, the `function_call` field
|
94
|
-
* contains the function call name and arguments. Otherwise, the field should
|
95
|
-
* not be set. (Deprecated and replaced by tool_calls.)
|
96
|
-
*/
|
97
|
-
function_call?: string | FunctionCall;
|
98
|
-
data?: JSONValue;
|
99
|
-
/**
|
100
|
-
* If the assistant role makes a tool call, the `tool_calls` field contains
|
101
|
-
* the tool call name and arguments. Otherwise, the field should not be set.
|
102
|
-
*/
|
103
|
-
tool_calls?: string | ToolCall[];
|
104
|
-
/**
|
105
|
-
* Additional message-specific information added on the server via StreamData
|
106
|
-
*/
|
107
|
-
annotations?: JSONValue[] | undefined;
|
108
|
-
/**
|
109
|
-
Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
|
110
|
-
that the assistant made as part of this message.
|
111
|
-
*/
|
112
|
-
toolInvocations?: Array<ToolInvocation>;
|
113
|
-
}
|
114
|
-
type JSONValue = null | string | number | boolean | {
|
115
|
-
[x: string]: JSONValue;
|
116
|
-
} | Array<JSONValue>;
|
117
|
-
|
118
|
-
/**
|
119
|
-
* A prompt constructor for Anthropic models.
|
120
|
-
* Does not support `function` messages.
|
121
|
-
* @see https://docs.anthropic.com/claude/reference/getting-started-with-the-api
|
122
|
-
*/
|
123
|
-
declare function experimental_buildAnthropicPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
|
124
|
-
/**
|
125
|
-
* A prompt constructor for Anthropic V3 models which require Messages API.
|
126
|
-
* Does not support message with image content
|
127
|
-
* @see https://docs.anthropic.com/claude/reference/messages_post
|
128
|
-
*/
|
129
|
-
declare function experimental_buildAnthropicMessages(messages: Pick<Message, 'content' | 'role'>[]): {
|
130
|
-
role: "function" | "system" | "user" | "assistant" | "data" | "tool";
|
131
|
-
content: {
|
132
|
-
type: string;
|
133
|
-
text: string;
|
134
|
-
}[];
|
135
|
-
}[];
|
136
|
-
|
137
|
-
/**
|
138
|
-
* A prompt constructor for the HuggingFace StarChat Beta model.
|
139
|
-
* Does not support `function` messages.
|
140
|
-
* @see https://huggingface.co/HuggingFaceH4/starchat-beta
|
141
|
-
*/
|
142
|
-
declare function experimental_buildStarChatBetaPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
|
143
|
-
/**
|
144
|
-
* A prompt constructor for HuggingFace OpenAssistant models.
|
145
|
-
* Does not support `function` or `system` messages.
|
146
|
-
* @see https://huggingface.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5
|
147
|
-
*/
|
148
|
-
declare function experimental_buildOpenAssistantPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
|
149
|
-
/**
|
150
|
-
* A prompt constructor for HuggingFace LLama 2 chat models.
|
151
|
-
* Does not support `function` messages.
|
152
|
-
* @see https://huggingface.co/meta-llama/Llama-2-70b-chat-hf and https://huggingface.co/blog/llama2#how-to-prompt-llama-2
|
153
|
-
*/
|
154
|
-
declare function experimental_buildLlama2Prompt(messages: Pick<Message, 'content' | 'role'>[]): string;
|
155
|
-
|
156
|
-
declare function experimental_buildOpenAIMessages(messages: Message[]): ChatCompletionMessageParam[];
|
157
|
-
type ChatCompletionMessageParam = ChatCompletionSystemMessageParam | ChatCompletionUserMessageParam | ChatCompletionAssistantMessageParam | ChatCompletionToolMessageParam | ChatCompletionFunctionMessageParam;
|
158
|
-
interface ChatCompletionSystemMessageParam {
|
159
|
-
/**
|
160
|
-
* The contents of the system message.
|
161
|
-
*/
|
162
|
-
content: string;
|
163
|
-
/**
|
164
|
-
* The role of the messages author, in this case `system`.
|
165
|
-
*/
|
166
|
-
role: 'system';
|
167
|
-
/**
|
168
|
-
* An optional name for the participant. Provides the model information to
|
169
|
-
* differentiate between participants of the same role.
|
170
|
-
*/
|
171
|
-
name?: string;
|
172
|
-
}
|
173
|
-
interface ChatCompletionUserMessageParam {
|
174
|
-
/**
|
175
|
-
* The contents of the user message.
|
176
|
-
*/
|
177
|
-
content: string | Array<ChatCompletionContentPart>;
|
178
|
-
/**
|
179
|
-
* The role of the messages author, in this case `user`.
|
180
|
-
*/
|
181
|
-
role: 'user';
|
182
|
-
/**
|
183
|
-
* An optional name for the participant. Provides the model information to
|
184
|
-
* differentiate between participants of the same role.
|
185
|
-
*/
|
186
|
-
name?: string;
|
187
|
-
}
|
188
|
-
type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage;
|
189
|
-
interface ChatCompletionContentPartText {
|
190
|
-
/**
|
191
|
-
* The text content.
|
192
|
-
*/
|
193
|
-
text: string;
|
194
|
-
/**
|
195
|
-
* The type of the content part.
|
196
|
-
*/
|
197
|
-
type: 'text';
|
198
|
-
}
|
199
|
-
interface ChatCompletionContentPartImage {
|
200
|
-
image_url: ChatCompletionContentPartImage.ImageURL;
|
201
|
-
/**
|
202
|
-
* The type of the content part.
|
203
|
-
*/
|
204
|
-
type: 'image_url';
|
205
|
-
}
|
206
|
-
declare namespace ChatCompletionContentPartImage {
|
207
|
-
interface ImageURL {
|
208
|
-
/**
|
209
|
-
* Either a URL of the image or the base64 encoded image data.
|
210
|
-
*/
|
211
|
-
url: string;
|
212
|
-
/**
|
213
|
-
* Specifies the detail level of the image. Learn more in the
|
214
|
-
* [Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).
|
215
|
-
*/
|
216
|
-
detail?: 'auto' | 'low' | 'high';
|
217
|
-
}
|
218
|
-
}
|
219
|
-
interface ChatCompletionAssistantMessageParam {
|
220
|
-
/**
|
221
|
-
* The role of the messages author, in this case `assistant`.
|
222
|
-
*/
|
223
|
-
role: 'assistant';
|
224
|
-
/**
|
225
|
-
* The contents of the assistant message. Required unless `tool_calls` or
|
226
|
-
* `function_call` is specified.
|
227
|
-
*/
|
228
|
-
content?: string | null;
|
229
|
-
/**
|
230
|
-
* @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
|
231
|
-
* a function that should be called, as generated by the model.
|
232
|
-
*/
|
233
|
-
function_call?: ChatCompletionAssistantMessageParam.FunctionCall;
|
234
|
-
/**
|
235
|
-
* An optional name for the participant. Provides the model information to
|
236
|
-
* differentiate between participants of the same role.
|
237
|
-
*/
|
238
|
-
name?: string;
|
239
|
-
/**
|
240
|
-
* The tool calls generated by the model, such as function calls.
|
241
|
-
*/
|
242
|
-
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
243
|
-
}
|
244
|
-
declare namespace ChatCompletionAssistantMessageParam {
|
245
|
-
/**
|
246
|
-
* @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
|
247
|
-
* a function that should be called, as generated by the model.
|
248
|
-
*/
|
249
|
-
interface FunctionCall {
|
250
|
-
/**
|
251
|
-
* The arguments to call the function with, as generated by the model in JSON
|
252
|
-
* format. Note that the model does not always generate valid JSON, and may
|
253
|
-
* hallucinate parameters not defined by your function schema. Validate the
|
254
|
-
* arguments in your code before calling your function.
|
255
|
-
*/
|
256
|
-
arguments: string;
|
257
|
-
/**
|
258
|
-
* The name of the function to call.
|
259
|
-
*/
|
260
|
-
name: string;
|
261
|
-
}
|
262
|
-
}
|
263
|
-
interface ChatCompletionMessageToolCall {
|
264
|
-
/**
|
265
|
-
* The ID of the tool call.
|
266
|
-
*/
|
267
|
-
id: string;
|
268
|
-
/**
|
269
|
-
* The function that the model called.
|
270
|
-
*/
|
271
|
-
function: ChatCompletionMessageToolCall.Function;
|
272
|
-
/**
|
273
|
-
* The type of the tool. Currently, only `function` is supported.
|
274
|
-
*/
|
275
|
-
type: 'function';
|
276
|
-
}
|
277
|
-
declare namespace ChatCompletionMessageToolCall {
|
278
|
-
/**
|
279
|
-
* The function that the model called.
|
280
|
-
*/
|
281
|
-
interface Function {
|
282
|
-
/**
|
283
|
-
* The arguments to call the function with, as generated by the model in JSON
|
284
|
-
* format. Note that the model does not always generate valid JSON, and may
|
285
|
-
* hallucinate parameters not defined by your function schema. Validate the
|
286
|
-
* arguments in your code before calling your function.
|
287
|
-
*/
|
288
|
-
arguments: string;
|
289
|
-
/**
|
290
|
-
* The name of the function to call.
|
291
|
-
*/
|
292
|
-
name: string;
|
293
|
-
}
|
294
|
-
}
|
295
|
-
interface ChatCompletionToolMessageParam {
|
296
|
-
/**
|
297
|
-
* The contents of the tool message.
|
298
|
-
*/
|
299
|
-
content: string;
|
300
|
-
/**
|
301
|
-
* The role of the messages author, in this case `tool`.
|
302
|
-
*/
|
303
|
-
role: 'tool';
|
304
|
-
/**
|
305
|
-
* Tool call that this message is responding to.
|
306
|
-
*/
|
307
|
-
tool_call_id: string;
|
308
|
-
}
|
309
|
-
interface ChatCompletionFunctionMessageParam {
|
310
|
-
/**
|
311
|
-
* The return value from the function call, to return to the model.
|
312
|
-
*/
|
313
|
-
content: string | null;
|
314
|
-
/**
|
315
|
-
* The name of the function to call.
|
316
|
-
*/
|
317
|
-
name: string;
|
318
|
-
/**
|
319
|
-
* The role of the messages author, in this case `function`.
|
320
|
-
*/
|
321
|
-
role: 'function';
|
322
|
-
}
|
323
|
-
|
324
|
-
export { ChatCompletionAssistantMessageParam, ChatCompletionContentPart, ChatCompletionContentPartImage, ChatCompletionContentPartText, ChatCompletionFunctionMessageParam, ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionSystemMessageParam, ChatCompletionToolMessageParam, ChatCompletionUserMessageParam, experimental_buildAnthropicMessages, experimental_buildAnthropicPrompt, experimental_buildLlama2Prompt, experimental_buildOpenAIMessages, experimental_buildOpenAssistantPrompt, experimental_buildStarChatBetaPrompt };
|
package/prompts/dist/index.js
DELETED
@@ -1,178 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
|
20
|
-
// prompts/index.ts
|
21
|
-
var prompts_exports = {};
|
22
|
-
__export(prompts_exports, {
|
23
|
-
experimental_buildAnthropicMessages: () => experimental_buildAnthropicMessages,
|
24
|
-
experimental_buildAnthropicPrompt: () => experimental_buildAnthropicPrompt,
|
25
|
-
experimental_buildLlama2Prompt: () => experimental_buildLlama2Prompt,
|
26
|
-
experimental_buildOpenAIMessages: () => experimental_buildOpenAIMessages,
|
27
|
-
experimental_buildOpenAssistantPrompt: () => experimental_buildOpenAssistantPrompt,
|
28
|
-
experimental_buildStarChatBetaPrompt: () => experimental_buildStarChatBetaPrompt
|
29
|
-
});
|
30
|
-
module.exports = __toCommonJS(prompts_exports);
|
31
|
-
|
32
|
-
// prompts/anthropic.ts
|
33
|
-
function experimental_buildAnthropicPrompt(messages) {
|
34
|
-
return messages.map(({ content, role }) => {
|
35
|
-
if (role === "user") {
|
36
|
-
return `
|
37
|
-
|
38
|
-
Human: ${content}`;
|
39
|
-
} else {
|
40
|
-
return `
|
41
|
-
|
42
|
-
Assistant: ${content}`;
|
43
|
-
}
|
44
|
-
}) + "\n\nAssistant:";
|
45
|
-
}
|
46
|
-
function experimental_buildAnthropicMessages(messages) {
|
47
|
-
return messages.map(({ content, role }) => {
|
48
|
-
if (!["assistant", "user"].includes(role)) {
|
49
|
-
throw new Error(`Cannot use ${role} on Anthropic V3 Messages API`);
|
50
|
-
}
|
51
|
-
return {
|
52
|
-
role,
|
53
|
-
content: [{ type: "text", text: content }]
|
54
|
-
};
|
55
|
-
});
|
56
|
-
}
|
57
|
-
|
58
|
-
// prompts/huggingface.ts
|
59
|
-
function experimental_buildStarChatBetaPrompt(messages) {
|
60
|
-
return messages.map(({ content, role }) => {
|
61
|
-
if (role === "user") {
|
62
|
-
return `<|user|>
|
63
|
-
${content}<|end|>
|
64
|
-
`;
|
65
|
-
} else if (role === "assistant") {
|
66
|
-
return `<|assistant|>
|
67
|
-
${content}<|end|>
|
68
|
-
`;
|
69
|
-
} else if (role === "system") {
|
70
|
-
return `<|system|>
|
71
|
-
${content}<|end|>
|
72
|
-
`;
|
73
|
-
} else if (role === "function") {
|
74
|
-
throw new Error("StarChat Beta does not support function calls.");
|
75
|
-
}
|
76
|
-
}).join("") + "<|assistant|>";
|
77
|
-
}
|
78
|
-
function experimental_buildOpenAssistantPrompt(messages) {
|
79
|
-
return messages.map(({ content, role }) => {
|
80
|
-
if (role === "user") {
|
81
|
-
return `<|prompter|>${content}<|endoftext|>`;
|
82
|
-
} else if (role === "function") {
|
83
|
-
throw new Error("OpenAssistant does not support function calls.");
|
84
|
-
} else if (role === "system") {
|
85
|
-
throw new Error("OpenAssistant does not support system messages.");
|
86
|
-
} else {
|
87
|
-
return `<|assistant|>${content}<|endoftext|>`;
|
88
|
-
}
|
89
|
-
}).join("") + "<|assistant|>";
|
90
|
-
}
|
91
|
-
function experimental_buildLlama2Prompt(messages) {
|
92
|
-
const startPrompt = `<s>[INST] `;
|
93
|
-
const endPrompt = ` [/INST]`;
|
94
|
-
const conversation = messages.map(({ content, role }, index) => {
|
95
|
-
if (role === "user") {
|
96
|
-
return content.trim();
|
97
|
-
} else if (role === "assistant") {
|
98
|
-
return ` [/INST] ${content}</s><s>[INST] `;
|
99
|
-
} else if (role === "function") {
|
100
|
-
throw new Error("Llama 2 does not support function calls.");
|
101
|
-
} else if (role === "system" && index === 0) {
|
102
|
-
return `<<SYS>>
|
103
|
-
${content}
|
104
|
-
<</SYS>>
|
105
|
-
|
106
|
-
`;
|
107
|
-
} else {
|
108
|
-
throw new Error(`Invalid message role: ${role}`);
|
109
|
-
}
|
110
|
-
});
|
111
|
-
return startPrompt + conversation.join("") + endPrompt;
|
112
|
-
}
|
113
|
-
|
114
|
-
// prompts/openai.tsx
|
115
|
-
function experimental_buildOpenAIMessages(messages) {
|
116
|
-
return messages.map((message) => {
|
117
|
-
switch (message.role) {
|
118
|
-
case "system":
|
119
|
-
case "user":
|
120
|
-
return {
|
121
|
-
role: message.role,
|
122
|
-
content: message.content
|
123
|
-
};
|
124
|
-
case "assistant": {
|
125
|
-
const function_call = message.function_call;
|
126
|
-
if (function_call !== void 0 && (typeof function_call === "string" || function_call.arguments === void 0 || function_call.name === void 0)) {
|
127
|
-
throw new Error(
|
128
|
-
"Invalid function call in message. Expected a function call object"
|
129
|
-
);
|
130
|
-
}
|
131
|
-
return {
|
132
|
-
role: message.role,
|
133
|
-
content: message.content,
|
134
|
-
function_call: function_call === void 0 ? void 0 : {
|
135
|
-
name: function_call.name,
|
136
|
-
arguments: function_call.arguments
|
137
|
-
}
|
138
|
-
};
|
139
|
-
}
|
140
|
-
case "function": {
|
141
|
-
if (message.name === void 0) {
|
142
|
-
throw new Error("Invalid function call in message. Expected a name");
|
143
|
-
}
|
144
|
-
return {
|
145
|
-
role: message.role,
|
146
|
-
content: message.content,
|
147
|
-
name: message.name
|
148
|
-
};
|
149
|
-
}
|
150
|
-
case "data": {
|
151
|
-
throw "unsupported message role 'data'";
|
152
|
-
}
|
153
|
-
case "tool": {
|
154
|
-
if (message.name === void 0) {
|
155
|
-
throw new Error("Invalid tool message. Expected a name");
|
156
|
-
}
|
157
|
-
if (message.tool_call_id === void 0) {
|
158
|
-
throw new Error("Invalid tool message. Expected a tool_call_id");
|
159
|
-
}
|
160
|
-
return {
|
161
|
-
role: message.role,
|
162
|
-
content: message.content,
|
163
|
-
tool_call_id: message.tool_call_id
|
164
|
-
};
|
165
|
-
}
|
166
|
-
}
|
167
|
-
});
|
168
|
-
}
|
169
|
-
// Annotate the CommonJS export names for ESM import in node:
|
170
|
-
0 && (module.exports = {
|
171
|
-
experimental_buildAnthropicMessages,
|
172
|
-
experimental_buildAnthropicPrompt,
|
173
|
-
experimental_buildLlama2Prompt,
|
174
|
-
experimental_buildOpenAIMessages,
|
175
|
-
experimental_buildOpenAssistantPrompt,
|
176
|
-
experimental_buildStarChatBetaPrompt
|
177
|
-
});
|
178
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../index.ts","../anthropic.ts","../huggingface.ts","../openai.tsx"],"sourcesContent":["export * from './anthropic';\nexport * from './huggingface';\nexport * from './openai';\n","import { Message } from '../shared/types';\n\n/**\n * A prompt constructor for Anthropic models.\n * Does not support `function` messages.\n * @see https://docs.anthropic.com/claude/reference/getting-started-with-the-api\n */\nexport function experimental_buildAnthropicPrompt(\n messages: Pick<Message, 'content' | 'role'>[],\n) {\n return (\n messages.map(({ content, role }) => {\n if (role === 'user') {\n return `\\n\\nHuman: ${content}`;\n } else {\n return `\\n\\nAssistant: ${content}`;\n }\n }) + '\\n\\nAssistant:'\n );\n}\n\n/**\n * A prompt constructor for Anthropic V3 models which require Messages API.\n * Does not support message with image content\n * @see https://docs.anthropic.com/claude/reference/messages_post\n */\nexport function experimental_buildAnthropicMessages(\n messages: Pick<Message, 'content' | 'role'>[],\n) {\n return messages.map(({ content, role }) => {\n if (!['assistant', 'user'].includes(role)) {\n throw new Error(`Cannot use ${role} on Anthropic V3 Messages API`);\n }\n return {\n role,\n content: [{ type: 'text', text: content }],\n };\n });\n}\n","import { Message } from '../shared/types';\n\n/**\n * A prompt constructor for the HuggingFace StarChat Beta model.\n * Does not support `function` messages.\n * @see https://huggingface.co/HuggingFaceH4/starchat-beta\n */\nexport function experimental_buildStarChatBetaPrompt(\n messages: Pick<Message, 'content' | 'role'>[],\n) {\n return (\n messages\n .map(({ content, role }) => {\n if (role === 'user') {\n return `<|user|>\\n${content}<|end|>\\n`;\n } else if (role === 'assistant') {\n return `<|assistant|>\\n${content}<|end|>\\n`;\n } else if (role === 'system') {\n return `<|system|>\\n${content}<|end|>\\n`;\n } else if (role === 'function') {\n throw new Error('StarChat Beta does not support function calls.');\n }\n })\n .join('') + '<|assistant|>'\n );\n}\n\n/**\n * A prompt constructor for HuggingFace OpenAssistant models.\n * Does not support `function` or `system` messages.\n * @see https://huggingface.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5\n */\nexport function experimental_buildOpenAssistantPrompt(\n messages: Pick<Message, 'content' | 'role'>[],\n) {\n return (\n messages\n .map(({ content, role }) => {\n if (role === 'user') {\n return `<|prompter|>${content}<|endoftext|>`;\n } else if (role === 'function') {\n throw new Error('OpenAssistant does not support function calls.');\n } else if (role === 'system') {\n throw new Error('OpenAssistant does not support system messages.');\n } else {\n return `<|assistant|>${content}<|endoftext|>`;\n }\n })\n .join('') + '<|assistant|>'\n );\n}\n\n/**\n * A prompt constructor for HuggingFace LLama 2 chat models.\n * Does not support `function` messages.\n * @see https://huggingface.co/meta-llama/Llama-2-70b-chat-hf and https://huggingface.co/blog/llama2#how-to-prompt-llama-2\n */\nexport function experimental_buildLlama2Prompt(\n messages: Pick<Message, 'content' | 'role'>[],\n) {\n const startPrompt = `<s>[INST] `;\n const endPrompt = ` [/INST]`;\n const conversation = messages.map(({ content, role }, index) => {\n if (role === 'user') {\n return content.trim();\n } else if (role === 'assistant') {\n return ` [/INST] ${content}</s><s>[INST] `;\n } else if (role === 'function') {\n throw new Error('Llama 2 does not support function calls.');\n } else if (role === 'system' && index === 0) {\n return `<<SYS>>\\n${content}\\n<</SYS>>\\n\\n`;\n } else {\n throw new Error(`Invalid message role: ${role}`);\n }\n });\n\n return startPrompt + conversation.join('') + endPrompt;\n}\n","import { Message } from '../shared/types';\n\nexport function experimental_buildOpenAIMessages(\n messages: Message[],\n): ChatCompletionMessageParam[] {\n return messages.map(message => {\n switch (message.role) {\n case 'system':\n case 'user':\n return {\n role: message.role,\n content: message.content,\n } satisfies ChatCompletionMessageParam;\n\n case 'assistant': {\n const function_call = message.function_call;\n\n if (\n function_call !== undefined &&\n (typeof function_call === 'string' ||\n function_call.arguments === undefined ||\n function_call.name === undefined)\n ) {\n throw new Error(\n 'Invalid function call in message. Expected a function call object',\n );\n }\n\n return {\n role: message.role,\n content: message.content,\n function_call:\n function_call === undefined\n ? undefined\n : {\n name: function_call.name!,\n arguments: function_call.arguments!,\n },\n } satisfies ChatCompletionMessageParam;\n }\n\n case 'function': {\n if (message.name === undefined) {\n throw new Error('Invalid function call in message. Expected a name');\n }\n\n return {\n role: message.role,\n content: message.content,\n name: message.name,\n } satisfies ChatCompletionMessageParam;\n }\n\n case 'data': {\n throw \"unsupported message role 'data'\";\n }\n\n case 'tool': {\n if (message.name === undefined) {\n throw new Error('Invalid tool message. Expected a name');\n }\n\n if (message.tool_call_id === undefined) {\n throw new Error('Invalid tool message. Expected a tool_call_id');\n }\n\n return {\n role: message.role,\n content: message.content,\n tool_call_id: message.tool_call_id,\n } satisfies ChatCompletionMessageParam;\n }\n }\n });\n}\n\n// copy of open ai messages (so we don't have a dependency on the openai package)\nexport type ChatCompletionMessageParam =\n | ChatCompletionSystemMessageParam\n | ChatCompletionUserMessageParam\n | ChatCompletionAssistantMessageParam\n | ChatCompletionToolMessageParam\n | ChatCompletionFunctionMessageParam;\n\nexport interface ChatCompletionSystemMessageParam {\n /**\n * The contents of the system message.\n */\n content: string;\n\n /**\n * The role of the messages author, in this case `system`.\n */\n role: 'system';\n\n /**\n * An optional name for the participant. Provides the model information to\n * differentiate between participants of the same role.\n */\n name?: string;\n}\n\nexport interface ChatCompletionUserMessageParam {\n /**\n * The contents of the user message.\n */\n content: string | Array<ChatCompletionContentPart>;\n\n /**\n * The role of the messages author, in this case `user`.\n */\n role: 'user';\n\n /**\n * An optional name for the participant. Provides the model information to\n * differentiate between participants of the same role.\n */\n name?: string;\n}\n\nexport type ChatCompletionContentPart =\n | ChatCompletionContentPartText\n | ChatCompletionContentPartImage;\n\nexport interface ChatCompletionContentPartText {\n /**\n * The text content.\n */\n text: string;\n\n /**\n * The type of the content part.\n */\n type: 'text';\n}\n\nexport interface ChatCompletionContentPartImage {\n image_url: ChatCompletionContentPartImage.ImageURL;\n\n /**\n * The type of the content part.\n */\n type: 'image_url';\n}\n\nexport namespace ChatCompletionContentPartImage {\n export interface ImageURL {\n /**\n * Either a URL of the image or the base64 encoded image data.\n */\n url: string;\n\n /**\n * Specifies the detail level of the image. Learn more in the\n * [Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).\n */\n detail?: 'auto' | 'low' | 'high';\n }\n}\n\nexport interface ChatCompletionAssistantMessageParam {\n /**\n * The role of the messages author, in this case `assistant`.\n */\n role: 'assistant';\n\n /**\n * The contents of the assistant message. Required unless `tool_calls` or\n * `function_call` is specified.\n */\n content?: string | null;\n\n /**\n * @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of\n * a function that should be called, as generated by the model.\n */\n function_call?: ChatCompletionAssistantMessageParam.FunctionCall;\n\n /**\n * An optional name for the participant. Provides the model information to\n * differentiate between participants of the same role.\n */\n name?: string;\n\n /**\n * The tool calls generated by the model, such as function calls.\n */\n tool_calls?: Array<ChatCompletionMessageToolCall>;\n}\n\nexport namespace ChatCompletionAssistantMessageParam {\n /**\n * @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of\n * a function that should be called, as generated by the model.\n */\n export interface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n\n /**\n * The name of the function to call.\n */\n name: string;\n }\n}\n\nexport interface ChatCompletionMessageToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n\n /**\n * The function that the model called.\n */\n function: ChatCompletionMessageToolCall.Function;\n\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: 'function';\n}\n\nexport namespace ChatCompletionMessageToolCall {\n /**\n * The function that the model called.\n */\n export interface Function {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n\n /**\n * The name of the function to call.\n */\n name: string;\n }\n}\n\nexport interface ChatCompletionToolMessageParam {\n /**\n * The contents of the tool message.\n */\n content: string;\n\n /**\n * The role of the messages author, in this case `tool`.\n */\n role: 'tool';\n\n /**\n * Tool call that this message is responding to.\n */\n tool_call_id: string;\n}\n\nexport interface ChatCompletionFunctionMessageParam {\n /**\n * The return value from the function call, to return to the model.\n */\n content: string | null;\n\n /**\n * The name of the function to call.\n */\n name: string;\n\n /**\n * The role of the messages author, in this case `function`.\n */\n role: 'function';\n}\n"],"mappings":"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","names":[]}
|
package/prompts/dist/index.mjs
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
// prompts/anthropic.ts
|
2
|
-
function experimental_buildAnthropicPrompt(messages) {
|
3
|
-
return messages.map(({ content, role }) => {
|
4
|
-
if (role === "user") {
|
5
|
-
return `
|
6
|
-
|
7
|
-
Human: ${content}`;
|
8
|
-
} else {
|
9
|
-
return `
|
10
|
-
|
11
|
-
Assistant: ${content}`;
|
12
|
-
}
|
13
|
-
}) + "\n\nAssistant:";
|
14
|
-
}
|
15
|
-
function experimental_buildAnthropicMessages(messages) {
|
16
|
-
return messages.map(({ content, role }) => {
|
17
|
-
if (!["assistant", "user"].includes(role)) {
|
18
|
-
throw new Error(`Cannot use ${role} on Anthropic V3 Messages API`);
|
19
|
-
}
|
20
|
-
return {
|
21
|
-
role,
|
22
|
-
content: [{ type: "text", text: content }]
|
23
|
-
};
|
24
|
-
});
|
25
|
-
}
|
26
|
-
|
27
|
-
// prompts/huggingface.ts
|
28
|
-
function experimental_buildStarChatBetaPrompt(messages) {
|
29
|
-
return messages.map(({ content, role }) => {
|
30
|
-
if (role === "user") {
|
31
|
-
return `<|user|>
|
32
|
-
${content}<|end|>
|
33
|
-
`;
|
34
|
-
} else if (role === "assistant") {
|
35
|
-
return `<|assistant|>
|
36
|
-
${content}<|end|>
|
37
|
-
`;
|
38
|
-
} else if (role === "system") {
|
39
|
-
return `<|system|>
|
40
|
-
${content}<|end|>
|
41
|
-
`;
|
42
|
-
} else if (role === "function") {
|
43
|
-
throw new Error("StarChat Beta does not support function calls.");
|
44
|
-
}
|
45
|
-
}).join("") + "<|assistant|>";
|
46
|
-
}
|
47
|
-
function experimental_buildOpenAssistantPrompt(messages) {
|
48
|
-
return messages.map(({ content, role }) => {
|
49
|
-
if (role === "user") {
|
50
|
-
return `<|prompter|>${content}<|endoftext|>`;
|
51
|
-
} else if (role === "function") {
|
52
|
-
throw new Error("OpenAssistant does not support function calls.");
|
53
|
-
} else if (role === "system") {
|
54
|
-
throw new Error("OpenAssistant does not support system messages.");
|
55
|
-
} else {
|
56
|
-
return `<|assistant|>${content}<|endoftext|>`;
|
57
|
-
}
|
58
|
-
}).join("") + "<|assistant|>";
|
59
|
-
}
|
60
|
-
function experimental_buildLlama2Prompt(messages) {
|
61
|
-
const startPrompt = `<s>[INST] `;
|
62
|
-
const endPrompt = ` [/INST]`;
|
63
|
-
const conversation = messages.map(({ content, role }, index) => {
|
64
|
-
if (role === "user") {
|
65
|
-
return content.trim();
|
66
|
-
} else if (role === "assistant") {
|
67
|
-
return ` [/INST] ${content}</s><s>[INST] `;
|
68
|
-
} else if (role === "function") {
|
69
|
-
throw new Error("Llama 2 does not support function calls.");
|
70
|
-
} else if (role === "system" && index === 0) {
|
71
|
-
return `<<SYS>>
|
72
|
-
${content}
|
73
|
-
<</SYS>>
|
74
|
-
|
75
|
-
`;
|
76
|
-
} else {
|
77
|
-
throw new Error(`Invalid message role: ${role}`);
|
78
|
-
}
|
79
|
-
});
|
80
|
-
return startPrompt + conversation.join("") + endPrompt;
|
81
|
-
}
|
82
|
-
|
83
|
-
// prompts/openai.tsx
|
84
|
-
function experimental_buildOpenAIMessages(messages) {
|
85
|
-
return messages.map((message) => {
|
86
|
-
switch (message.role) {
|
87
|
-
case "system":
|
88
|
-
case "user":
|
89
|
-
return {
|
90
|
-
role: message.role,
|
91
|
-
content: message.content
|
92
|
-
};
|
93
|
-
case "assistant": {
|
94
|
-
const function_call = message.function_call;
|
95
|
-
if (function_call !== void 0 && (typeof function_call === "string" || function_call.arguments === void 0 || function_call.name === void 0)) {
|
96
|
-
throw new Error(
|
97
|
-
"Invalid function call in message. Expected a function call object"
|
98
|
-
);
|
99
|
-
}
|
100
|
-
return {
|
101
|
-
role: message.role,
|
102
|
-
content: message.content,
|
103
|
-
function_call: function_call === void 0 ? void 0 : {
|
104
|
-
name: function_call.name,
|
105
|
-
arguments: function_call.arguments
|
106
|
-
}
|
107
|
-
};
|
108
|
-
}
|
109
|
-
case "function": {
|
110
|
-
if (message.name === void 0) {
|
111
|
-
throw new Error("Invalid function call in message. Expected a name");
|
112
|
-
}
|
113
|
-
return {
|
114
|
-
role: message.role,
|
115
|
-
content: message.content,
|
116
|
-
name: message.name
|
117
|
-
};
|
118
|
-
}
|
119
|
-
case "data": {
|
120
|
-
throw "unsupported message role 'data'";
|
121
|
-
}
|
122
|
-
case "tool": {
|
123
|
-
if (message.name === void 0) {
|
124
|
-
throw new Error("Invalid tool message. Expected a name");
|
125
|
-
}
|
126
|
-
if (message.tool_call_id === void 0) {
|
127
|
-
throw new Error("Invalid tool message. Expected a tool_call_id");
|
128
|
-
}
|
129
|
-
return {
|
130
|
-
role: message.role,
|
131
|
-
content: message.content,
|
132
|
-
tool_call_id: message.tool_call_id
|
133
|
-
};
|
134
|
-
}
|
135
|
-
}
|
136
|
-
});
|
137
|
-
}
|
138
|
-
export {
|
139
|
-
experimental_buildAnthropicMessages,
|
140
|
-
experimental_buildAnthropicPrompt,
|
141
|
-
experimental_buildLlama2Prompt,
|
142
|
-
experimental_buildOpenAIMessages,
|
143
|
-
experimental_buildOpenAssistantPrompt,
|
144
|
-
experimental_buildStarChatBetaPrompt
|
145
|
-
};
|
146
|
-
//# sourceMappingURL=index.mjs.map
|