ai 3.4.33 → 4.0.0-canary.1

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.
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../anthropic.ts","../huggingface.ts","../openai.tsx"],"sourcesContent":["import { Message } from '@ai-sdk/ui-utils';\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 *\n * @deprecated Will be removed. Use the new provider architecture instead.\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 *\n * @deprecated Will be removed. Use the new provider architecture instead.\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 '@ai-sdk/ui-utils';\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 * @deprecated Will be removed. Use the new provider architecture instead.\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 * @deprecated Will be removed. Use the new provider architecture instead.\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 *\n * @deprecated Will be removed. Use the new provider architecture instead.\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 '@ai-sdk/ui-utils';\n\n/**\n * @deprecated Will be removed. Use the new provider architecture instead.\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":[]}
@@ -1,13 +0,0 @@
1
- import { useChat as useChat$1, useCompletion as useCompletion$1 } from '@ai-sdk/solid';
2
- export { CreateMessage, Message, UseChatHelpers, UseChatOptions } from '@ai-sdk/solid';
3
-
4
- /**
5
- * @deprecated Use `useChat` from `@ai-sdk/solid` instead.
6
- */
7
- declare const useChat: typeof useChat$1;
8
- /**
9
- * @deprecated Use `useCompletion` from `@ai-sdk/solid` instead.
10
- */
11
- declare const useCompletion: typeof useCompletion$1;
12
-
13
- export { useChat, useCompletion };
@@ -1,13 +0,0 @@
1
- import { useChat as useChat$1, useCompletion as useCompletion$1 } from '@ai-sdk/solid';
2
- export { CreateMessage, Message, UseChatHelpers, UseChatOptions } from '@ai-sdk/solid';
3
-
4
- /**
5
- * @deprecated Use `useChat` from `@ai-sdk/solid` instead.
6
- */
7
- declare const useChat: typeof useChat$1;
8
- /**
9
- * @deprecated Use `useCompletion` from `@ai-sdk/solid` instead.
10
- */
11
- declare const useCompletion: typeof useCompletion$1;
12
-
13
- export { useChat, useCompletion };
@@ -1,35 +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
- // solid/index.ts
21
- var solid_exports = {};
22
- __export(solid_exports, {
23
- useChat: () => useChat,
24
- useCompletion: () => useCompletion
25
- });
26
- module.exports = __toCommonJS(solid_exports);
27
- var import_solid = require("@ai-sdk/solid");
28
- var useChat = import_solid.useChat;
29
- var useCompletion = import_solid.useCompletion;
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- useChat,
33
- useCompletion
34
- });
35
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n useChat as useChatSolid,\n useCompletion as useCompletionSolid,\n} from '@ai-sdk/solid';\n\n/**\n * @deprecated Use `useChat` from `@ai-sdk/solid` instead.\n */\nexport const useChat = useChatSolid;\n\n/**\n * @deprecated Use `useCompletion` from `@ai-sdk/solid` instead.\n */\nexport const useCompletion = useCompletionSolid;\n\n/**\n * @deprecated Use `@ai-sdk/solid` instead.\n */\nexport type {\n CreateMessage,\n Message,\n UseChatOptions,\n UseChatHelpers,\n} from '@ai-sdk/solid';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAGO;AAKA,IAAM,UAAU,aAAAA;AAKhB,IAAM,gBAAgB,aAAAC;","names":["useChatSolid","useCompletionSolid"]}
@@ -1,12 +0,0 @@
1
- // solid/index.ts
2
- import {
3
- useChat as useChatSolid,
4
- useCompletion as useCompletionSolid
5
- } from "@ai-sdk/solid";
6
- var useChat = useChatSolid;
7
- var useCompletion = useCompletionSolid;
8
- export {
9
- useChat,
10
- useCompletion
11
- };
12
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n useChat as useChatSolid,\n useCompletion as useCompletionSolid,\n} from '@ai-sdk/solid';\n\n/**\n * @deprecated Use `useChat` from `@ai-sdk/solid` instead.\n */\nexport const useChat = useChatSolid;\n\n/**\n * @deprecated Use `useCompletion` from `@ai-sdk/solid` instead.\n */\nexport const useCompletion = useCompletionSolid;\n\n/**\n * @deprecated Use `@ai-sdk/solid` instead.\n */\nexport type {\n CreateMessage,\n Message,\n UseChatOptions,\n UseChatHelpers,\n} from '@ai-sdk/solid';\n"],"mappings":";AAAA;AAAA,EACE,WAAW;AAAA,EACX,iBAAiB;AAAA,OACZ;AAKA,IAAM,UAAU;AAKhB,IAAM,gBAAgB;","names":[]}
@@ -1,175 +0,0 @@
1
- import { UseChatOptions as UseChatOptions$1, Message, CreateMessage, ChatRequestOptions, JSONValue, RequestOptions, UseCompletionOptions, AssistantStatus, UseAssistantOptions } from '@ai-sdk/ui-utils';
2
- export { CreateMessage, Message, UseCompletionOptions } from '@ai-sdk/ui-utils';
3
- import { Readable, Writable } from 'svelte/store';
4
-
5
- type UseChatOptions = UseChatOptions$1 & {
6
- /**
7
- Maximum number of automatic roundtrips for tool calls.
8
-
9
- An automatic tool call roundtrip is a call to the server with the
10
- tool call results when all tool calls in the last assistant
11
- message have results.
12
-
13
- A maximum number is required to prevent infinite loops in the
14
- case of misconfigured tools.
15
-
16
- By default, it's set to 0, which will disable the feature.
17
-
18
- @deprecated Use `maxSteps` instead (which is `maxToolRoundtrips` + 1).
19
- */
20
- maxToolRoundtrips?: number;
21
- /**
22
- Maximum number of sequential LLM calls (steps), e.g. when you use tool calls. Must be at least 1.
23
-
24
- A maximum number is required to prevent infinite loops in the case of misconfigured tools.
25
-
26
- By default, it's set to 1, which means that only a single LLM call is made.
27
- */
28
- maxSteps?: number;
29
- };
30
- type UseChatHelpers = {
31
- /** Current messages in the chat */
32
- messages: Readable<Message[]>;
33
- /** The error object of the API request */
34
- error: Readable<undefined | Error>;
35
- /**
36
- * Append a user message to the chat list. This triggers the API call to fetch
37
- * the assistant's response.
38
- * @param message The message to append
39
- * @param chatRequestOptions Additional options to pass to the API call
40
- */
41
- append: (message: Message | CreateMessage, chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
42
- /**
43
- * Reload the last AI chat response for the given chat history. If the last
44
- * message isn't from the assistant, it will request the API to generate a
45
- * new response.
46
- */
47
- reload: (chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
48
- /**
49
- * Abort the current request immediately, keep the generated tokens if any.
50
- */
51
- stop: () => void;
52
- /**
53
- * Update the `messages` state locally. This is useful when you want to
54
- * edit the messages on the client, and then trigger the `reload` method
55
- * manually to regenerate the AI response.
56
- */
57
- setMessages: (messages: Message[] | ((messages: Message[]) => Message[])) => void;
58
- /** The current value of the input */
59
- input: Writable<string>;
60
- /** Form submission handler to automatically reset input and append a user message */
61
- handleSubmit: (event?: {
62
- preventDefault?: () => void;
63
- }, chatRequestOptions?: ChatRequestOptions) => void;
64
- metadata?: Object;
65
- /** Whether the API request is in progress */
66
- isLoading: Readable<boolean | undefined>;
67
- /** Additional data added on the server via StreamData */
68
- data: Readable<JSONValue[] | undefined>;
69
- /** Set the data of the chat. You can use this to transform or clear the chat data. */
70
- setData: (data: JSONValue[] | undefined | ((data: JSONValue[] | undefined) => JSONValue[] | undefined)) => void;
71
- };
72
- /**
73
- * @deprecated Use `useChat` from `@ai-sdk/svelte` instead.
74
- */
75
- declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, streamMode, streamProtocol, onResponse, onFinish, onError, onToolCall, credentials, headers, body, generateId, fetch, keepLastMessageOnError, maxToolRoundtrips, maxSteps, }?: UseChatOptions): UseChatHelpers & {
76
- addToolResult: ({ toolCallId, result, }: {
77
- toolCallId: string;
78
- result: any;
79
- }) => void;
80
- };
81
-
82
- type UseCompletionHelpers = {
83
- /** The current completion result */
84
- completion: Readable<string>;
85
- /** The error object of the API request */
86
- error: Readable<undefined | Error>;
87
- /**
88
- * Send a new prompt to the API endpoint and update the completion state.
89
- */
90
- complete: (prompt: string, options?: RequestOptions) => Promise<string | null | undefined>;
91
- /**
92
- * Abort the current API request but keep the generated tokens.
93
- */
94
- stop: () => void;
95
- /**
96
- * Update the `completion` state locally.
97
- */
98
- setCompletion: (completion: string) => void;
99
- /** The current value of the input */
100
- input: Writable<string>;
101
- /**
102
- * Form submission handler to automatically reset input and append a user message
103
- * @example
104
- * ```jsx
105
- * <form onSubmit={handleSubmit}>
106
- * <input onChange={handleInputChange} value={input} />
107
- * </form>
108
- * ```
109
- */
110
- handleSubmit: (event?: {
111
- preventDefault?: () => void;
112
- }) => void;
113
- /** Whether the API request is in progress */
114
- isLoading: Readable<boolean | undefined>;
115
- /** Additional data added on the server via StreamData */
116
- data: Readable<JSONValue[] | undefined>;
117
- };
118
- /**
119
- * @deprecated Use `useCompletion` from `@ai-sdk/svelte` instead.
120
- */
121
- declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamMode, streamProtocol, onResponse, onFinish, onError, fetch, }?: UseCompletionOptions): UseCompletionHelpers;
122
-
123
- type UseAssistantHelpers = {
124
- /**
125
- * The current array of chat messages.
126
- */
127
- messages: Readable<Message[]>;
128
- /**
129
- * Update the message store with a new array of messages.
130
- */
131
- setMessages: (messages: Message[]) => void;
132
- /**
133
- * The current thread ID.
134
- */
135
- threadId: Readable<string | undefined>;
136
- /**
137
- * The current value of the input field.
138
- */
139
- input: Writable<string>;
140
- /**
141
- * Append a user message to the chat list. This triggers the API call to fetch
142
- * the assistant's response.
143
- * @param message The message to append
144
- * @param requestOptions Additional options to pass to the API call
145
- */
146
- append: (message: Message | CreateMessage, requestOptions?: {
147
- data?: Record<string, string>;
148
- }) => Promise<void>;
149
- /**
150
- Abort the current request immediately, keep the generated tokens if any.
151
- */
152
- stop: () => void;
153
- /**
154
- * Form submission handler that automatically resets the input field and appends a user message.
155
- */
156
- submitMessage: (event?: {
157
- preventDefault?: () => void;
158
- }, requestOptions?: {
159
- data?: Record<string, string>;
160
- }) => Promise<void>;
161
- /**
162
- * The current status of the assistant. This can be used to show a loading indicator.
163
- */
164
- status: Readable<AssistantStatus>;
165
- /**
166
- * The error thrown during the assistant message processing, if any.
167
- */
168
- error: Readable<undefined | Error>;
169
- };
170
- /**
171
- * @deprecated Use `useAssistant` from `@ai-sdk/svelte` instead.
172
- */
173
- declare function useAssistant({ api, threadId: threadIdParam, credentials, headers, body, onError, fetch, }: UseAssistantOptions): UseAssistantHelpers;
174
-
175
- export { UseAssistantHelpers, UseChatHelpers, UseChatOptions, UseCompletionHelpers, useAssistant, useChat, useCompletion };
@@ -1,175 +0,0 @@
1
- import { UseChatOptions as UseChatOptions$1, Message, CreateMessage, ChatRequestOptions, JSONValue, RequestOptions, UseCompletionOptions, AssistantStatus, UseAssistantOptions } from '@ai-sdk/ui-utils';
2
- export { CreateMessage, Message, UseCompletionOptions } from '@ai-sdk/ui-utils';
3
- import { Readable, Writable } from 'svelte/store';
4
-
5
- type UseChatOptions = UseChatOptions$1 & {
6
- /**
7
- Maximum number of automatic roundtrips for tool calls.
8
-
9
- An automatic tool call roundtrip is a call to the server with the
10
- tool call results when all tool calls in the last assistant
11
- message have results.
12
-
13
- A maximum number is required to prevent infinite loops in the
14
- case of misconfigured tools.
15
-
16
- By default, it's set to 0, which will disable the feature.
17
-
18
- @deprecated Use `maxSteps` instead (which is `maxToolRoundtrips` + 1).
19
- */
20
- maxToolRoundtrips?: number;
21
- /**
22
- Maximum number of sequential LLM calls (steps), e.g. when you use tool calls. Must be at least 1.
23
-
24
- A maximum number is required to prevent infinite loops in the case of misconfigured tools.
25
-
26
- By default, it's set to 1, which means that only a single LLM call is made.
27
- */
28
- maxSteps?: number;
29
- };
30
- type UseChatHelpers = {
31
- /** Current messages in the chat */
32
- messages: Readable<Message[]>;
33
- /** The error object of the API request */
34
- error: Readable<undefined | Error>;
35
- /**
36
- * Append a user message to the chat list. This triggers the API call to fetch
37
- * the assistant's response.
38
- * @param message The message to append
39
- * @param chatRequestOptions Additional options to pass to the API call
40
- */
41
- append: (message: Message | CreateMessage, chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
42
- /**
43
- * Reload the last AI chat response for the given chat history. If the last
44
- * message isn't from the assistant, it will request the API to generate a
45
- * new response.
46
- */
47
- reload: (chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
48
- /**
49
- * Abort the current request immediately, keep the generated tokens if any.
50
- */
51
- stop: () => void;
52
- /**
53
- * Update the `messages` state locally. This is useful when you want to
54
- * edit the messages on the client, and then trigger the `reload` method
55
- * manually to regenerate the AI response.
56
- */
57
- setMessages: (messages: Message[] | ((messages: Message[]) => Message[])) => void;
58
- /** The current value of the input */
59
- input: Writable<string>;
60
- /** Form submission handler to automatically reset input and append a user message */
61
- handleSubmit: (event?: {
62
- preventDefault?: () => void;
63
- }, chatRequestOptions?: ChatRequestOptions) => void;
64
- metadata?: Object;
65
- /** Whether the API request is in progress */
66
- isLoading: Readable<boolean | undefined>;
67
- /** Additional data added on the server via StreamData */
68
- data: Readable<JSONValue[] | undefined>;
69
- /** Set the data of the chat. You can use this to transform or clear the chat data. */
70
- setData: (data: JSONValue[] | undefined | ((data: JSONValue[] | undefined) => JSONValue[] | undefined)) => void;
71
- };
72
- /**
73
- * @deprecated Use `useChat` from `@ai-sdk/svelte` instead.
74
- */
75
- declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, streamMode, streamProtocol, onResponse, onFinish, onError, onToolCall, credentials, headers, body, generateId, fetch, keepLastMessageOnError, maxToolRoundtrips, maxSteps, }?: UseChatOptions): UseChatHelpers & {
76
- addToolResult: ({ toolCallId, result, }: {
77
- toolCallId: string;
78
- result: any;
79
- }) => void;
80
- };
81
-
82
- type UseCompletionHelpers = {
83
- /** The current completion result */
84
- completion: Readable<string>;
85
- /** The error object of the API request */
86
- error: Readable<undefined | Error>;
87
- /**
88
- * Send a new prompt to the API endpoint and update the completion state.
89
- */
90
- complete: (prompt: string, options?: RequestOptions) => Promise<string | null | undefined>;
91
- /**
92
- * Abort the current API request but keep the generated tokens.
93
- */
94
- stop: () => void;
95
- /**
96
- * Update the `completion` state locally.
97
- */
98
- setCompletion: (completion: string) => void;
99
- /** The current value of the input */
100
- input: Writable<string>;
101
- /**
102
- * Form submission handler to automatically reset input and append a user message
103
- * @example
104
- * ```jsx
105
- * <form onSubmit={handleSubmit}>
106
- * <input onChange={handleInputChange} value={input} />
107
- * </form>
108
- * ```
109
- */
110
- handleSubmit: (event?: {
111
- preventDefault?: () => void;
112
- }) => void;
113
- /** Whether the API request is in progress */
114
- isLoading: Readable<boolean | undefined>;
115
- /** Additional data added on the server via StreamData */
116
- data: Readable<JSONValue[] | undefined>;
117
- };
118
- /**
119
- * @deprecated Use `useCompletion` from `@ai-sdk/svelte` instead.
120
- */
121
- declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamMode, streamProtocol, onResponse, onFinish, onError, fetch, }?: UseCompletionOptions): UseCompletionHelpers;
122
-
123
- type UseAssistantHelpers = {
124
- /**
125
- * The current array of chat messages.
126
- */
127
- messages: Readable<Message[]>;
128
- /**
129
- * Update the message store with a new array of messages.
130
- */
131
- setMessages: (messages: Message[]) => void;
132
- /**
133
- * The current thread ID.
134
- */
135
- threadId: Readable<string | undefined>;
136
- /**
137
- * The current value of the input field.
138
- */
139
- input: Writable<string>;
140
- /**
141
- * Append a user message to the chat list. This triggers the API call to fetch
142
- * the assistant's response.
143
- * @param message The message to append
144
- * @param requestOptions Additional options to pass to the API call
145
- */
146
- append: (message: Message | CreateMessage, requestOptions?: {
147
- data?: Record<string, string>;
148
- }) => Promise<void>;
149
- /**
150
- Abort the current request immediately, keep the generated tokens if any.
151
- */
152
- stop: () => void;
153
- /**
154
- * Form submission handler that automatically resets the input field and appends a user message.
155
- */
156
- submitMessage: (event?: {
157
- preventDefault?: () => void;
158
- }, requestOptions?: {
159
- data?: Record<string, string>;
160
- }) => Promise<void>;
161
- /**
162
- * The current status of the assistant. This can be used to show a loading indicator.
163
- */
164
- status: Readable<AssistantStatus>;
165
- /**
166
- * The error thrown during the assistant message processing, if any.
167
- */
168
- error: Readable<undefined | Error>;
169
- };
170
- /**
171
- * @deprecated Use `useAssistant` from `@ai-sdk/svelte` instead.
172
- */
173
- declare function useAssistant({ api, threadId: threadIdParam, credentials, headers, body, onError, fetch, }: UseAssistantOptions): UseAssistantHelpers;
174
-
175
- export { UseAssistantHelpers, UseChatHelpers, UseChatOptions, UseCompletionHelpers, useAssistant, useChat, useCompletion };