@assistant-ui/react 0.5.20 → 0.5.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{ModelConfigTypes-ComYH1b6.d.mts → AssistantTypes-D93BmqD5.d.mts} +64 -60
- package/dist/{ModelConfigTypes-ComYH1b6.d.ts → AssistantTypes-D93BmqD5.d.ts} +64 -60
- package/dist/Thread-BbLf1cc4.d.mts +156 -0
- package/dist/Thread-jfAlPLli.d.ts +156 -0
- package/dist/chunk-2RKUKZSZ.mjs +761 -0
- package/dist/chunk-2RKUKZSZ.mjs.map +1 -0
- package/dist/chunk-BJPOCE4O.mjs +11 -0
- package/dist/chunk-BJPOCE4O.mjs.map +1 -0
- package/dist/{chunk-BV6Y7C43.mjs → chunk-QBS6JLLN.mjs} +3 -1
- package/dist/{chunk-BV6Y7C43.mjs.map → chunk-QBS6JLLN.mjs.map} +1 -1
- package/dist/chunk-V66MVXBH.mjs +608 -0
- package/dist/chunk-V66MVXBH.mjs.map +1 -0
- package/dist/edge.d.mts +2 -2
- package/dist/edge.d.ts +2 -2
- package/dist/edge.js +1 -0
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +10 -748
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +11 -309
- package/dist/index.d.ts +11 -309
- package/dist/index.mjs +324 -1677
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +7 -126
- package/dist/internal.d.ts +7 -126
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +12 -519
- package/dist/internal.mjs.map +1 -1
- package/dist/tailwindcss/index.js +1 -0
- package/dist/tailwindcss/index.js.map +1 -1
- package/dist/tailwindcss/index.mjs +3 -0
- package/dist/tailwindcss/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/edge.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/runtimes/edge/streams/assistantEncoderStream.ts","../src/runtimes/edge/EdgeRuntimeRequestOptions.ts","../src/runtimes/edge/converters/toLanguageModelMessages.ts","../src/runtimes/edge/converters/toLanguageModelTools.ts","../src/runtimes/edge/streams/toolResultStream.ts","../src/runtimes/edge/partial-json/parse-partial-json.ts","../src/runtimes/edge/partial-json/fix-json.ts","../src/runtimes/edge/streams/runResultStream.ts","../src/runtimes/edge/converters/toCoreMessages.ts","../src/runtimes/edge/createEdgeRuntimeAPI.ts"],"sourcesContent":["import {\n AssistantStreamChunkTuple,\n AssistantStreamChunkType,\n} from \"./AssistantStreamChunkType\";\nimport { ToolResultStreamPart } from \"./toolResultStream\";\n\nexport function assistantEncoderStream() {\n const toolCalls = new Set<string>();\n return new TransformStream<ToolResultStreamPart, string>({\n transform(chunk, controller) {\n const chunkType = chunk.type;\n switch (chunkType) {\n case \"text-delta\": {\n controller.enqueue(\n formatStreamPart(\n AssistantStreamChunkType.TextDelta,\n chunk.textDelta,\n ),\n );\n break;\n }\n case \"tool-call-delta\": {\n if (!toolCalls.has(chunk.toolCallId)) {\n toolCalls.add(chunk.toolCallId);\n controller.enqueue(\n formatStreamPart(AssistantStreamChunkType.ToolCallBegin, {\n id: chunk.toolCallId,\n name: chunk.toolName,\n }),\n );\n }\n\n controller.enqueue(\n formatStreamPart(\n AssistantStreamChunkType.ToolCallArgsTextDelta,\n chunk.argsTextDelta,\n ),\n );\n break;\n }\n\n // ignore\n case \"tool-call\":\n break;\n\n case \"tool-result\": {\n controller.enqueue(\n formatStreamPart(AssistantStreamChunkType.ToolCallResult, {\n id: chunk.toolCallId,\n result: chunk.result,\n }),\n );\n break;\n }\n\n case \"finish\": {\n const { type, ...rest } = chunk;\n controller.enqueue(\n formatStreamPart(AssistantStreamChunkType.Finish, rest),\n );\n break;\n }\n\n case \"error\": {\n controller.enqueue(\n formatStreamPart(AssistantStreamChunkType.Error, chunk.error),\n );\n break;\n }\n default: {\n const unhandledType: never = chunkType;\n throw new Error(`Unhandled chunk type: ${unhandledType}`);\n }\n }\n },\n });\n}\n\nexport function formatStreamPart(\n ...[code, value]: AssistantStreamChunkTuple\n): string {\n return `${code}:${JSON.stringify(value)}\\n`;\n}\n","import { JSONSchema7 } from \"json-schema\";\nimport {\n LanguageModelConfigSchema,\n LanguageModelV1CallSettingsSchema,\n} from \"../../types/ModelConfigTypes\";\nimport { z } from \"zod\";\n\nconst LanguageModelV1FunctionToolSchema = z.object({\n type: z.literal(\"function\"),\n name: z.string(),\n description: z.string().optional(),\n parameters: z.custom<JSONSchema7>(\n (val) => typeof val === \"object\" && val !== null,\n ),\n});\n\nconst TextContentPartSchema = z.object({\n type: z.literal(\"text\"),\n text: z.string(),\n});\n\nconst ImageContentPartSchema = z.object({\n type: z.literal(\"image\"),\n image: z.string(),\n});\n\nconst CoreToolCallContentPartSchema = z.object({\n type: z.literal(\"tool-call\"),\n toolCallId: z.string(),\n toolName: z.string(),\n args: z.record(z.unknown()),\n result: z.unknown().optional(),\n isError: z.boolean().optional(),\n});\n// args is required but unknown;\n\nconst CoreUserMessageSchema = z.object({\n role: z.literal(\"user\"),\n content: z\n .array(\n z.discriminatedUnion(\"type\", [\n TextContentPartSchema,\n ImageContentPartSchema,\n ]),\n )\n .min(1),\n});\n\nconst CoreAssistantMessageSchema = z.object({\n role: z.literal(\"assistant\"),\n content: z\n .array(\n z.discriminatedUnion(\"type\", [\n TextContentPartSchema,\n CoreToolCallContentPartSchema,\n ]),\n )\n .min(1),\n});\n\nconst CoreSystemMessageSchema = z.object({\n role: z.literal(\"system\"),\n content: z.tuple([TextContentPartSchema]),\n});\n\nconst CoreMessageSchema = z.discriminatedUnion(\"role\", [\n CoreSystemMessageSchema,\n CoreUserMessageSchema,\n CoreAssistantMessageSchema,\n]);\n\nexport const EdgeRuntimeRequestOptionsSchema = z\n .object({\n system: z.string().optional(),\n messages: z.array(CoreMessageSchema).min(1),\n tools: z.array(LanguageModelV1FunctionToolSchema).optional(),\n })\n .merge(LanguageModelV1CallSettingsSchema)\n .merge(LanguageModelConfigSchema);\n\nexport type EdgeRuntimeRequestOptions = z.infer<\n typeof EdgeRuntimeRequestOptionsSchema\n>;\n","import {\n LanguageModelV1ImagePart,\n LanguageModelV1Message,\n LanguageModelV1TextPart,\n LanguageModelV1ToolCallPart,\n LanguageModelV1ToolResultPart,\n} from \"@ai-sdk/provider\";\nimport {\n CoreMessage,\n ThreadMessage,\n TextContentPart,\n CoreToolCallContentPart,\n} from \"../../../types/AssistantTypes\";\n\nconst assistantMessageSplitter = () => {\n const stash: LanguageModelV1Message[] = [];\n let assistantMessage = {\n role: \"assistant\" as const,\n content: [] as (LanguageModelV1TextPart | LanguageModelV1ToolCallPart)[],\n };\n let toolMessage = {\n role: \"tool\" as const,\n content: [] as LanguageModelV1ToolResultPart[],\n };\n\n return {\n addTextContentPart: (part: TextContentPart) => {\n if (toolMessage.content.length > 0) {\n stash.push(assistantMessage);\n stash.push(toolMessage);\n\n assistantMessage = {\n role: \"assistant\" as const,\n content: [] as (\n | LanguageModelV1TextPart\n | LanguageModelV1ToolCallPart\n )[],\n };\n\n toolMessage = {\n role: \"tool\" as const,\n content: [] as LanguageModelV1ToolResultPart[],\n };\n }\n\n assistantMessage.content.push(part);\n },\n addToolCallPart: (part: CoreToolCallContentPart) => {\n assistantMessage.content.push({\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n args: part.args,\n });\n if (part.result) {\n toolMessage.content.push({\n type: \"tool-result\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n result: part.result,\n // isError\n });\n }\n },\n getMessages: () => {\n if (toolMessage.content.length > 0) {\n return [...stash, assistantMessage, toolMessage];\n }\n\n return [...stash, assistantMessage];\n },\n };\n};\n\nexport function toLanguageModelMessages(\n message: readonly CoreMessage[] | readonly ThreadMessage[],\n): LanguageModelV1Message[] {\n return message.flatMap((message) => {\n const role = message.role;\n switch (role) {\n case \"system\": {\n return [{ role: \"system\", content: message.content[0].text }];\n }\n\n case \"user\": {\n const msg: LanguageModelV1Message = {\n role: \"user\",\n content: message.content.map(\n (part): LanguageModelV1TextPart | LanguageModelV1ImagePart => {\n const type = part.type;\n switch (type) {\n case \"text\": {\n return part;\n }\n\n case \"image\": {\n return {\n type: \"image\",\n image: new URL(part.image),\n };\n }\n\n default: {\n const unhandledType: \"ui\" = type;\n throw new Error(\n `Unspported content part type: ${unhandledType}`,\n );\n }\n }\n },\n ),\n };\n return [msg];\n }\n\n case \"assistant\": {\n const splitter = assistantMessageSplitter();\n for (const part of message.content) {\n const type = part.type;\n switch (type) {\n case \"text\": {\n splitter.addTextContentPart(part);\n break;\n }\n case \"tool-call\": {\n splitter.addToolCallPart(part);\n break;\n }\n default: {\n const unhandledType: \"ui\" = type;\n throw new Error(`Unhandled content part type: ${unhandledType}`);\n }\n }\n }\n return splitter.getMessages();\n }\n\n default: {\n const unhandledRole: never = role;\n throw new Error(`Unknown message role: ${unhandledRole}`);\n }\n }\n });\n}\n","import { LanguageModelV1FunctionTool } from \"@ai-sdk/provider\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { z } from \"zod\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport { Tool } from \"../../../types/ModelConfigTypes\";\n\nexport const toLanguageModelTools = (\n tools: Record<string, Tool<any, any>>,\n): LanguageModelV1FunctionTool[] => {\n return Object.entries(tools).map(([name, tool]) => ({\n type: \"function\",\n name,\n ...(tool.description ? { description: tool.description } : undefined),\n parameters: (tool.parameters instanceof z.ZodType\n ? zodToJsonSchema(tool.parameters)\n : tool.parameters) as JSONSchema7,\n }));\n};\n","import { Tool } from \"../../../types/ModelConfigTypes\";\nimport { LanguageModelV1StreamPart } from \"@ai-sdk/provider\";\nimport { z } from \"zod\";\nimport sjson from \"secure-json-parse\";\n\nexport type ToolResultStreamPart =\n | LanguageModelV1StreamPart\n | {\n type: \"tool-result\";\n toolCallType: \"function\";\n toolCallId: string;\n toolName: string;\n result: unknown;\n isError?: boolean;\n };\n\nexport function toolResultStream(tools: Record<string, Tool> | undefined) {\n const toolCallExecutions = new Map<string, Promise<any>>();\n\n return new TransformStream<ToolResultStreamPart, ToolResultStreamPart>({\n transform(chunk, controller) {\n // forward everything\n controller.enqueue(chunk);\n\n // handle tool calls\n const chunkType = chunk.type;\n switch (chunkType) {\n case \"tool-call\": {\n const { toolCallId, toolCallType, toolName, args: argsText } = chunk;\n const tool = tools?.[toolName];\n if (!tool || !tool.execute) return;\n\n const args = sjson.parse(argsText);\n if (tool.parameters instanceof z.ZodType) {\n const result = tool.parameters.safeParse(args);\n if (!result.success) {\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result:\n \"Function parameter validation failed. \" +\n JSON.stringify(result.error.issues),\n isError: true,\n });\n return;\n } else {\n toolCallExecutions.set(\n toolCallId,\n (async () => {\n try {\n const result = await tool.execute!(args);\n\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result,\n });\n } catch (error) {\n console.error(\"Error: \", error);\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result: \"Error: \" + error,\n isError: true,\n });\n } finally {\n toolCallExecutions.delete(toolCallId);\n }\n })(),\n );\n }\n }\n break;\n }\n\n // ignore other parts\n case \"text-delta\":\n case \"tool-call-delta\":\n case \"tool-result\":\n case \"finish\":\n case \"error\":\n break;\n\n default: {\n const unhandledType: never = chunkType;\n throw new Error(`Unhandled chunk type: ${unhandledType}`);\n }\n }\n },\n\n async flush() {\n await Promise.all(toolCallExecutions.values());\n },\n });\n}\n","import sjson from \"secure-json-parse\";\nimport { fixJson } from \"./fix-json\";\n\nexport const parsePartialJson = (json: string) => {\n try {\n return sjson.parse(json);\n } catch {\n try {\n return sjson.parse(fixJson(json));\n } catch {\n return undefined;\n }\n }\n};\n","// LICENSE for this file only\n\n// Copyright 2023 Vercel, Inc.\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\ntype State =\n | \"ROOT\"\n | \"FINISH\"\n | \"INSIDE_STRING\"\n | \"INSIDE_STRING_ESCAPE\"\n | \"INSIDE_LITERAL\"\n | \"INSIDE_NUMBER\"\n | \"INSIDE_OBJECT_START\"\n | \"INSIDE_OBJECT_KEY\"\n | \"INSIDE_OBJECT_AFTER_KEY\"\n | \"INSIDE_OBJECT_BEFORE_VALUE\"\n | \"INSIDE_OBJECT_AFTER_VALUE\"\n | \"INSIDE_OBJECT_AFTER_COMMA\"\n | \"INSIDE_ARRAY_START\"\n | \"INSIDE_ARRAY_AFTER_VALUE\"\n | \"INSIDE_ARRAY_AFTER_COMMA\";\n\n// Implemented as a scanner with additional fixing\n// that performs a single linear time scan pass over the partial JSON.\n//\n// The states should ideally match relevant states from the JSON spec:\n// https://www.json.org/json-en.html\n//\n// Please note that invalid JSON is not considered/covered, because it\n// is assumed that the resulting JSON will be processed by a standard\n// JSON parser that will detect any invalid JSON.\nexport function fixJson(input: string): string {\n const stack: State[] = [\"ROOT\"];\n let lastValidIndex = -1;\n let literalStart: number | null = null;\n\n function processValueStart(char: string, i: number, swapState: State) {\n {\n switch (char) {\n case '\"': {\n lastValidIndex = i;\n stack.pop();\n stack.push(swapState);\n stack.push(\"INSIDE_STRING\");\n break;\n }\n\n case \"f\":\n case \"t\":\n case \"n\": {\n lastValidIndex = i;\n literalStart = i;\n stack.pop();\n stack.push(swapState);\n stack.push(\"INSIDE_LITERAL\");\n break;\n }\n\n case \"-\": {\n stack.pop();\n stack.push(swapState);\n stack.push(\"INSIDE_NUMBER\");\n break;\n }\n case \"0\":\n case \"1\":\n case \"2\":\n case \"3\":\n case \"4\":\n case \"5\":\n case \"6\":\n case \"7\":\n case \"8\":\n case \"9\": {\n lastValidIndex = i;\n stack.pop();\n stack.push(swapState);\n stack.push(\"INSIDE_NUMBER\");\n break;\n }\n\n case \"{\": {\n lastValidIndex = i;\n stack.pop();\n stack.push(swapState);\n stack.push(\"INSIDE_OBJECT_START\");\n break;\n }\n\n case \"[\": {\n lastValidIndex = i;\n stack.pop();\n stack.push(swapState);\n stack.push(\"INSIDE_ARRAY_START\");\n break;\n }\n }\n }\n }\n\n function processAfterObjectValue(char: string, i: number) {\n switch (char) {\n case \",\": {\n stack.pop();\n stack.push(\"INSIDE_OBJECT_AFTER_COMMA\");\n break;\n }\n case \"}\": {\n lastValidIndex = i;\n stack.pop();\n break;\n }\n }\n }\n\n function processAfterArrayValue(char: string, i: number) {\n switch (char) {\n case \",\": {\n stack.pop();\n stack.push(\"INSIDE_ARRAY_AFTER_COMMA\");\n break;\n }\n case \"]\": {\n lastValidIndex = i;\n stack.pop();\n break;\n }\n }\n }\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i]!;\n const currentState = stack[stack.length - 1];\n\n switch (currentState) {\n case \"ROOT\":\n processValueStart(char, i, \"FINISH\");\n break;\n\n case \"INSIDE_OBJECT_START\": {\n switch (char) {\n case '\"': {\n stack.pop();\n stack.push(\"INSIDE_OBJECT_KEY\");\n break;\n }\n case \"}\": {\n lastValidIndex = i;\n stack.pop();\n break;\n }\n }\n break;\n }\n\n case \"INSIDE_OBJECT_AFTER_COMMA\": {\n switch (char) {\n case '\"': {\n stack.pop();\n stack.push(\"INSIDE_OBJECT_KEY\");\n break;\n }\n }\n break;\n }\n\n case \"INSIDE_OBJECT_KEY\": {\n switch (char) {\n case '\"': {\n stack.pop();\n stack.push(\"INSIDE_OBJECT_AFTER_KEY\");\n break;\n }\n }\n break;\n }\n\n case \"INSIDE_OBJECT_AFTER_KEY\": {\n switch (char) {\n case \":\": {\n stack.pop();\n stack.push(\"INSIDE_OBJECT_BEFORE_VALUE\");\n\n break;\n }\n }\n break;\n }\n\n case \"INSIDE_OBJECT_BEFORE_VALUE\": {\n processValueStart(char, i, \"INSIDE_OBJECT_AFTER_VALUE\");\n break;\n }\n\n case \"INSIDE_OBJECT_AFTER_VALUE\": {\n processAfterObjectValue(char, i);\n break;\n }\n\n case \"INSIDE_STRING\": {\n switch (char) {\n case '\"': {\n stack.pop();\n lastValidIndex = i;\n break;\n }\n\n case \"\\\\\": {\n stack.push(\"INSIDE_STRING_ESCAPE\");\n break;\n }\n\n default: {\n lastValidIndex = i;\n }\n }\n\n break;\n }\n\n case \"INSIDE_ARRAY_START\": {\n switch (char) {\n case \"]\": {\n lastValidIndex = i;\n stack.pop();\n break;\n }\n\n default: {\n lastValidIndex = i;\n processValueStart(char, i, \"INSIDE_ARRAY_AFTER_VALUE\");\n break;\n }\n }\n break;\n }\n\n case \"INSIDE_ARRAY_AFTER_VALUE\": {\n switch (char) {\n case \",\": {\n stack.pop();\n stack.push(\"INSIDE_ARRAY_AFTER_COMMA\");\n break;\n }\n\n case \"]\": {\n lastValidIndex = i;\n stack.pop();\n break;\n }\n\n default: {\n lastValidIndex = i;\n break;\n }\n }\n\n break;\n }\n\n case \"INSIDE_ARRAY_AFTER_COMMA\": {\n processValueStart(char, i, \"INSIDE_ARRAY_AFTER_VALUE\");\n break;\n }\n\n case \"INSIDE_STRING_ESCAPE\": {\n stack.pop();\n lastValidIndex = i;\n\n break;\n }\n\n case \"INSIDE_NUMBER\": {\n switch (char) {\n case \"0\":\n case \"1\":\n case \"2\":\n case \"3\":\n case \"4\":\n case \"5\":\n case \"6\":\n case \"7\":\n case \"8\":\n case \"9\": {\n lastValidIndex = i;\n break;\n }\n\n case \"e\":\n case \"E\":\n case \"-\":\n case \".\": {\n break;\n }\n\n case \",\": {\n stack.pop();\n\n if (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") {\n processAfterArrayValue(char, i);\n }\n\n if (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") {\n processAfterObjectValue(char, i);\n }\n\n break;\n }\n\n case \"}\": {\n stack.pop();\n\n if (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") {\n processAfterObjectValue(char, i);\n }\n\n break;\n }\n\n case \"]\": {\n stack.pop();\n\n if (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") {\n processAfterArrayValue(char, i);\n }\n\n break;\n }\n\n default: {\n stack.pop();\n break;\n }\n }\n\n break;\n }\n\n case \"INSIDE_LITERAL\": {\n const partialLiteral = input.substring(literalStart!, i + 1);\n\n if (\n !\"false\".startsWith(partialLiteral) &&\n !\"true\".startsWith(partialLiteral) &&\n !\"null\".startsWith(partialLiteral)\n ) {\n stack.pop();\n\n if (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") {\n processAfterObjectValue(char, i);\n } else if (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") {\n processAfterArrayValue(char, i);\n }\n } else {\n lastValidIndex = i;\n }\n\n break;\n }\n }\n }\n\n let result = input.slice(0, lastValidIndex + 1);\n\n for (let i = stack.length - 1; i >= 0; i--) {\n const state = stack[i];\n\n switch (state) {\n case \"INSIDE_STRING\": {\n result += '\"';\n break;\n }\n\n case \"INSIDE_OBJECT_KEY\":\n case \"INSIDE_OBJECT_AFTER_KEY\":\n case \"INSIDE_OBJECT_AFTER_COMMA\":\n case \"INSIDE_OBJECT_START\":\n case \"INSIDE_OBJECT_BEFORE_VALUE\":\n case \"INSIDE_OBJECT_AFTER_VALUE\": {\n result += \"}\";\n break;\n }\n\n case \"INSIDE_ARRAY_START\":\n case \"INSIDE_ARRAY_AFTER_COMMA\":\n case \"INSIDE_ARRAY_AFTER_VALUE\": {\n result += \"]\";\n break;\n }\n\n case \"INSIDE_LITERAL\": {\n const partialLiteral = input.substring(literalStart!, input.length);\n\n if (\"true\".startsWith(partialLiteral)) {\n result += \"true\".slice(partialLiteral.length);\n } else if (\"false\".startsWith(partialLiteral)) {\n result += \"false\".slice(partialLiteral.length);\n } else if (\"null\".startsWith(partialLiteral)) {\n result += \"null\".slice(partialLiteral.length);\n }\n }\n }\n }\n\n return result;\n}\n","import { ChatModelRunResult } from \"../../local/ChatModelAdapter\";\nimport { parsePartialJson } from \"../partial-json/parse-partial-json\";\nimport { LanguageModelV1StreamPart } from \"@ai-sdk/provider\";\nimport { ToolResultStreamPart } from \"./toolResultStream\";\nimport { MessageStatus } from \"../../../types\";\n\nexport function runResultStream() {\n let message: ChatModelRunResult = {\n content: [],\n status: { type: \"running\" },\n };\n const currentToolCall = { toolCallId: \"\", argsText: \"\" };\n\n return new TransformStream<ToolResultStreamPart, ChatModelRunResult>({\n transform(chunk, controller) {\n const chunkType = chunk.type;\n switch (chunkType) {\n case \"text-delta\": {\n message = appendOrUpdateText(message, chunk.textDelta);\n controller.enqueue(message);\n break;\n }\n case \"tool-call-delta\": {\n const { toolCallId, toolName, argsTextDelta } = chunk;\n if (currentToolCall.toolCallId !== toolCallId) {\n currentToolCall.toolCallId = toolCallId;\n currentToolCall.argsText = argsTextDelta;\n } else {\n currentToolCall.argsText += argsTextDelta;\n }\n\n message = appendOrUpdateToolCall(\n message,\n toolCallId,\n toolName,\n currentToolCall.argsText,\n );\n controller.enqueue(message);\n break;\n }\n case \"tool-call\": {\n break;\n }\n case \"tool-result\": {\n message = appendOrUpdateToolResult(\n message,\n chunk.toolCallId,\n chunk.toolName,\n chunk.result,\n );\n controller.enqueue(message);\n break;\n }\n case \"finish\": {\n message = appendOrUpdateFinish(message, chunk);\n controller.enqueue(message);\n break;\n }\n case \"error\": {\n if (\n chunk.error instanceof Error &&\n chunk.error.name === \"AbortError\"\n ) {\n message = appendOrUpdateCancel(message);\n controller.enqueue(message);\n break;\n } else {\n throw chunk.error;\n }\n }\n default: {\n const unhandledType: never = chunkType;\n throw new Error(`Unhandled chunk type: ${unhandledType}`);\n }\n }\n },\n });\n}\n\nconst appendOrUpdateText = (message: ChatModelRunResult, textDelta: string) => {\n let contentParts = message.content;\n let contentPart = message.content.at(-1);\n if (contentPart?.type !== \"text\") {\n contentPart = { type: \"text\", text: textDelta };\n } else {\n contentParts = contentParts.slice(0, -1);\n contentPart = { type: \"text\", text: contentPart.text + textDelta };\n }\n return {\n ...message,\n content: contentParts.concat([contentPart]),\n };\n};\n\nconst appendOrUpdateToolCall = (\n message: ChatModelRunResult,\n toolCallId: string,\n toolName: string,\n argsText: string,\n) => {\n let contentParts = message.content;\n let contentPart = message.content.at(-1);\n if (\n contentPart?.type !== \"tool-call\" ||\n contentPart.toolCallId !== toolCallId\n ) {\n contentPart = {\n type: \"tool-call\",\n toolCallId,\n toolName,\n argsText,\n args: parsePartialJson(argsText),\n };\n } else {\n contentParts = contentParts.slice(0, -1);\n contentPart = {\n ...contentPart,\n argsText,\n args: parsePartialJson(argsText),\n };\n }\n return {\n ...message,\n content: contentParts.concat([contentPart]),\n };\n};\n\nconst appendOrUpdateToolResult = (\n message: ChatModelRunResult,\n toolCallId: string,\n toolName: string,\n result: any,\n) => {\n let found = false;\n const newContentParts = message.content.map((part) => {\n if (part.type !== \"tool-call\" || part.toolCallId !== toolCallId)\n return part;\n found = true;\n\n if (part.toolName !== toolName)\n throw new Error(\n `Tool call ${toolCallId} found with tool name ${part.toolName}, but expected ${toolName}`,\n );\n\n return {\n ...part,\n result,\n };\n });\n if (!found)\n throw new Error(\n `Received tool result for unknown tool call \"${toolName}\" / \"${toolCallId}\". This is likely an internal bug in assistant-ui.`,\n );\n\n return {\n ...message,\n content: newContentParts,\n };\n};\n\nconst appendOrUpdateFinish = (\n message: ChatModelRunResult,\n chunk: LanguageModelV1StreamPart & { type: \"finish\" },\n): ChatModelRunResult => {\n const { type, ...rest } = chunk;\n return {\n ...message,\n status: getStatus(chunk),\n roundtrips: [\n ...(message.roundtrips ?? []),\n {\n logprobs: rest.logprobs,\n usage: rest.usage,\n },\n ],\n };\n};\n\nconst getStatus = (\n chunk: LanguageModelV1StreamPart & { type: \"finish\" },\n): MessageStatus => {\n if (chunk.finishReason === \"tool-calls\") {\n return {\n type: \"requires-action\",\n reason: \"tool-calls\",\n };\n } else if (\n chunk.finishReason === \"stop\" ||\n chunk.finishReason === \"unknown\"\n ) {\n return {\n type: \"complete\",\n reason: chunk.finishReason,\n };\n } else {\n return {\n type: \"incomplete\",\n reason: chunk.finishReason,\n };\n }\n};\n\nconst appendOrUpdateCancel = (\n message: ChatModelRunResult,\n): ChatModelRunResult => {\n return {\n ...message,\n status: {\n type: \"incomplete\",\n reason: \"cancelled\",\n },\n };\n};\n","import { ThreadMessage, CoreMessage } from \"../../../types\";\n\nexport const toCoreMessages = (message: ThreadMessage[]): CoreMessage[] => {\n return message.map(toCoreMessage);\n};\n\nexport const toCoreMessage = (message: ThreadMessage): CoreMessage => {\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n role,\n content: message.content.map((part) => {\n if (part.type === \"ui\") throw new Error(\"UI parts are not supported\");\n if (part.type === \"tool-call\") {\n const { argsText, ...rest } = part;\n return rest;\n }\n return part;\n }),\n };\n\n case \"user\":\n return {\n role,\n content: message.content.map((part) => {\n if (part.type === \"ui\") throw new Error(\"UI parts are not supported\");\n return part;\n }),\n };\n\n case \"system\":\n return {\n role,\n content: message.content,\n };\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n","import {\n LanguageModelV1,\n LanguageModelV1ToolChoice,\n LanguageModelV1FunctionTool,\n LanguageModelV1Prompt,\n LanguageModelV1CallOptions,\n} from \"@ai-sdk/provider\";\nimport {\n CoreMessage,\n ThreadMessage,\n ThreadRoundtrip,\n} from \"../../types/AssistantTypes\";\nimport { assistantEncoderStream } from \"./streams/assistantEncoderStream\";\nimport { EdgeRuntimeRequestOptionsSchema } from \"./EdgeRuntimeRequestOptions\";\nimport { toLanguageModelMessages } from \"./converters/toLanguageModelMessages\";\nimport { Tool } from \"../../types\";\nimport { toLanguageModelTools } from \"./converters/toLanguageModelTools\";\nimport {\n toolResultStream,\n ToolResultStreamPart,\n} from \"./streams/toolResultStream\";\nimport { runResultStream } from \"./streams/runResultStream\";\nimport {\n LanguageModelConfig,\n LanguageModelV1CallSettings,\n LanguageModelV1CallSettingsSchema,\n} from \"../../types/ModelConfigTypes\";\nimport { ChatModelRunResult } from \"../local\";\nimport { toCoreMessage } from \"./converters/toCoreMessages\";\n\ntype FinishResult = {\n messages: CoreMessage[];\n roundtrips: ThreadRoundtrip[];\n};\n\ntype LanguageModelCreator = (\n config: LanguageModelConfig,\n) => Promise<LanguageModelV1> | LanguageModelV1;\n\ntype CreateEdgeRuntimeAPIOptions = LanguageModelV1CallSettings & {\n model: LanguageModelV1 | LanguageModelCreator;\n system?: string;\n tools?: Record<string, Tool<any, any>>;\n toolChoice?: LanguageModelV1ToolChoice;\n onFinish?: (result: FinishResult) => void;\n};\n\nconst voidStream = () => {\n return new WritableStream({\n abort(reason) {\n console.error(\"Server stream processing aborted:\", reason);\n },\n });\n};\n\nexport const createEdgeRuntimeAPI = ({\n model: modelOrCreator,\n system: serverSystem,\n tools: serverTools = {},\n toolChoice,\n onFinish,\n ...unsafeSettings\n}: CreateEdgeRuntimeAPIOptions) => {\n const settings = LanguageModelV1CallSettingsSchema.parse(unsafeSettings);\n const lmServerTools = toLanguageModelTools(serverTools);\n const hasServerTools = Object.values(serverTools).some((v) => !!v.execute);\n\n const POST = async (request: Request) => {\n const {\n system: clientSystem,\n tools: clientTools = [],\n messages,\n apiKey,\n baseUrl,\n modelName,\n ...callSettings\n } = EdgeRuntimeRequestOptionsSchema.parse(await request.json());\n\n const systemMessages = [];\n if (serverSystem) systemMessages.push(serverSystem);\n if (clientSystem) systemMessages.push(clientSystem);\n const system = systemMessages.join(\"\\n\\n\");\n\n for (const clientTool of clientTools) {\n if (serverTools?.[clientTool.name]) {\n throw new Error(\n `Tool ${clientTool.name} was defined in both the client and server tools. This is not allowed.`,\n );\n }\n }\n\n let model;\n\n try {\n model =\n typeof modelOrCreator === \"function\"\n ? await modelOrCreator({ apiKey, baseUrl, modelName })\n : modelOrCreator;\n } catch (e) {\n return new Response(\n JSON.stringify({\n type: \"error\",\n error: (e as Error).message,\n }),\n {\n status: 500,\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n );\n }\n\n let stream: ReadableStream<ToolResultStreamPart>;\n const streamResult = await streamMessage({\n ...(settings as Partial<StreamMessageOptions>),\n ...callSettings,\n\n model,\n abortSignal: request.signal,\n\n ...(!!system ? { system } : undefined),\n messages,\n tools: lmServerTools.concat(clientTools as LanguageModelV1FunctionTool[]),\n ...(toolChoice ? { toolChoice } : undefined),\n });\n stream = streamResult.stream;\n\n // add tool results if we have server tools\n const canExecuteTools = hasServerTools && toolChoice?.type !== \"none\";\n if (canExecuteTools) {\n stream = stream.pipeThrough(toolResultStream(serverTools));\n }\n\n if (canExecuteTools || onFinish) {\n // tee the stream to process server tools and onFinish asap\n const tees = stream.tee();\n stream = tees[0];\n let serverStream = tees[1];\n\n if (onFinish) {\n let lastChunk: ChatModelRunResult;\n serverStream = serverStream.pipeThrough(runResultStream()).pipeThrough(\n new TransformStream({\n transform(chunk) {\n lastChunk = chunk;\n },\n flush() {\n if (!lastChunk?.status || lastChunk.status.type === \"running\")\n return;\n\n const resultingMessages = [\n ...messages,\n toCoreMessage({\n role: \"assistant\",\n content: lastChunk.content,\n } as ThreadMessage),\n ];\n onFinish({\n messages: resultingMessages,\n roundtrips: lastChunk.roundtrips!,\n });\n },\n }),\n );\n }\n\n // drain the server stream\n serverStream.pipeTo(voidStream()).catch((e) => {\n console.error(\"Server stream processing error:\", e);\n });\n }\n\n return new Response(\n stream\n .pipeThrough(assistantEncoderStream())\n .pipeThrough(new TextEncoderStream()),\n {\n headers: {\n contentType: \"text/plain; charset=utf-8\",\n },\n },\n );\n };\n return { POST };\n};\n\ntype StreamMessageOptions = LanguageModelV1CallSettings & {\n model: LanguageModelV1;\n system?: string;\n messages: CoreMessage[];\n tools?: LanguageModelV1FunctionTool[];\n toolChoice?: LanguageModelV1ToolChoice;\n abortSignal: AbortSignal;\n};\n\nasync function streamMessage({\n model,\n system,\n messages,\n tools,\n toolChoice,\n ...options\n}: StreamMessageOptions) {\n return model.doStream({\n inputFormat: \"messages\",\n mode: {\n type: \"regular\",\n ...(tools ? { tools } : undefined),\n ...(toolChoice ? { toolChoice } : undefined),\n },\n prompt: convertToLanguageModelPrompt(system, messages),\n ...(options as Partial<LanguageModelV1CallOptions>),\n });\n}\n\nexport function convertToLanguageModelPrompt(\n system: string | undefined,\n messages: CoreMessage[],\n): LanguageModelV1Prompt {\n const languageModelMessages: LanguageModelV1Prompt = [];\n\n if (system != null) {\n languageModelMessages.push({ role: \"system\", content: system });\n }\n languageModelMessages.push(...toLanguageModelMessages(messages));\n\n return languageModelMessages;\n}\n"],"mappings":";;;;;;AAMO,SAAS,yBAAyB;AACvC,QAAM,YAAY,oBAAI,IAAY;AAClC,SAAO,IAAI,gBAA8C;AAAA,IACvD,UAAU,OAAO,YAAY;AAC3B,YAAM,YAAY,MAAM;AACxB,cAAQ,WAAW;AAAA,QACjB,KAAK,cAAc;AACjB,qBAAW;AAAA,YACT;AAAA;AAAA,cAEE,MAAM;AAAA,YACR;AAAA,UACF;AACA;AAAA,QACF;AAAA,QACA,KAAK,mBAAmB;AACtB,cAAI,CAAC,UAAU,IAAI,MAAM,UAAU,GAAG;AACpC,sBAAU,IAAI,MAAM,UAAU;AAC9B,uBAAW;AAAA,cACT,0CAAyD;AAAA,gBACvD,IAAI,MAAM;AAAA,gBACV,MAAM,MAAM;AAAA,cACd,CAAC;AAAA,YACH;AAAA,UACF;AAEA,qBAAW;AAAA,YACT;AAAA;AAAA,cAEE,MAAM;AAAA,YACR;AAAA,UACF;AACA;AAAA,QACF;AAAA,QAGA,KAAK;AACH;AAAA,QAEF,KAAK,eAAe;AAClB,qBAAW;AAAA,YACT,2CAA0D;AAAA,cACxD,IAAI,MAAM;AAAA,cACV,QAAQ,MAAM;AAAA,YAChB,CAAC;AAAA,UACH;AACA;AAAA,QACF;AAAA,QAEA,KAAK,UAAU;AACb,gBAAM,EAAE,MAAM,GAAG,KAAK,IAAI;AAC1B,qBAAW;AAAA,YACT,mCAAkD,IAAI;AAAA,UACxD;AACA;AAAA,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AAK,GAAG,wBAAwB,QAAQ,CAAC;AAE/D,SAAO;AACT;","names":["message","z","z","result","sjson","sjson"]}
|
1
|
+
{"version":3,"sources":["../src/runtimes/edge/streams/assistantEncoderStream.ts","../src/runtimes/edge/EdgeRuntimeRequestOptions.ts","../src/runtimes/edge/createEdgeRuntimeAPI.ts"],"sourcesContent":["import {\n AssistantStreamChunkTuple,\n AssistantStreamChunkType,\n} from \"./AssistantStreamChunkType\";\nimport { ToolResultStreamPart } from \"./toolResultStream\";\n\nexport function assistantEncoderStream() {\n const toolCalls = new Set<string>();\n return new TransformStream<ToolResultStreamPart, string>({\n transform(chunk, controller) {\n const chunkType = chunk.type;\n switch (chunkType) {\n case \"text-delta\": {\n controller.enqueue(\n formatStreamPart(\n AssistantStreamChunkType.TextDelta,\n chunk.textDelta,\n ),\n );\n break;\n }\n case \"tool-call-delta\": {\n if (!toolCalls.has(chunk.toolCallId)) {\n toolCalls.add(chunk.toolCallId);\n controller.enqueue(\n formatStreamPart(AssistantStreamChunkType.ToolCallBegin, {\n id: chunk.toolCallId,\n name: chunk.toolName,\n }),\n );\n }\n\n controller.enqueue(\n formatStreamPart(\n AssistantStreamChunkType.ToolCallArgsTextDelta,\n chunk.argsTextDelta,\n ),\n );\n break;\n }\n\n // ignore\n case \"tool-call\":\n break;\n\n case \"tool-result\": {\n controller.enqueue(\n formatStreamPart(AssistantStreamChunkType.ToolCallResult, {\n id: chunk.toolCallId,\n result: chunk.result,\n }),\n );\n break;\n }\n\n case \"finish\": {\n const { type, ...rest } = chunk;\n controller.enqueue(\n formatStreamPart(AssistantStreamChunkType.Finish, rest),\n );\n break;\n }\n\n case \"error\": {\n controller.enqueue(\n formatStreamPart(AssistantStreamChunkType.Error, chunk.error),\n );\n break;\n }\n default: {\n const unhandledType: never = chunkType;\n throw new Error(`Unhandled chunk type: ${unhandledType}`);\n }\n }\n },\n });\n}\n\nexport function formatStreamPart(\n ...[code, value]: AssistantStreamChunkTuple\n): string {\n return `${code}:${JSON.stringify(value)}\\n`;\n}\n","import { JSONSchema7 } from \"json-schema\";\nimport {\n LanguageModelConfigSchema,\n LanguageModelV1CallSettingsSchema,\n} from \"../../types/ModelConfigTypes\";\nimport { z } from \"zod\";\n\nconst LanguageModelV1FunctionToolSchema = z.object({\n type: z.literal(\"function\"),\n name: z.string(),\n description: z.string().optional(),\n parameters: z.custom<JSONSchema7>(\n (val) => typeof val === \"object\" && val !== null,\n ),\n});\n\nconst TextContentPartSchema = z.object({\n type: z.literal(\"text\"),\n text: z.string(),\n});\n\nconst ImageContentPartSchema = z.object({\n type: z.literal(\"image\"),\n image: z.string(),\n});\n\nconst CoreToolCallContentPartSchema = z.object({\n type: z.literal(\"tool-call\"),\n toolCallId: z.string(),\n toolName: z.string(),\n args: z.record(z.unknown()),\n result: z.unknown().optional(),\n isError: z.boolean().optional(),\n});\n// args is required but unknown;\n\nconst CoreUserMessageSchema = z.object({\n role: z.literal(\"user\"),\n content: z\n .array(\n z.discriminatedUnion(\"type\", [\n TextContentPartSchema,\n ImageContentPartSchema,\n ]),\n )\n .min(1),\n});\n\nconst CoreAssistantMessageSchema = z.object({\n role: z.literal(\"assistant\"),\n content: z\n .array(\n z.discriminatedUnion(\"type\", [\n TextContentPartSchema,\n CoreToolCallContentPartSchema,\n ]),\n )\n .min(1),\n});\n\nconst CoreSystemMessageSchema = z.object({\n role: z.literal(\"system\"),\n content: z.tuple([TextContentPartSchema]),\n});\n\nconst CoreMessageSchema = z.discriminatedUnion(\"role\", [\n CoreSystemMessageSchema,\n CoreUserMessageSchema,\n CoreAssistantMessageSchema,\n]);\n\nexport const EdgeRuntimeRequestOptionsSchema = z\n .object({\n system: z.string().optional(),\n messages: z.array(CoreMessageSchema).min(1),\n tools: z.array(LanguageModelV1FunctionToolSchema).optional(),\n })\n .merge(LanguageModelV1CallSettingsSchema)\n .merge(LanguageModelConfigSchema);\n\nexport type EdgeRuntimeRequestOptions = z.infer<\n typeof EdgeRuntimeRequestOptionsSchema\n>;\n","import {\n LanguageModelV1,\n LanguageModelV1ToolChoice,\n LanguageModelV1FunctionTool,\n LanguageModelV1Prompt,\n LanguageModelV1CallOptions,\n} from \"@ai-sdk/provider\";\nimport {\n CoreMessage,\n ThreadMessage,\n ThreadRoundtrip,\n} from \"../../types/AssistantTypes\";\nimport { assistantEncoderStream } from \"./streams/assistantEncoderStream\";\nimport { EdgeRuntimeRequestOptionsSchema } from \"./EdgeRuntimeRequestOptions\";\nimport { toLanguageModelMessages } from \"./converters/toLanguageModelMessages\";\nimport { Tool } from \"../../types\";\nimport { toLanguageModelTools } from \"./converters/toLanguageModelTools\";\nimport {\n toolResultStream,\n ToolResultStreamPart,\n} from \"./streams/toolResultStream\";\nimport { runResultStream } from \"./streams/runResultStream\";\nimport {\n LanguageModelConfig,\n LanguageModelV1CallSettings,\n LanguageModelV1CallSettingsSchema,\n} from \"../../types/ModelConfigTypes\";\nimport { ChatModelRunResult } from \"../local\";\nimport { toCoreMessage } from \"./converters/toCoreMessages\";\n\ntype FinishResult = {\n messages: CoreMessage[];\n roundtrips: ThreadRoundtrip[];\n};\n\ntype LanguageModelCreator = (\n config: LanguageModelConfig,\n) => Promise<LanguageModelV1> | LanguageModelV1;\n\ntype CreateEdgeRuntimeAPIOptions = LanguageModelV1CallSettings & {\n model: LanguageModelV1 | LanguageModelCreator;\n system?: string;\n tools?: Record<string, Tool<any, any>>;\n toolChoice?: LanguageModelV1ToolChoice;\n onFinish?: (result: FinishResult) => void;\n};\n\nconst voidStream = () => {\n return new WritableStream({\n abort(reason) {\n console.error(\"Server stream processing aborted:\", reason);\n },\n });\n};\n\nexport const createEdgeRuntimeAPI = ({\n model: modelOrCreator,\n system: serverSystem,\n tools: serverTools = {},\n toolChoice,\n onFinish,\n ...unsafeSettings\n}: CreateEdgeRuntimeAPIOptions) => {\n const settings = LanguageModelV1CallSettingsSchema.parse(unsafeSettings);\n const lmServerTools = toLanguageModelTools(serverTools);\n const hasServerTools = Object.values(serverTools).some((v) => !!v.execute);\n\n const POST = async (request: Request) => {\n const {\n system: clientSystem,\n tools: clientTools = [],\n messages,\n apiKey,\n baseUrl,\n modelName,\n ...callSettings\n } = EdgeRuntimeRequestOptionsSchema.parse(await request.json());\n\n const systemMessages = [];\n if (serverSystem) systemMessages.push(serverSystem);\n if (clientSystem) systemMessages.push(clientSystem);\n const system = systemMessages.join(\"\\n\\n\");\n\n for (const clientTool of clientTools) {\n if (serverTools?.[clientTool.name]) {\n throw new Error(\n `Tool ${clientTool.name} was defined in both the client and server tools. This is not allowed.`,\n );\n }\n }\n\n let model;\n\n try {\n model =\n typeof modelOrCreator === \"function\"\n ? await modelOrCreator({ apiKey, baseUrl, modelName })\n : modelOrCreator;\n } catch (e) {\n return new Response(\n JSON.stringify({\n type: \"error\",\n error: (e as Error).message,\n }),\n {\n status: 500,\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n );\n }\n\n let stream: ReadableStream<ToolResultStreamPart>;\n const streamResult = await streamMessage({\n ...(settings as Partial<StreamMessageOptions>),\n ...callSettings,\n\n model,\n abortSignal: request.signal,\n\n ...(!!system ? { system } : undefined),\n messages,\n tools: lmServerTools.concat(clientTools as LanguageModelV1FunctionTool[]),\n ...(toolChoice ? { toolChoice } : undefined),\n });\n stream = streamResult.stream;\n\n // add tool results if we have server tools\n const canExecuteTools = hasServerTools && toolChoice?.type !== \"none\";\n if (canExecuteTools) {\n stream = stream.pipeThrough(toolResultStream(serverTools));\n }\n\n if (canExecuteTools || onFinish) {\n // tee the stream to process server tools and onFinish asap\n const tees = stream.tee();\n stream = tees[0];\n let serverStream = tees[1];\n\n if (onFinish) {\n let lastChunk: ChatModelRunResult;\n serverStream = serverStream.pipeThrough(runResultStream()).pipeThrough(\n new TransformStream({\n transform(chunk) {\n lastChunk = chunk;\n },\n flush() {\n if (!lastChunk?.status || lastChunk.status.type === \"running\")\n return;\n\n const resultingMessages = [\n ...messages,\n toCoreMessage({\n role: \"assistant\",\n content: lastChunk.content,\n } as ThreadMessage),\n ];\n onFinish({\n messages: resultingMessages,\n roundtrips: lastChunk.roundtrips!,\n });\n },\n }),\n );\n }\n\n // drain the server stream\n serverStream.pipeTo(voidStream()).catch((e) => {\n console.error(\"Server stream processing error:\", e);\n });\n }\n\n return new Response(\n stream\n .pipeThrough(assistantEncoderStream())\n .pipeThrough(new TextEncoderStream()),\n {\n headers: {\n contentType: \"text/plain; charset=utf-8\",\n },\n },\n );\n };\n return { POST };\n};\n\ntype StreamMessageOptions = LanguageModelV1CallSettings & {\n model: LanguageModelV1;\n system?: string;\n messages: CoreMessage[];\n tools?: LanguageModelV1FunctionTool[];\n toolChoice?: LanguageModelV1ToolChoice;\n abortSignal: AbortSignal;\n};\n\nasync function streamMessage({\n model,\n system,\n messages,\n tools,\n toolChoice,\n ...options\n}: StreamMessageOptions) {\n return model.doStream({\n inputFormat: \"messages\",\n mode: {\n type: \"regular\",\n ...(tools ? { tools } : undefined),\n ...(toolChoice ? { toolChoice } : undefined),\n },\n prompt: convertToLanguageModelPrompt(system, messages),\n ...(options as Partial<LanguageModelV1CallOptions>),\n });\n}\n\nexport function convertToLanguageModelPrompt(\n system: string | undefined,\n messages: CoreMessage[],\n): LanguageModelV1Prompt {\n const languageModelMessages: LanguageModelV1Prompt = [];\n\n if (system != null) {\n languageModelMessages.push({ role: \"system\", content: system });\n }\n languageModelMessages.push(...toLanguageModelMessages(messages));\n\n return languageModelMessages;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAMO,SAAS,yBAAyB;AACvC,QAAM,YAAY,oBAAI,IAAY;AAClC,SAAO,IAAI,gBAA8C;AAAA,IACvD,UAAU,OAAO,YAAY;AAC3B,YAAM,YAAY,MAAM;AACxB,cAAQ,WAAW;AAAA,QACjB,KAAK,cAAc;AACjB,qBAAW;AAAA,YACT;AAAA;AAAA,cAEE,MAAM;AAAA,YACR;AAAA,UACF;AACA;AAAA,QACF;AAAA,QACA,KAAK,mBAAmB;AACtB,cAAI,CAAC,UAAU,IAAI,MAAM,UAAU,GAAG;AACpC,sB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O,IAAI;AAAA,MACT,OACG,YAAY,uBAAuB,CAAC,EACpC,YAAY,IAAI,kBAAkB,CAAC;AAAA,MACtC;AAAA,QACE,SAAS;AAAA,UACP,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,KAAK;AAChB;AAWA,eAAe,cAAc;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAyB;AACvB,SAAO,MAAM,SAAS;AAAA,IACpB,aAAa;AAAA,IACb,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,GAAI,QAAQ,EAAE,MAAM,IAAI;AAAA,MACxB,GAAI,aAAa,EAAE,WAAW,IAAI;AAAA,IACpC;AAAA,IACA,QAAQ,6BAA6B,QAAQ,QAAQ;AAAA,IACrD,GAAI;AAAA,EACN,CAAC;AACH;AAEO,SAAS,6BACd,QACA,UACuB;AACvB,QAAM,wBAA+C,CAAC;AAEtD,MAAI,UAAU,MAAM;AAClB,0BAAsB,KAAK,EAAE,MAAM,UAAU,SAAS,OAAO,CAAC;AAAA,EAChE;AACA,wBAAsB,KAAK,GAAG,wBAAwB,QAAQ,CAAC;AAE/D,SAAO;AACT;","names":[]}
|
package/dist/index.d.mts
CHANGED
@@ -1,179 +1,22 @@
|
|
1
1
|
import * as react from 'react';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
|
5
|
-
import {
|
2
|
+
import { ComponentType, PropsWithChildren, ComponentPropsWithoutRef, FC, ElementType, ReactNode } from 'react';
|
3
|
+
import { T as ThreadRuntime, U as Unsubscribe, A as AddToolResultOptions, B as BaseAssistantRuntime, R as ReactThreadRuntime, a as AssistantRuntime, b as ThreadState, c as ThreadActionsState, C as ContentPartState, d as TooltipIconButtonProps, e as ButtonProps } from './Thread-BbLf1cc4.mjs';
|
4
|
+
export { i as INTERNAL } from './Thread-BbLf1cc4.mjs';
|
5
|
+
import { T as ThreadAssistantContentPart, M as MessageStatus, a as ThreadRoundtrip, b as ThreadMessage, c as ModelConfig, d as TextContentPart, C as ContentPartStatus, I as ImageContentPart, U as UIContentPart, e as ToolCallContentPart, f as ToolCallContentPartStatus, g as CoreMessage, h as ModelConfigProvider, A as AppendMessage, i as Tool, j as CoreToolCallContentPart } from './AssistantTypes-D93BmqD5.mjs';
|
6
|
+
export { p as CoreAssistantContentPart, s as CoreAssistantMessage, q as CoreSystemMessage, o as CoreUserContentPart, r as CoreUserMessage, m as ThreadAssistantMessage, l as ThreadSystemMessage, k as ThreadUserContentPart, n as ThreadUserMessage } from './AssistantTypes-D93BmqD5.mjs';
|
6
7
|
import { UseBoundStore, StoreApi } from 'zustand';
|
7
8
|
import { Primitive } from '@radix-ui/react-primitive';
|
8
9
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
9
10
|
import * as react_textarea_autosize from 'react-textarea-autosize';
|
10
11
|
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
11
|
-
import
|
12
|
-
import {
|
13
|
-
import
|
14
|
-
|
15
|
-
|
16
|
-
maxTokens: z.ZodOptional<z.ZodNumber>;
|
17
|
-
temperature: z.ZodOptional<z.ZodNumber>;
|
18
|
-
topP: z.ZodOptional<z.ZodNumber>;
|
19
|
-
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
20
|
-
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
21
|
-
seed: z.ZodOptional<z.ZodNumber>;
|
22
|
-
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
|
23
|
-
}, "strip", z.ZodTypeAny, {
|
24
|
-
maxTokens?: number | undefined;
|
25
|
-
temperature?: number | undefined;
|
26
|
-
topP?: number | undefined;
|
27
|
-
presencePenalty?: number | undefined;
|
28
|
-
frequencyPenalty?: number | undefined;
|
29
|
-
seed?: number | undefined;
|
30
|
-
headers?: Record<string, string | undefined> | undefined;
|
31
|
-
}, {
|
32
|
-
maxTokens?: number | undefined;
|
33
|
-
temperature?: number | undefined;
|
34
|
-
topP?: number | undefined;
|
35
|
-
presencePenalty?: number | undefined;
|
36
|
-
frequencyPenalty?: number | undefined;
|
37
|
-
seed?: number | undefined;
|
38
|
-
headers?: Record<string, string | undefined> | undefined;
|
39
|
-
}>;
|
40
|
-
type LanguageModelV1CallSettings = z.infer<typeof LanguageModelV1CallSettingsSchema>;
|
41
|
-
declare const LanguageModelConfigSchema: z.ZodObject<{
|
42
|
-
apiKey: z.ZodOptional<z.ZodString>;
|
43
|
-
baseUrl: z.ZodOptional<z.ZodString>;
|
44
|
-
modelName: z.ZodOptional<z.ZodString>;
|
45
|
-
}, "strip", z.ZodTypeAny, {
|
46
|
-
apiKey?: string | undefined;
|
47
|
-
baseUrl?: string | undefined;
|
48
|
-
modelName?: string | undefined;
|
49
|
-
}, {
|
50
|
-
apiKey?: string | undefined;
|
51
|
-
baseUrl?: string | undefined;
|
52
|
-
modelName?: string | undefined;
|
53
|
-
}>;
|
54
|
-
type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;
|
55
|
-
type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
|
56
|
-
type Tool<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
|
57
|
-
description?: string | undefined;
|
58
|
-
parameters: z.ZodSchema<TArgs> | JSONSchema7;
|
59
|
-
execute?: ToolExecuteFunction<TArgs, TResult>;
|
60
|
-
};
|
61
|
-
type ModelConfig = {
|
62
|
-
priority?: number | undefined;
|
63
|
-
system?: string | undefined;
|
64
|
-
tools?: Record<string, Tool<any, any>> | undefined;
|
65
|
-
callSettings?: LanguageModelV1CallSettings | undefined;
|
66
|
-
config?: LanguageModelConfig | undefined;
|
67
|
-
};
|
68
|
-
type ModelConfigProvider = {
|
69
|
-
getModelConfig: () => ModelConfig;
|
70
|
-
};
|
71
|
-
|
72
|
-
type Unsubscribe = () => void;
|
73
|
-
|
74
|
-
type TextContentPart = {
|
75
|
-
type: "text";
|
76
|
-
text: string;
|
77
|
-
};
|
78
|
-
type ImageContentPart = {
|
79
|
-
type: "image";
|
80
|
-
image: string;
|
81
|
-
};
|
82
|
-
type UIContentPart = {
|
83
|
-
type: "ui";
|
84
|
-
display: ReactNode;
|
85
|
-
};
|
86
|
-
type CoreToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
|
87
|
-
type: "tool-call";
|
88
|
-
toolCallId: string;
|
89
|
-
toolName: string;
|
90
|
-
args: TArgs;
|
91
|
-
result?: TResult | undefined;
|
92
|
-
isError?: boolean | undefined;
|
93
|
-
};
|
94
|
-
type ToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
|
95
|
-
argsText: string;
|
96
|
-
};
|
97
|
-
type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
98
|
-
type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
99
|
-
type MessageCommonProps = {
|
100
|
-
id: string;
|
101
|
-
createdAt: Date;
|
102
|
-
};
|
103
|
-
type ThreadRoundtrip = {
|
104
|
-
logprobs?: LanguageModelV1LogProbs | undefined;
|
105
|
-
usage?: {
|
106
|
-
promptTokens: number;
|
107
|
-
completionTokens: number;
|
108
|
-
} | undefined;
|
109
|
-
};
|
110
|
-
type ContentPartStatus = {
|
111
|
-
type: "running";
|
112
|
-
} | {
|
113
|
-
type: "complete";
|
114
|
-
} | {
|
115
|
-
type: "incomplete";
|
116
|
-
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
117
|
-
error?: unknown;
|
118
|
-
};
|
119
|
-
type ToolCallContentPartStatus = {
|
120
|
-
type: "requires-action";
|
121
|
-
reason: "tool-calls";
|
122
|
-
} | ContentPartStatus;
|
123
|
-
type MessageStatus = {
|
124
|
-
type: "running";
|
125
|
-
} | {
|
126
|
-
type: "requires-action";
|
127
|
-
reason: "tool-calls";
|
128
|
-
} | {
|
129
|
-
type: "complete";
|
130
|
-
reason: "stop" | "unknown";
|
131
|
-
} | {
|
132
|
-
type: "incomplete";
|
133
|
-
reason: "cancelled" | "tool-calls" | "length" | "content-filter" | "other" | "error";
|
134
|
-
error?: unknown;
|
135
|
-
};
|
136
|
-
type ThreadSystemMessage = MessageCommonProps & {
|
137
|
-
role: "system";
|
138
|
-
content: [TextContentPart];
|
139
|
-
};
|
140
|
-
type ThreadUserMessage = MessageCommonProps & {
|
141
|
-
role: "user";
|
142
|
-
content: ThreadUserContentPart[];
|
143
|
-
};
|
144
|
-
type ThreadAssistantMessage = MessageCommonProps & {
|
145
|
-
role: "assistant";
|
146
|
-
content: ThreadAssistantContentPart[];
|
147
|
-
status: MessageStatus;
|
148
|
-
roundtrips?: ThreadRoundtrip[] | undefined;
|
149
|
-
};
|
150
|
-
type AppendMessage = CoreMessage & {
|
151
|
-
parentId: string | null;
|
152
|
-
};
|
153
|
-
type ThreadMessage = ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage;
|
154
|
-
/** Core Message Types (without UI content parts) */
|
155
|
-
type CoreUserContentPart = TextContentPart | ImageContentPart;
|
156
|
-
type CoreAssistantContentPart = TextContentPart | CoreToolCallContentPart;
|
157
|
-
type CoreSystemMessage = {
|
158
|
-
role: "system";
|
159
|
-
content: [TextContentPart];
|
160
|
-
};
|
161
|
-
type CoreUserMessage = {
|
162
|
-
role: "user";
|
163
|
-
content: CoreUserContentPart[];
|
164
|
-
};
|
165
|
-
type CoreAssistantMessage = {
|
166
|
-
role: "assistant";
|
167
|
-
content: CoreAssistantContentPart[];
|
168
|
-
};
|
169
|
-
type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
|
12
|
+
import { LanguageModelV1Message, LanguageModelV1FunctionTool } from '@ai-sdk/provider';
|
13
|
+
import { JSONSchema7 } from 'json-schema';
|
14
|
+
import { z } from 'zod';
|
15
|
+
import 'class-variance-authority';
|
16
|
+
import 'class-variance-authority/types';
|
170
17
|
|
171
18
|
type ReadonlyStore<T> = UseBoundStore<Omit<StoreApi<T>, "setState" | "destroy">>;
|
172
19
|
|
173
|
-
type ReactThreadRuntime = ThreadRuntime & {
|
174
|
-
unstable_synchronizer?: ComponentType;
|
175
|
-
};
|
176
|
-
|
177
20
|
type ChatModelRunUpdate = {
|
178
21
|
content: ThreadAssistantContentPart[];
|
179
22
|
};
|
@@ -195,18 +38,6 @@ type ChatModelAdapter = {
|
|
195
38
|
run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;
|
196
39
|
};
|
197
40
|
|
198
|
-
declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
|
199
|
-
private _thread;
|
200
|
-
constructor(_thread: TThreadRuntime);
|
201
|
-
get thread(): TThreadRuntime;
|
202
|
-
set thread(thread: TThreadRuntime);
|
203
|
-
abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
|
204
|
-
abstract switchToThread(threadId: string | null): void;
|
205
|
-
private _subscriptions;
|
206
|
-
subscribe(callback: () => void): Unsubscribe;
|
207
|
-
private subscriptionHandler;
|
208
|
-
}
|
209
|
-
|
210
41
|
type TextContentPartProps = {
|
211
42
|
part: TextContentPart;
|
212
43
|
status: ContentPartStatus;
|
@@ -585,94 +416,6 @@ type ExternalStoreAdapterBase<T> = {
|
|
585
416
|
};
|
586
417
|
type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
|
587
418
|
|
588
|
-
declare class ProxyConfigProvider implements ModelConfigProvider {
|
589
|
-
private _providers;
|
590
|
-
getModelConfig(): ModelConfig;
|
591
|
-
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
592
|
-
}
|
593
|
-
|
594
|
-
declare class MessageRepository {
|
595
|
-
private messages;
|
596
|
-
private head;
|
597
|
-
private root;
|
598
|
-
private performOp;
|
599
|
-
getMessages(): ThreadMessage[];
|
600
|
-
addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
|
601
|
-
getMessage(messageId: string): {
|
602
|
-
parentId: string | null;
|
603
|
-
message: ThreadMessage;
|
604
|
-
};
|
605
|
-
appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
|
606
|
-
deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
|
607
|
-
getBranches(messageId: string): string[];
|
608
|
-
switchToBranch(messageId: string): void;
|
609
|
-
resetHead(messageId: string | null): void;
|
610
|
-
}
|
611
|
-
|
612
|
-
type TextContentPartState = Readonly<{
|
613
|
-
status: ContentPartStatus;
|
614
|
-
part: TextContentPart;
|
615
|
-
}>;
|
616
|
-
type ContentPartState = Readonly<{
|
617
|
-
status: ContentPartStatus | ToolCallContentPartStatus;
|
618
|
-
part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
|
619
|
-
}>;
|
620
|
-
|
621
|
-
declare const useSmooth: (state: TextContentPartState, smooth?: boolean) => TextContentPartState;
|
622
|
-
|
623
|
-
declare const withSmoothContextProvider: <C extends React.ComponentType<any>>(Component: C) => C;
|
624
|
-
declare const useSmoothStatus: () => {
|
625
|
-
type: "running";
|
626
|
-
} | {
|
627
|
-
type: "complete";
|
628
|
-
} | {
|
629
|
-
type: "incomplete";
|
630
|
-
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
631
|
-
error?: unknown;
|
632
|
-
} | {
|
633
|
-
type: "requires-action";
|
634
|
-
reason: "tool-calls";
|
635
|
-
};
|
636
|
-
|
637
|
-
declare const buttonVariants: (props?: ({
|
638
|
-
variant?: "default" | "outline" | "ghost" | null | undefined;
|
639
|
-
size?: "default" | "icon" | null | undefined;
|
640
|
-
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
641
|
-
type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
|
642
|
-
|
643
|
-
type TooltipIconButtonProps = ButtonProps & {
|
644
|
-
tooltip: string;
|
645
|
-
side?: "top" | "bottom" | "left" | "right";
|
646
|
-
};
|
647
|
-
declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
648
|
-
ref?: ((instance: HTMLButtonElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLButtonElement> | null | undefined;
|
649
|
-
} & {
|
650
|
-
asChild?: boolean;
|
651
|
-
}, "ref"> & class_variance_authority.VariantProps<(props?: ({
|
652
|
-
variant?: "default" | "outline" | "ghost" | null | undefined;
|
653
|
-
size?: "default" | "icon" | null | undefined;
|
654
|
-
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
655
|
-
tooltip: string;
|
656
|
-
side?: "top" | "bottom" | "left" | "right";
|
657
|
-
} & react.RefAttributes<HTMLButtonElement>>;
|
658
|
-
|
659
|
-
declare const generateId: (size?: number) => string;
|
660
|
-
|
661
|
-
type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
|
662
|
-
declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
|
663
|
-
type internal_MessageRepository = MessageRepository;
|
664
|
-
declare const internal_MessageRepository: typeof MessageRepository;
|
665
|
-
type internal_ProxyConfigProvider = ProxyConfigProvider;
|
666
|
-
declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
|
667
|
-
declare const internal_TooltipIconButton: typeof TooltipIconButton;
|
668
|
-
declare const internal_generateId: typeof generateId;
|
669
|
-
declare const internal_useSmooth: typeof useSmooth;
|
670
|
-
declare const internal_useSmoothStatus: typeof useSmoothStatus;
|
671
|
-
declare const internal_withSmoothContextProvider: typeof withSmoothContextProvider;
|
672
|
-
declare namespace internal {
|
673
|
-
export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth, internal_useSmoothStatus as useSmoothStatus, internal_withSmoothContextProvider as withSmoothContextProvider };
|
674
|
-
}
|
675
|
-
|
676
419
|
declare class ExternalStoreThreadRuntime implements ReactThreadRuntime {
|
677
420
|
store: ExternalStoreAdapter<any>;
|
678
421
|
private _subscriptions;
|
@@ -719,42 +462,6 @@ declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefi
|
|
719
462
|
|
720
463
|
type ThreadRuntimeStore = ThreadRuntime;
|
721
464
|
|
722
|
-
type AddToolResultOptions = {
|
723
|
-
messageId: string;
|
724
|
-
toolCallId: string;
|
725
|
-
result: any;
|
726
|
-
};
|
727
|
-
type RuntimeCapabilities = {
|
728
|
-
switchToBranch: boolean;
|
729
|
-
edit: boolean;
|
730
|
-
reload: boolean;
|
731
|
-
cancel: boolean;
|
732
|
-
copy: boolean;
|
733
|
-
};
|
734
|
-
type ThreadActionsState = Readonly<{
|
735
|
-
capabilities: Readonly<RuntimeCapabilities>;
|
736
|
-
getBranches: (messageId: string) => readonly string[];
|
737
|
-
switchToBranch: (branchId: string) => void;
|
738
|
-
append: (message: AppendMessage) => void;
|
739
|
-
startRun: (parentId: string | null) => void;
|
740
|
-
cancelRun: () => void;
|
741
|
-
addToolResult: (options: AddToolResultOptions) => void;
|
742
|
-
}>;
|
743
|
-
|
744
|
-
type ThreadRuntime = Readonly<ThreadState & Omit<ThreadActionsState, "getRuntime"> & {
|
745
|
-
messages: readonly ThreadMessage[];
|
746
|
-
subscribe: (callback: () => void) => Unsubscribe;
|
747
|
-
}>;
|
748
|
-
|
749
|
-
type ThreadRuntimeWithSubscribe = {
|
750
|
-
readonly thread: ThreadRuntime;
|
751
|
-
subscribe: (callback: () => void) => Unsubscribe;
|
752
|
-
};
|
753
|
-
type AssistantRuntime = ThreadRuntimeWithSubscribe & {
|
754
|
-
switchToThread: (threadId: string | null) => void;
|
755
|
-
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
756
|
-
};
|
757
|
-
|
758
465
|
type AssistantRuntimeProviderProps = {
|
759
466
|
runtime: AssistantRuntime;
|
760
467
|
};
|
@@ -789,11 +496,6 @@ declare function useAssistantContext(options: {
|
|
789
496
|
optional: true;
|
790
497
|
}): AssistantContextValue | null;
|
791
498
|
|
792
|
-
type ThreadState = Readonly<{
|
793
|
-
isRunning: boolean;
|
794
|
-
isDisabled: boolean;
|
795
|
-
}>;
|
796
|
-
|
797
499
|
type ThreadViewportState = Readonly<{
|
798
500
|
isAtBottom: boolean;
|
799
501
|
scrollToBottom: () => void;
|
@@ -1512,4 +1214,4 @@ declare const exports: {
|
|
1512
1214
|
Text: FC;
|
1513
1215
|
};
|
1514
1216
|
|
1515
|
-
export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps,
|
1217
|
+
export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, AddToolResultOptions, AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, ContentPartState, CoreMessage, EdgeChatAdapter, type EdgeRuntimeOptions, type EdgeRuntimeRequestOptions, _default$4 as EditComposer, type EditComposerState, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, ReactThreadRuntime, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useEdgeRuntime, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
|