@assistant-ui/react 0.5.88 → 0.5.90
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-CKNRD26B.mjs → chunk-C57XMNDQ.mjs} +10 -2
- package/dist/chunk-C57XMNDQ.mjs.map +1 -0
- package/dist/{chunk-75WIGDCW.js → chunk-MRIZ4RHI.js} +10 -2
- package/dist/chunk-MRIZ4RHI.js.map +1 -0
- package/dist/{edge-B3YIacNl.d.mts → edge-Bycfnl_J.d.mts} +58 -3
- package/dist/{edge-B3YIacNl.d.ts → edge-Bycfnl_J.d.ts} +58 -3
- package/dist/edge.d.mts +56 -1
- package/dist/edge.d.ts +56 -1
- package/dist/edge.js +9 -1
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +9 -1
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +113 -105
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -22
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles/index.css.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-75WIGDCW.js.map +0 -1
- package/dist/chunk-CKNRD26B.mjs.map +0 -1
@@ -322,6 +322,13 @@ var ImageContentPartSchema = z3.object({
|
|
322
322
|
type: z3.literal("image"),
|
323
323
|
image: z3.string()
|
324
324
|
});
|
325
|
+
var Unstable_AudioContentPart = z3.object({
|
326
|
+
type: z3.literal("audio"),
|
327
|
+
audio: z3.object({
|
328
|
+
data: z3.string(),
|
329
|
+
format: z3.union([z3.literal("mp3"), z3.literal("wav")])
|
330
|
+
})
|
331
|
+
});
|
325
332
|
var CoreToolCallContentPartSchema = z3.object({
|
326
333
|
type: z3.literal("tool-call"),
|
327
334
|
toolCallId: z3.string(),
|
@@ -335,7 +342,8 @@ var CoreUserMessageSchema = z3.object({
|
|
335
342
|
content: z3.array(
|
336
343
|
z3.discriminatedUnion("type", [
|
337
344
|
TextContentPartSchema,
|
338
|
-
ImageContentPartSchema
|
345
|
+
ImageContentPartSchema,
|
346
|
+
Unstable_AudioContentPart
|
339
347
|
])
|
340
348
|
).min(1)
|
341
349
|
});
|
@@ -1170,4 +1178,4 @@ export {
|
|
1170
1178
|
getEdgeRuntimeResponse,
|
1171
1179
|
createEdgeRuntimeAPI
|
1172
1180
|
};
|
1173
|
-
//# sourceMappingURL=chunk-
|
1181
|
+
//# sourceMappingURL=chunk-C57XMNDQ.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/runtimes/edge/converters/toLanguageModelMessages.ts","../src/runtimes/edge/converters/toLanguageModelTools.ts","../src/runtimes/edge/converters/toCoreMessages.ts","../src/runtimes/edge/streams/assistantEncoderStream.ts","../src/types/ModelConfigTypes.ts","../src/runtimes/edge/EdgeRuntimeRequestOptions.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/streams/utils/PipeableTransformStream.ts","../src/runtimes/edge/streams/utils/streamPartEncoderStream.ts","../src/runtimes/edge/createEdgeRuntimeAPI.ts"],"sourcesContent":["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\n toolMessage.content.push({\n type: \"tool-result\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n result: part.result ?? \"<no result>\",\n isError: part.isError ?? false,\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\" | \"audio\" = 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 { 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: [\n ...message.content.map((part) => {\n if (part.type === \"ui\")\n throw new Error(\"UI parts are not supported\");\n return part;\n }),\n ...message.attachments.map((a) => a.content).flat(),\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 AssistantStreamChunk,\n AssistantStreamChunkType,\n} from \"./AssistantStreamChunkType\";\nimport { StreamPart } from \"./utils/StreamPart\";\nimport { ToolResultStreamPart } from \"./toolResultStream\";\n\nexport function assistantEncoderStream() {\n const toolCalls = new Set<string>();\n return new TransformStream<\n ToolResultStreamPart,\n StreamPart<AssistantStreamChunk>\n >({\n transform(chunk, controller) {\n const chunkType = chunk.type;\n switch (chunkType) {\n case \"text-delta\": {\n controller.enqueue({\n type: AssistantStreamChunkType.TextDelta,\n value: chunk.textDelta,\n });\n break;\n }\n case \"tool-call-delta\": {\n if (!toolCalls.has(chunk.toolCallId)) {\n toolCalls.add(chunk.toolCallId);\n controller.enqueue({\n type: AssistantStreamChunkType.ToolCallBegin,\n value: {\n toolCallId: chunk.toolCallId,\n toolName: chunk.toolName,\n },\n });\n }\n\n controller.enqueue({\n type: AssistantStreamChunkType.ToolCallDelta,\n value: {\n toolCallId: chunk.toolCallId,\n argsTextDelta: chunk.argsTextDelta,\n },\n });\n break;\n }\n\n // ignore\n case \"tool-call\":\n case \"response-metadata\":\n break;\n\n case \"tool-result\": {\n controller.enqueue({\n type: AssistantStreamChunkType.ToolCallResult,\n value: {\n toolCallId: chunk.toolCallId,\n result: chunk.result,\n },\n });\n break;\n }\n\n case \"step-finish\": {\n const { type, ...rest } = chunk;\n controller.enqueue({\n type: AssistantStreamChunkType.StepFinish,\n value: rest,\n });\n break;\n }\n\n case \"finish\": {\n const { type, ...rest } = chunk;\n controller.enqueue({\n type: AssistantStreamChunkType.Finish,\n value: rest,\n });\n break;\n }\n\n case \"error\": {\n controller.enqueue({\n type: AssistantStreamChunkType.Error,\n value: 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","import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"./Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\nexport type Tool<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n description?: string | undefined;\n parameters: z.ZodSchema<TArgs> | JSONSchema7;\n execute?: ToolExecuteFunction<TArgs, TResult>;\n};\n\nexport type ModelConfig = {\n priority?: number | undefined;\n system?: string | undefined;\n tools?: Record<string, Tool<any, any>> | undefined;\n callSettings?: LanguageModelV1CallSettings | undefined;\n config?: LanguageModelConfig | undefined;\n};\n\nexport type ModelConfigProvider = {\n getModelConfig: () => ModelConfig;\n subscribe?: (callback: () => void) => Unsubscribe;\n};\n\nexport const mergeModelConfigs = (\n configSet: Set<ModelConfigProvider>,\n): ModelConfig => {\n const configs = Array.from(configSet)\n .map((c) => c.getModelConfig())\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n for (const [name, tool] of Object.entries(config.tools)) {\n if (acc.tools?.[name]) {\n throw new Error(\n `You tried to define a tool with the name ${name}, but it already exists.`,\n );\n }\n if (!acc.tools) acc.tools = {};\n acc.tools[name] = tool;\n }\n }\n if (config.config) {\n acc.config = {\n ...acc.config,\n ...config.config,\n };\n }\n if (config.callSettings) {\n acc.callSettings = {\n ...acc.callSettings,\n ...config.callSettings,\n };\n }\n return acc;\n }, {} as ModelConfig);\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 Unstable_AudioContentPart = z.object({\n type: z.literal(\"audio\"),\n audio: z.object({\n data: z.string(),\n format: z.union([z.literal(\"mp3\"), z.literal(\"wav\")]),\n }),\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 Unstable_AudioContentPart,\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 { 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 | {\n type: \"step-finish\";\n finishReason:\n | \"stop\"\n | \"length\"\n | \"content-filter\"\n | \"tool-calls\"\n | \"error\"\n | \"other\"\n | \"unknown\";\n usage: {\n promptTokens: number;\n completionTokens: number;\n };\n isContinued: boolean;\n };\n\nexport function toolResultStream(\n tools: Record<string, Tool> | undefined,\n abortSignal: AbortSignal,\n) {\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 if (!tool.execute) return;\n\n try {\n const result = await tool.execute(args, { abortSignal });\n\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result,\n });\n } catch (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 \"step-finish\":\n case \"finish\":\n case \"error\":\n case \"response-metadata\":\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, ToolCallContentPart } from \"../../../types\";\n\nexport function runResultStream() {\n let message: ChatModelRunResult = {\n content: [],\n status: { type: \"running\" },\n };\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\n case \"tool-call-delta\": {\n const { toolCallId, toolName, argsTextDelta } = chunk;\n\n message = appendOrUpdateToolCall(\n message,\n toolCallId,\n toolName,\n argsTextDelta,\n );\n controller.enqueue(message);\n break;\n }\n\n case \"tool-call\":\n case \"response-metadata\":\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 \"step-finish\": {\n message = appendOrUpdateStepFinish(message, chunk);\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 argsTextDelta: string,\n): ChatModelRunResult => {\n let contentParts = message.content ?? [];\n const contentPartIdx = contentParts.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === toolCallId,\n );\n let contentPart =\n contentPartIdx === -1\n ? null\n : (contentParts[contentPartIdx] as ToolCallContentPart);\n\n if (contentPart == null) {\n contentPart = {\n type: \"tool-call\",\n toolCallId,\n toolName,\n argsText: argsTextDelta,\n args: parsePartialJson(argsTextDelta),\n };\n contentParts = [...contentParts, contentPart];\n } else {\n const argsText = contentPart.argsText + argsTextDelta;\n contentPart = {\n ...contentPart,\n argsText,\n args: parsePartialJson(argsText),\n };\n contentParts = [\n ...contentParts.slice(0, contentPartIdx),\n contentPart,\n ...contentParts.slice(contentPartIdx + 1),\n ];\n }\n\n return {\n ...message,\n content: contentParts,\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 appendOrUpdateStepFinish = (\n message: ChatModelRunResult,\n chunk: ToolResultStreamPart & { type: \"step-finish\" },\n): ChatModelRunResult => {\n const { type, ...rest } = chunk;\n const steps = [\n ...(message.metadata?.steps ?? []),\n {\n usage: rest.usage,\n },\n ];\n return {\n ...message,\n metadata: {\n ...message.metadata,\n roundtrips: steps,\n steps,\n },\n };\n};\n\nconst appendOrUpdateFinish = (\n message: ChatModelRunResult,\n chunk: LanguageModelV1StreamPart & { type: \"finish\" },\n): ChatModelRunResult => {\n const { type, ...rest } = chunk;\n\n const steps = [\n ...(message.metadata?.steps ?? []),\n {\n logprobs: rest.logprobs,\n usage: rest.usage,\n },\n ];\n return {\n ...message,\n status: getStatus(chunk),\n metadata: {\n ...message.metadata,\n roundtrips: steps,\n steps,\n },\n };\n};\n\nconst getStatus = (\n chunk:\n | (LanguageModelV1StreamPart & { type: \"finish\" })\n | (ToolResultStreamPart & { type: \"step-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","export class PipeableTransformStream<I, O> extends TransformStream<I, O> {\n constructor(transform: (readable: ReadableStream<I>) => ReadableStream<O>) {\n super();\n const readable = transform(super.readable as any);\n Object.defineProperty(this, \"readable\", {\n value: readable,\n writable: false,\n });\n }\n}\n","import { PipeableTransformStream } from \"./PipeableTransformStream\";\nimport { StreamPart } from \"./StreamPart\";\n\nfunction encodeStreamPart<T extends Record<string, unknown>>({\n type,\n value,\n}: StreamPart<T>): string {\n return `${type as string}:${JSON.stringify(value)}\\n`;\n}\n\nexport function streamPartEncoderStream<T extends Record<string, unknown>>() {\n const encodeStream = new TransformStream<StreamPart<T>, string>({\n transform(chunk, controller) {\n controller.enqueue(encodeStreamPart<T>(chunk));\n },\n });\n\n return new PipeableTransformStream((readable) => {\n return readable\n .pipeThrough(encodeStream)\n .pipeThrough(new TextEncoderStream());\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 ThreadStep,\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\";\nimport { streamPartEncoderStream } from \"./streams/utils/streamPartEncoderStream\";\nimport { z } from \"zod\";\n\ntype FinishResult = {\n messages: CoreMessage[];\n metadata: {\n /**\n * @deprecated Use `steps` instead. This field will be removed in v0.6.\n */\n roundtrips: ThreadStep[];\n steps: ThreadStep[];\n };\n};\n\ntype LanguageModelCreator = (\n config: LanguageModelConfig,\n) => Promise<LanguageModelV1> | LanguageModelV1;\n\nexport type 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\ntype GetEdgeRuntimeStreamOptions = {\n abortSignal: AbortSignal;\n requestData: z.infer<typeof EdgeRuntimeRequestOptionsSchema>;\n options: CreateEdgeRuntimeAPIOptions;\n};\n\nexport const getEdgeRuntimeStream = async ({\n abortSignal,\n requestData: unsafeRequest,\n options: {\n model: modelOrCreator,\n system: serverSystem,\n tools: serverTools = {},\n toolChoice,\n onFinish,\n ...unsafeSettings\n },\n}: GetEdgeRuntimeStreamOptions) => {\n const settings = LanguageModelV1CallSettingsSchema.parse(unsafeSettings);\n const lmServerTools = toLanguageModelTools(serverTools);\n const hasServerTools = Object.values(serverTools).some((v) => !!v.execute);\n\n const {\n system: clientSystem,\n tools: clientTools = [],\n messages,\n apiKey,\n baseUrl,\n modelName,\n ...callSettings\n } = EdgeRuntimeRequestOptionsSchema.parse(unsafeRequest);\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 const model =\n typeof modelOrCreator === \"function\"\n ? await modelOrCreator({ apiKey, baseUrl, modelName })\n : modelOrCreator;\n\n let stream: ReadableStream<ToolResultStreamPart>;\n const streamResult = await streamMessage({\n ...(settings as Partial<StreamMessageOptions>),\n ...callSettings,\n\n model,\n abortSignal,\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, abortSignal));\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 metadata: {\n // TODO\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n roundtrips: lastChunk.metadata?.steps!,\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n steps: lastChunk.metadata?.steps!,\n },\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 stream;\n};\n\nexport declare namespace getEdgeRuntimeResponse {\n export type { GetEdgeRuntimeStreamOptions as Options };\n}\n\nexport const getEdgeRuntimeResponse = async (\n options: getEdgeRuntimeResponse.Options,\n) => {\n const stream = await getEdgeRuntimeStream(options);\n return new Response(\n stream\n .pipeThrough(assistantEncoderStream())\n .pipeThrough(streamPartEncoderStream()),\n {\n headers: {\n \"Content-Type\": \"text/plain; charset=utf-8\",\n },\n },\n );\n};\n\nexport const createEdgeRuntimeAPI = (options: CreateEdgeRuntimeAPIOptions) => ({\n POST: async (request: Request) =>\n getEdgeRuntimeResponse({\n abortSignal: request.signal,\n requestData: await request.json(),\n options,\n }),\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":";;;AAcA,IAAM,2BAA2B,MAAM;AACrC,QAAM,QAAkC,CAAC;AACzC,MAAI,mBAAmB;AAAA,IACrB,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,EACZ;AACA,MAAI,cAAc;AAAA,IAChB,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,EACZ;AAEA,SAAO;AAAA,IACL,oBAAoB,CAAC,SAA0B;AAC7C,UAAI,YAAY,QAAQ,SAAS,GAAG;AAClC,cAAM,KAAK,gBAAgB;AAC3B,cAAM,KAAK,WAAW;AAEtB,2BAAmB;AAAA,UACjB,MAAM;AAAA,UACN,SAAS,CAAC;AAAA,QAIZ;AAEA,sBAAc;AAAA,UACZ,MAAM;AAAA,UACN,SAAS,CAAC;AAAA,QACZ;AAAA,MACF;AAEA,uBAAiB,QAAQ,KAAK,IAAI;AAAA,IACpC;AAAA,IACA,iBAAiB,CAAC,SAAkC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ACuB;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":["message","z","z","z","result","sjson","sjson"]}
|
@@ -320,6 +320,13 @@ var ImageContentPartSchema = _zod.z.object({
|
|
320
320
|
type: _zod.z.literal("image"),
|
321
321
|
image: _zod.z.string()
|
322
322
|
});
|
323
|
+
var Unstable_AudioContentPart = _zod.z.object({
|
324
|
+
type: _zod.z.literal("audio"),
|
325
|
+
audio: _zod.z.object({
|
326
|
+
data: _zod.z.string(),
|
327
|
+
format: _zod.z.union([_zod.z.literal("mp3"), _zod.z.literal("wav")])
|
328
|
+
})
|
329
|
+
});
|
323
330
|
var CoreToolCallContentPartSchema = _zod.z.object({
|
324
331
|
type: _zod.z.literal("tool-call"),
|
325
332
|
toolCallId: _zod.z.string(),
|
@@ -333,7 +340,8 @@ var CoreUserMessageSchema = _zod.z.object({
|
|
333
340
|
content: _zod.z.array(
|
334
341
|
_zod.z.discriminatedUnion("type", [
|
335
342
|
TextContentPartSchema,
|
336
|
-
ImageContentPartSchema
|
343
|
+
ImageContentPartSchema,
|
344
|
+
Unstable_AudioContentPart
|
337
345
|
])
|
338
346
|
).min(1)
|
339
347
|
});
|
@@ -1168,4 +1176,4 @@ function convertToLanguageModelPrompt(system, messages) {
|
|
1168
1176
|
|
1169
1177
|
|
1170
1178
|
exports.mergeModelConfigs = mergeModelConfigs; exports.toLanguageModelMessages = toLanguageModelMessages; exports.toLanguageModelTools = toLanguageModelTools; exports.toolResultStream = toolResultStream; exports.runResultStream = runResultStream; exports.toCoreMessages = toCoreMessages; exports.toCoreMessage = toCoreMessage; exports.PipeableTransformStream = PipeableTransformStream; exports.streamPartEncoderStream = streamPartEncoderStream; exports.getEdgeRuntimeStream = getEdgeRuntimeStream; exports.getEdgeRuntimeResponse = getEdgeRuntimeResponse; exports.createEdgeRuntimeAPI = createEdgeRuntimeAPI;
|
1171
|
-
//# sourceMappingURL=chunk-
|
1179
|
+
//# sourceMappingURL=chunk-MRIZ4RHI.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/assistant-ui/assistant-ui/packages/react/dist/chunk-MRIZ4RHI.js","../src/runtimes/edge/converters/toLanguageModelMessages.ts","../src/runtimes/edge/converters/toLanguageModelTools.ts","../src/runtimes/edge/converters/toCoreMessages.ts","../src/runtimes/edge/streams/assistantEncoderStream.ts","../src/types/ModelConfigTypes.ts","../src/runtimes/edge/EdgeRuntimeRequestOptions.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/streams/utils/PipeableTransformStream.ts","../src/runtimes/edge/streams/utils/streamPartEncoderStream.ts","../src/runtimes/edge/createEdgeRuntimeAPI.ts"],"names":["message"],"mappings":"AAAA;ACcA,IAAM,yBAAA,EAA2B,CAAA,EAAA,GAAM;AACrC,EAAA,MAAM,MAAA,EAAkC,CAAC,CAAA;AACzC,EAAA,IAAI,iBAAA,EAAmB;AAAA,IACrB,IAAA,EAAM,WAAA;AAAA,IACN,OAAA,EAAS,CAAC;AAAA,EACZ,CAAA;AACA,EAAA,IAAI,YAAA,EAAc;AAAA,IAChB,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS,CAAC;AAAA,EACZ,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,CAAC,IAAA,EAAA,GAA0B;AAC7C,MAAA,GAAA,CAAI,WAAA,CAAY,OAAA,CAAQ,OAAA,EAAS,CAAA,EAAG;AAClC,QAAA,KAAA,CAAM,IAAA,CAAK,gBAAgB,CAAA;AAC3B,QAAA,KAAA,CAAM,IAAA,CAAK,WAAW,CAAA;AAEtB,QAAA,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EpB,YAAA;AAAS,cAAA;AACG,cAAA;AACA;AAAA;AAAA,gBAAA;AAGwB;AAAA,gBAAA;AAEL,cAAA;AAC7B,YAAA;AACD,UAAA;AACH,QAAA;AACD,MAAA;AACH,IAAA;AAIF,IAAA;AACE,MAAA;AAAkD,IAAA;AACnD,EAAA;AAGH,EAAA;AACF;AAMO;AAGL,EAAA;AACA,EAAA;AAAW,IAAA;AAG+B,IAAA;AACxC,MAAA;AACW,QAAA;AACS,MAAA;AAClB,IAAA;AACF,EAAA;AAEJ;AAEO;AAAwE,EAAA;AAEpD,IAAA;AACA,IAAA;AACW,IAAA;AAChC,EAAA;AAEN;AAWA;AAA6B,EAAA;AAC3B,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAEF;AACE,EAAA;AAAsB,IAAA;AACP,IAAA;AACP,MAAA;AACE,MAAA;AACkB,MAAA;AACU,IAAA;AACpC,IAAA;AACqD,IAAA;AACjD,EAAA;AAER;AAEO;AAIL,EAAA;AAEA,EAAA;AACE,IAAA;AAA8D,EAAA;AAEhE,EAAA;AAEA,EAAA;AACF;Ab+4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/assistant-ui/assistant-ui/packages/react/dist/chunk-MRIZ4RHI.js","sourcesContent":[null,"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\n toolMessage.content.push({\n type: \"tool-result\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n result: part.result ?? \"<no result>\",\n isError: part.isError ?? false,\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\" | \"audio\" = 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 { 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: [\n ...message.content.map((part) => {\n if (part.type === \"ui\")\n throw new Error(\"UI parts are not supported\");\n return part;\n }),\n ...message.attachments.map((a) => a.content).flat(),\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 AssistantStreamChunk,\n AssistantStreamChunkType,\n} from \"./AssistantStreamChunkType\";\nimport { StreamPart } from \"./utils/StreamPart\";\nimport { ToolResultStreamPart } from \"./toolResultStream\";\n\nexport function assistantEncoderStream() {\n const toolCalls = new Set<string>();\n return new TransformStream<\n ToolResultStreamPart,\n StreamPart<AssistantStreamChunk>\n >({\n transform(chunk, controller) {\n const chunkType = chunk.type;\n switch (chunkType) {\n case \"text-delta\": {\n controller.enqueue({\n type: AssistantStreamChunkType.TextDelta,\n value: chunk.textDelta,\n });\n break;\n }\n case \"tool-call-delta\": {\n if (!toolCalls.has(chunk.toolCallId)) {\n toolCalls.add(chunk.toolCallId);\n controller.enqueue({\n type: AssistantStreamChunkType.ToolCallBegin,\n value: {\n toolCallId: chunk.toolCallId,\n toolName: chunk.toolName,\n },\n });\n }\n\n controller.enqueue({\n type: AssistantStreamChunkType.ToolCallDelta,\n value: {\n toolCallId: chunk.toolCallId,\n argsTextDelta: chunk.argsTextDelta,\n },\n });\n break;\n }\n\n // ignore\n case \"tool-call\":\n case \"response-metadata\":\n break;\n\n case \"tool-result\": {\n controller.enqueue({\n type: AssistantStreamChunkType.ToolCallResult,\n value: {\n toolCallId: chunk.toolCallId,\n result: chunk.result,\n },\n });\n break;\n }\n\n case \"step-finish\": {\n const { type, ...rest } = chunk;\n controller.enqueue({\n type: AssistantStreamChunkType.StepFinish,\n value: rest,\n });\n break;\n }\n\n case \"finish\": {\n const { type, ...rest } = chunk;\n controller.enqueue({\n type: AssistantStreamChunkType.Finish,\n value: rest,\n });\n break;\n }\n\n case \"error\": {\n controller.enqueue({\n type: AssistantStreamChunkType.Error,\n value: 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","import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"./Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\nexport type Tool<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n description?: string | undefined;\n parameters: z.ZodSchema<TArgs> | JSONSchema7;\n execute?: ToolExecuteFunction<TArgs, TResult>;\n};\n\nexport type ModelConfig = {\n priority?: number | undefined;\n system?: string | undefined;\n tools?: Record<string, Tool<any, any>> | undefined;\n callSettings?: LanguageModelV1CallSettings | undefined;\n config?: LanguageModelConfig | undefined;\n};\n\nexport type ModelConfigProvider = {\n getModelConfig: () => ModelConfig;\n subscribe?: (callback: () => void) => Unsubscribe;\n};\n\nexport const mergeModelConfigs = (\n configSet: Set<ModelConfigProvider>,\n): ModelConfig => {\n const configs = Array.from(configSet)\n .map((c) => c.getModelConfig())\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n for (const [name, tool] of Object.entries(config.tools)) {\n if (acc.tools?.[name]) {\n throw new Error(\n `You tried to define a tool with the name ${name}, but it already exists.`,\n );\n }\n if (!acc.tools) acc.tools = {};\n acc.tools[name] = tool;\n }\n }\n if (config.config) {\n acc.config = {\n ...acc.config,\n ...config.config,\n };\n }\n if (config.callSettings) {\n acc.callSettings = {\n ...acc.callSettings,\n ...config.callSettings,\n };\n }\n return acc;\n }, {} as ModelConfig);\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 Unstable_AudioContentPart = z.object({\n type: z.literal(\"audio\"),\n audio: z.object({\n data: z.string(),\n format: z.union([z.literal(\"mp3\"), z.literal(\"wav\")]),\n }),\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 Unstable_AudioContentPart,\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 { 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 | {\n type: \"step-finish\";\n finishReason:\n | \"stop\"\n | \"length\"\n | \"content-filter\"\n | \"tool-calls\"\n | \"error\"\n | \"other\"\n | \"unknown\";\n usage: {\n promptTokens: number;\n completionTokens: number;\n };\n isContinued: boolean;\n };\n\nexport function toolResultStream(\n tools: Record<string, Tool> | undefined,\n abortSignal: AbortSignal,\n) {\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 if (!tool.execute) return;\n\n try {\n const result = await tool.execute(args, { abortSignal });\n\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result,\n });\n } catch (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 \"step-finish\":\n case \"finish\":\n case \"error\":\n case \"response-metadata\":\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, ToolCallContentPart } from \"../../../types\";\n\nexport function runResultStream() {\n let message: ChatModelRunResult = {\n content: [],\n status: { type: \"running\" },\n };\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\n case \"tool-call-delta\": {\n const { toolCallId, toolName, argsTextDelta } = chunk;\n\n message = appendOrUpdateToolCall(\n message,\n toolCallId,\n toolName,\n argsTextDelta,\n );\n controller.enqueue(message);\n break;\n }\n\n case \"tool-call\":\n case \"response-metadata\":\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 \"step-finish\": {\n message = appendOrUpdateStepFinish(message, chunk);\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 argsTextDelta: string,\n): ChatModelRunResult => {\n let contentParts = message.content ?? [];\n const contentPartIdx = contentParts.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === toolCallId,\n );\n let contentPart =\n contentPartIdx === -1\n ? null\n : (contentParts[contentPartIdx] as ToolCallContentPart);\n\n if (contentPart == null) {\n contentPart = {\n type: \"tool-call\",\n toolCallId,\n toolName,\n argsText: argsTextDelta,\n args: parsePartialJson(argsTextDelta),\n };\n contentParts = [...contentParts, contentPart];\n } else {\n const argsText = contentPart.argsText + argsTextDelta;\n contentPart = {\n ...contentPart,\n argsText,\n args: parsePartialJson(argsText),\n };\n contentParts = [\n ...contentParts.slice(0, contentPartIdx),\n contentPart,\n ...contentParts.slice(contentPartIdx + 1),\n ];\n }\n\n return {\n ...message,\n content: contentParts,\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 appendOrUpdateStepFinish = (\n message: ChatModelRunResult,\n chunk: ToolResultStreamPart & { type: \"step-finish\" },\n): ChatModelRunResult => {\n const { type, ...rest } = chunk;\n const steps = [\n ...(message.metadata?.steps ?? []),\n {\n usage: rest.usage,\n },\n ];\n return {\n ...message,\n metadata: {\n ...message.metadata,\n roundtrips: steps,\n steps,\n },\n };\n};\n\nconst appendOrUpdateFinish = (\n message: ChatModelRunResult,\n chunk: LanguageModelV1StreamPart & { type: \"finish\" },\n): ChatModelRunResult => {\n const { type, ...rest } = chunk;\n\n const steps = [\n ...(message.metadata?.steps ?? []),\n {\n logprobs: rest.logprobs,\n usage: rest.usage,\n },\n ];\n return {\n ...message,\n status: getStatus(chunk),\n metadata: {\n ...message.metadata,\n roundtrips: steps,\n steps,\n },\n };\n};\n\nconst getStatus = (\n chunk:\n | (LanguageModelV1StreamPart & { type: \"finish\" })\n | (ToolResultStreamPart & { type: \"step-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","export class PipeableTransformStream<I, O> extends TransformStream<I, O> {\n constructor(transform: (readable: ReadableStream<I>) => ReadableStream<O>) {\n super();\n const readable = transform(super.readable as any);\n Object.defineProperty(this, \"readable\", {\n value: readable,\n writable: false,\n });\n }\n}\n","import { PipeableTransformStream } from \"./PipeableTransformStream\";\nimport { StreamPart } from \"./StreamPart\";\n\nfunction encodeStreamPart<T extends Record<string, unknown>>({\n type,\n value,\n}: StreamPart<T>): string {\n return `${type as string}:${JSON.stringify(value)}\\n`;\n}\n\nexport function streamPartEncoderStream<T extends Record<string, unknown>>() {\n const encodeStream = new TransformStream<StreamPart<T>, string>({\n transform(chunk, controller) {\n controller.enqueue(encodeStreamPart<T>(chunk));\n },\n });\n\n return new PipeableTransformStream((readable) => {\n return readable\n .pipeThrough(encodeStream)\n .pipeThrough(new TextEncoderStream());\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 ThreadStep,\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\";\nimport { streamPartEncoderStream } from \"./streams/utils/streamPartEncoderStream\";\nimport { z } from \"zod\";\n\ntype FinishResult = {\n messages: CoreMessage[];\n metadata: {\n /**\n * @deprecated Use `steps` instead. This field will be removed in v0.6.\n */\n roundtrips: ThreadStep[];\n steps: ThreadStep[];\n };\n};\n\ntype LanguageModelCreator = (\n config: LanguageModelConfig,\n) => Promise<LanguageModelV1> | LanguageModelV1;\n\nexport type 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\ntype GetEdgeRuntimeStreamOptions = {\n abortSignal: AbortSignal;\n requestData: z.infer<typeof EdgeRuntimeRequestOptionsSchema>;\n options: CreateEdgeRuntimeAPIOptions;\n};\n\nexport const getEdgeRuntimeStream = async ({\n abortSignal,\n requestData: unsafeRequest,\n options: {\n model: modelOrCreator,\n system: serverSystem,\n tools: serverTools = {},\n toolChoice,\n onFinish,\n ...unsafeSettings\n },\n}: GetEdgeRuntimeStreamOptions) => {\n const settings = LanguageModelV1CallSettingsSchema.parse(unsafeSettings);\n const lmServerTools = toLanguageModelTools(serverTools);\n const hasServerTools = Object.values(serverTools).some((v) => !!v.execute);\n\n const {\n system: clientSystem,\n tools: clientTools = [],\n messages,\n apiKey,\n baseUrl,\n modelName,\n ...callSettings\n } = EdgeRuntimeRequestOptionsSchema.parse(unsafeRequest);\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 const model =\n typeof modelOrCreator === \"function\"\n ? await modelOrCreator({ apiKey, baseUrl, modelName })\n : modelOrCreator;\n\n let stream: ReadableStream<ToolResultStreamPart>;\n const streamResult = await streamMessage({\n ...(settings as Partial<StreamMessageOptions>),\n ...callSettings,\n\n model,\n abortSignal,\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, abortSignal));\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 metadata: {\n // TODO\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n roundtrips: lastChunk.metadata?.steps!,\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n steps: lastChunk.metadata?.steps!,\n },\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 stream;\n};\n\nexport declare namespace getEdgeRuntimeResponse {\n export type { GetEdgeRuntimeStreamOptions as Options };\n}\n\nexport const getEdgeRuntimeResponse = async (\n options: getEdgeRuntimeResponse.Options,\n) => {\n const stream = await getEdgeRuntimeStream(options);\n return new Response(\n stream\n .pipeThrough(assistantEncoderStream())\n .pipeThrough(streamPartEncoderStream()),\n {\n headers: {\n \"Content-Type\": \"text/plain; charset=utf-8\",\n },\n },\n );\n};\n\nexport const createEdgeRuntimeAPI = (options: CreateEdgeRuntimeAPIOptions) => ({\n POST: async (request: Request) =>\n getEdgeRuntimeResponse({\n abortSignal: request.signal,\n requestData: await request.json(),\n options,\n }),\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"]}
|
@@ -44,6 +44,13 @@ type ImageContentPart = {
|
|
44
44
|
type: "image";
|
45
45
|
image: string;
|
46
46
|
};
|
47
|
+
type Unstable_AudioContentPart = {
|
48
|
+
type: "audio";
|
49
|
+
audio: {
|
50
|
+
data: string;
|
51
|
+
format: "mp3" | "wav";
|
52
|
+
};
|
53
|
+
};
|
47
54
|
type UIContentPart = {
|
48
55
|
type: "ui";
|
49
56
|
display: ReactNode;
|
@@ -59,7 +66,7 @@ type CoreToolCallContentPart<TArgs extends Record<string, unknown> = Record<stri
|
|
59
66
|
type ToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
|
60
67
|
argsText: string;
|
61
68
|
};
|
62
|
-
type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
69
|
+
type ThreadUserContentPart = TextContentPart | ImageContentPart | Unstable_AudioContentPart | UIContentPart;
|
63
70
|
type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
64
71
|
type MessageCommonProps = {
|
65
72
|
id: string;
|
@@ -138,7 +145,7 @@ type BaseThreadMessage = {
|
|
138
145
|
};
|
139
146
|
type ThreadMessage = BaseThreadMessage & (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);
|
140
147
|
/** Core Message Types (without UI content parts) */
|
141
|
-
type CoreUserContentPart = TextContentPart | ImageContentPart;
|
148
|
+
type CoreUserContentPart = TextContentPart | ImageContentPart | Unstable_AudioContentPart;
|
142
149
|
type CoreAssistantContentPart = TextContentPart | CoreToolCallContentPart;
|
143
150
|
type CoreSystemMessage = {
|
144
151
|
role: "system";
|
@@ -200,6 +207,30 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
200
207
|
}, {
|
201
208
|
image: string;
|
202
209
|
type: "image";
|
210
|
+
}>, z.ZodObject<{
|
211
|
+
type: z.ZodLiteral<"audio">;
|
212
|
+
audio: z.ZodObject<{
|
213
|
+
data: z.ZodString;
|
214
|
+
format: z.ZodUnion<[z.ZodLiteral<"mp3">, z.ZodLiteral<"wav">]>;
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
216
|
+
data: string;
|
217
|
+
format: "mp3" | "wav";
|
218
|
+
}, {
|
219
|
+
data: string;
|
220
|
+
format: "mp3" | "wav";
|
221
|
+
}>;
|
222
|
+
}, "strip", z.ZodTypeAny, {
|
223
|
+
audio: {
|
224
|
+
data: string;
|
225
|
+
format: "mp3" | "wav";
|
226
|
+
};
|
227
|
+
type: "audio";
|
228
|
+
}, {
|
229
|
+
audio: {
|
230
|
+
data: string;
|
231
|
+
format: "mp3" | "wav";
|
232
|
+
};
|
233
|
+
type: "audio";
|
203
234
|
}>]>, "many">;
|
204
235
|
}, "strip", z.ZodTypeAny, {
|
205
236
|
role: "user";
|
@@ -209,6 +240,12 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
209
240
|
} | {
|
210
241
|
image: string;
|
211
242
|
type: "image";
|
243
|
+
} | {
|
244
|
+
audio: {
|
245
|
+
data: string;
|
246
|
+
format: "mp3" | "wav";
|
247
|
+
};
|
248
|
+
type: "audio";
|
212
249
|
})[];
|
213
250
|
}, {
|
214
251
|
role: "user";
|
@@ -218,6 +255,12 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
218
255
|
} | {
|
219
256
|
image: string;
|
220
257
|
type: "image";
|
258
|
+
} | {
|
259
|
+
audio: {
|
260
|
+
data: string;
|
261
|
+
format: "mp3" | "wav";
|
262
|
+
};
|
263
|
+
type: "audio";
|
221
264
|
})[];
|
222
265
|
}>, z.ZodObject<{
|
223
266
|
role: z.ZodLiteral<"assistant">;
|
@@ -316,6 +359,12 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
316
359
|
} | {
|
317
360
|
image: string;
|
318
361
|
type: "image";
|
362
|
+
} | {
|
363
|
+
audio: {
|
364
|
+
data: string;
|
365
|
+
format: "mp3" | "wav";
|
366
|
+
};
|
367
|
+
type: "audio";
|
319
368
|
})[];
|
320
369
|
} | {
|
321
370
|
role: "assistant";
|
@@ -363,6 +412,12 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
363
412
|
} | {
|
364
413
|
image: string;
|
365
414
|
type: "image";
|
415
|
+
} | {
|
416
|
+
audio: {
|
417
|
+
data: string;
|
418
|
+
format: "mp3" | "wav";
|
419
|
+
};
|
420
|
+
type: "audio";
|
366
421
|
})[];
|
367
422
|
} | {
|
368
423
|
role: "assistant";
|
@@ -497,4 +552,4 @@ declare const createEdgeRuntimeAPI: (options: CreateEdgeRuntimeAPIOptions) => {
|
|
497
552
|
POST: (request: Request) => Promise<Response>;
|
498
553
|
};
|
499
554
|
|
500
|
-
export { type Attachment as A,
|
555
|
+
export { type Attachment as A, type CoreAssistantMessage as B, type CoreMessage as C, createEdgeRuntimeAPI as D, type EdgeRuntimeRequestOptions as E, getEdgeRuntimeResponse as F, type ImageContentPart as I, type ModelConfig as M, type PendingAttachment as P, type ThreadMessage as T, type Unsubscribe as U, type AppendMessage as a, type ModelConfigProvider as b, type ThreadAssistantContentPart as c, type MessageStatus as d, type ThreadStep as e, type PendingAttachmentStatus as f, type CompleteAttachment as g, type CompleteAttachmentStatus as h, type TextContentPart as i, type Tool as j, type Unstable_AudioContentPart as k, type ToolCallContentPart as l, type CoreToolCallContentPart as m, type UIContentPart as n, type CreateEdgeRuntimeAPIOptions as o, type ThreadUserContentPart as p, type ContentPartStatus as q, type ToolCallContentPartStatus as r, type AttachmentStatus as s, type ThreadSystemMessage as t, type ThreadAssistantMessage as u, type ThreadUserMessage as v, type CoreUserContentPart as w, type CoreAssistantContentPart as x, type CoreSystemMessage as y, type CoreUserMessage as z };
|
@@ -44,6 +44,13 @@ type ImageContentPart = {
|
|
44
44
|
type: "image";
|
45
45
|
image: string;
|
46
46
|
};
|
47
|
+
type Unstable_AudioContentPart = {
|
48
|
+
type: "audio";
|
49
|
+
audio: {
|
50
|
+
data: string;
|
51
|
+
format: "mp3" | "wav";
|
52
|
+
};
|
53
|
+
};
|
47
54
|
type UIContentPart = {
|
48
55
|
type: "ui";
|
49
56
|
display: ReactNode;
|
@@ -59,7 +66,7 @@ type CoreToolCallContentPart<TArgs extends Record<string, unknown> = Record<stri
|
|
59
66
|
type ToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
|
60
67
|
argsText: string;
|
61
68
|
};
|
62
|
-
type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
69
|
+
type ThreadUserContentPart = TextContentPart | ImageContentPart | Unstable_AudioContentPart | UIContentPart;
|
63
70
|
type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
64
71
|
type MessageCommonProps = {
|
65
72
|
id: string;
|
@@ -138,7 +145,7 @@ type BaseThreadMessage = {
|
|
138
145
|
};
|
139
146
|
type ThreadMessage = BaseThreadMessage & (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);
|
140
147
|
/** Core Message Types (without UI content parts) */
|
141
|
-
type CoreUserContentPart = TextContentPart | ImageContentPart;
|
148
|
+
type CoreUserContentPart = TextContentPart | ImageContentPart | Unstable_AudioContentPart;
|
142
149
|
type CoreAssistantContentPart = TextContentPart | CoreToolCallContentPart;
|
143
150
|
type CoreSystemMessage = {
|
144
151
|
role: "system";
|
@@ -200,6 +207,30 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
200
207
|
}, {
|
201
208
|
image: string;
|
202
209
|
type: "image";
|
210
|
+
}>, z.ZodObject<{
|
211
|
+
type: z.ZodLiteral<"audio">;
|
212
|
+
audio: z.ZodObject<{
|
213
|
+
data: z.ZodString;
|
214
|
+
format: z.ZodUnion<[z.ZodLiteral<"mp3">, z.ZodLiteral<"wav">]>;
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
216
|
+
data: string;
|
217
|
+
format: "mp3" | "wav";
|
218
|
+
}, {
|
219
|
+
data: string;
|
220
|
+
format: "mp3" | "wav";
|
221
|
+
}>;
|
222
|
+
}, "strip", z.ZodTypeAny, {
|
223
|
+
audio: {
|
224
|
+
data: string;
|
225
|
+
format: "mp3" | "wav";
|
226
|
+
};
|
227
|
+
type: "audio";
|
228
|
+
}, {
|
229
|
+
audio: {
|
230
|
+
data: string;
|
231
|
+
format: "mp3" | "wav";
|
232
|
+
};
|
233
|
+
type: "audio";
|
203
234
|
}>]>, "many">;
|
204
235
|
}, "strip", z.ZodTypeAny, {
|
205
236
|
role: "user";
|
@@ -209,6 +240,12 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
209
240
|
} | {
|
210
241
|
image: string;
|
211
242
|
type: "image";
|
243
|
+
} | {
|
244
|
+
audio: {
|
245
|
+
data: string;
|
246
|
+
format: "mp3" | "wav";
|
247
|
+
};
|
248
|
+
type: "audio";
|
212
249
|
})[];
|
213
250
|
}, {
|
214
251
|
role: "user";
|
@@ -218,6 +255,12 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
218
255
|
} | {
|
219
256
|
image: string;
|
220
257
|
type: "image";
|
258
|
+
} | {
|
259
|
+
audio: {
|
260
|
+
data: string;
|
261
|
+
format: "mp3" | "wav";
|
262
|
+
};
|
263
|
+
type: "audio";
|
221
264
|
})[];
|
222
265
|
}>, z.ZodObject<{
|
223
266
|
role: z.ZodLiteral<"assistant">;
|
@@ -316,6 +359,12 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
316
359
|
} | {
|
317
360
|
image: string;
|
318
361
|
type: "image";
|
362
|
+
} | {
|
363
|
+
audio: {
|
364
|
+
data: string;
|
365
|
+
format: "mp3" | "wav";
|
366
|
+
};
|
367
|
+
type: "audio";
|
319
368
|
})[];
|
320
369
|
} | {
|
321
370
|
role: "assistant";
|
@@ -363,6 +412,12 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
363
412
|
} | {
|
364
413
|
image: string;
|
365
414
|
type: "image";
|
415
|
+
} | {
|
416
|
+
audio: {
|
417
|
+
data: string;
|
418
|
+
format: "mp3" | "wav";
|
419
|
+
};
|
420
|
+
type: "audio";
|
366
421
|
})[];
|
367
422
|
} | {
|
368
423
|
role: "assistant";
|
@@ -497,4 +552,4 @@ declare const createEdgeRuntimeAPI: (options: CreateEdgeRuntimeAPIOptions) => {
|
|
497
552
|
POST: (request: Request) => Promise<Response>;
|
498
553
|
};
|
499
554
|
|
500
|
-
export { type Attachment as A,
|
555
|
+
export { type Attachment as A, type CoreAssistantMessage as B, type CoreMessage as C, createEdgeRuntimeAPI as D, type EdgeRuntimeRequestOptions as E, getEdgeRuntimeResponse as F, type ImageContentPart as I, type ModelConfig as M, type PendingAttachment as P, type ThreadMessage as T, type Unsubscribe as U, type AppendMessage as a, type ModelConfigProvider as b, type ThreadAssistantContentPart as c, type MessageStatus as d, type ThreadStep as e, type PendingAttachmentStatus as f, type CompleteAttachment as g, type CompleteAttachmentStatus as h, type TextContentPart as i, type Tool as j, type Unstable_AudioContentPart as k, type ToolCallContentPart as l, type CoreToolCallContentPart as m, type UIContentPart as n, type CreateEdgeRuntimeAPIOptions as o, type ThreadUserContentPart as p, type ContentPartStatus as q, type ToolCallContentPartStatus as r, type AttachmentStatus as s, type ThreadSystemMessage as t, type ThreadAssistantMessage as u, type ThreadUserMessage as v, type CoreUserContentPart as w, type CoreAssistantContentPart as x, type CoreSystemMessage as y, type CoreUserMessage as z };
|