@assistant-ui/react 0.5.35 → 0.5.36
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-LX7F2T2K.mjs → chunk-5ZTUOAPH.mjs} +374 -102
- package/dist/chunk-5ZTUOAPH.mjs.map +1 -0
- package/dist/{chunk-JKRONBQK.js → chunk-BQ3MRWUV.js} +377 -105
- package/dist/chunk-BQ3MRWUV.js.map +1 -0
- package/dist/{EdgeRuntimeRequestOptions-BP7q0lyh.d.mts → edge-6dYzFCV5.d.mts} +31 -4
- package/dist/{EdgeRuntimeRequestOptions-BP7q0lyh.d.ts → edge-6dYzFCV5.d.ts} +31 -4
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +46 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -11
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +1 -0
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-JKRONBQK.js.map +0 -1
- package/dist/chunk-LX7F2T2K.mjs.map +0 -1
package/dist/index.mjs
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import {
|
3
3
|
PipeableTransformStream,
|
4
|
+
getEdgeRuntimeStream,
|
4
5
|
mergeModelConfigs,
|
5
6
|
runResultStream,
|
6
7
|
streamPartEncoderStream,
|
@@ -9,7 +10,7 @@ import {
|
|
9
10
|
toLanguageModelMessages,
|
10
11
|
toLanguageModelTools,
|
11
12
|
toolResultStream
|
12
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-5ZTUOAPH.mjs";
|
13
14
|
import {
|
14
15
|
__export
|
15
16
|
} from "./chunk-BJPOCE4O.mjs";
|
@@ -18,7 +19,7 @@ import {
|
|
18
19
|
import { memo } from "react";
|
19
20
|
|
20
21
|
// src/context/providers/AssistantProvider.tsx
|
21
|
-
import { useEffect as useEffect4, useInsertionEffect as useInsertionEffect3, useRef as useRef2, useState as
|
22
|
+
import { useEffect as useEffect4, useInsertionEffect as useInsertionEffect3, useRef as useRef2, useState as useState8 } from "react";
|
22
23
|
|
23
24
|
// src/context/react/AssistantContext.ts
|
24
25
|
import { createContext, useContext } from "react";
|
@@ -97,7 +98,7 @@ var makeAssistantToolUIsStore = () => create2((set) => {
|
|
97
98
|
});
|
98
99
|
|
99
100
|
// src/context/providers/ThreadProvider.tsx
|
100
|
-
import { useEffect as useEffect3, useInsertionEffect as useInsertionEffect2, useState as
|
101
|
+
import { useEffect as useEffect3, useInsertionEffect as useInsertionEffect2, useState as useState7 } from "react";
|
101
102
|
|
102
103
|
// src/context/react/ThreadContext.ts
|
103
104
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
@@ -1614,13 +1615,49 @@ var useExternalStoreRuntime = (store) => {
|
|
1614
1615
|
return runtime;
|
1615
1616
|
};
|
1616
1617
|
|
1618
|
+
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
1619
|
+
import { useState as useState6 } from "react";
|
1620
|
+
|
1621
|
+
// src/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.ts
|
1622
|
+
var DangerousInBrowserAdapter = class {
|
1623
|
+
constructor(options) {
|
1624
|
+
this.options = options;
|
1625
|
+
}
|
1626
|
+
async *run({ messages, abortSignal, config }) {
|
1627
|
+
const res = await getEdgeRuntimeStream({
|
1628
|
+
options: this.options,
|
1629
|
+
abortSignal,
|
1630
|
+
requestData: {
|
1631
|
+
system: config.system,
|
1632
|
+
messages: toCoreMessages(messages),
|
1633
|
+
tools: config.tools ? toLanguageModelTools(config.tools) : [],
|
1634
|
+
...config.callSettings,
|
1635
|
+
...config.config
|
1636
|
+
}
|
1637
|
+
});
|
1638
|
+
const stream = res.pipeThrough(toolResultStream(config.tools, abortSignal)).pipeThrough(runResultStream());
|
1639
|
+
for await (const update of asAsyncIterable(stream)) {
|
1640
|
+
yield update;
|
1641
|
+
}
|
1642
|
+
}
|
1643
|
+
};
|
1644
|
+
|
1645
|
+
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
1646
|
+
var useDangerousInBrowserRuntime = ({
|
1647
|
+
initialMessages,
|
1648
|
+
...options
|
1649
|
+
}) => {
|
1650
|
+
const [adapter] = useState6(() => new DangerousInBrowserAdapter(options));
|
1651
|
+
return useLocalRuntime(adapter, { initialMessages });
|
1652
|
+
};
|
1653
|
+
|
1617
1654
|
// src/context/providers/ThreadProvider.tsx
|
1618
1655
|
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
1619
1656
|
var ThreadProvider = ({
|
1620
1657
|
children,
|
1621
1658
|
provider
|
1622
1659
|
}) => {
|
1623
|
-
const [context] =
|
1660
|
+
const [context] = useState7(() => {
|
1624
1661
|
const useThreadRuntime = makeThreadRuntimeStore(provider.thread);
|
1625
1662
|
const useThread = makeThreadStore(useThreadRuntime);
|
1626
1663
|
const useThreadMessages = makeThreadMessagesStore(useThreadRuntime);
|
@@ -1693,7 +1730,7 @@ var AssistantProvider = ({ children, runtime }) => {
|
|
1693
1730
|
useInsertionEffect3(() => {
|
1694
1731
|
runtimeRef.current = runtime;
|
1695
1732
|
});
|
1696
|
-
const [context] =
|
1733
|
+
const [context] = useState8(() => {
|
1697
1734
|
const useModelConfig = makeAssistantModelConfigStore();
|
1698
1735
|
const useToolUIs = makeAssistantToolUIsStore();
|
1699
1736
|
const useAssistantActions = makeAssistantActionsStore(runtimeRef);
|
@@ -2285,7 +2322,7 @@ __export(assistantModal_exports, {
|
|
2285
2322
|
});
|
2286
2323
|
|
2287
2324
|
// src/primitives/assistantModal/AssistantModalRoot.tsx
|
2288
|
-
import { useState as
|
2325
|
+
import { useState as useState9 } from "react";
|
2289
2326
|
import * as PopoverPrimitive2 from "@radix-ui/react-popover";
|
2290
2327
|
import { composeEventHandlers as composeEventHandlers2 } from "@radix-ui/primitive";
|
2291
2328
|
|
@@ -2309,7 +2346,7 @@ var usePopoverScope = PopoverPrimitive.createPopoverScope();
|
|
2309
2346
|
// src/primitives/assistantModal/AssistantModalRoot.tsx
|
2310
2347
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
2311
2348
|
var useAssistantModalOpenState = (defaultOpen = false) => {
|
2312
|
-
const state =
|
2349
|
+
const state = useState9(defaultOpen);
|
2313
2350
|
const [, setOpen] = state;
|
2314
2351
|
useOnComposerFocus(() => {
|
2315
2352
|
setOpen(true);
|
@@ -2523,7 +2560,7 @@ MessagePrimitiveIf.displayName = "MessagePrimitive.If";
|
|
2523
2560
|
import { memo as memo2 } from "react";
|
2524
2561
|
|
2525
2562
|
// src/context/providers/ContentPartProvider.tsx
|
2526
|
-
import { useEffect as useEffect9, useState as
|
2563
|
+
import { useEffect as useEffect9, useState as useState10 } from "react";
|
2527
2564
|
import { create as create11 } from "zustand";
|
2528
2565
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
2529
2566
|
var COMPLETE_STATUS = {
|
@@ -2562,7 +2599,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
|
|
2562
2599
|
};
|
2563
2600
|
var useContentPartContext2 = (partIndex) => {
|
2564
2601
|
const { useMessage } = useMessageContext();
|
2565
|
-
const [context] =
|
2602
|
+
const [context] = useState10(() => {
|
2566
2603
|
const useContentPart = create11(
|
2567
2604
|
() => getContentPartState(useMessage.getState(), void 0, partIndex)
|
2568
2605
|
);
|
@@ -3070,7 +3107,7 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
|
3070
3107
|
import { memo as memo3 } from "react";
|
3071
3108
|
|
3072
3109
|
// src/context/providers/MessageProvider.tsx
|
3073
|
-
import { useEffect as useEffect12, useState as
|
3110
|
+
import { useEffect as useEffect12, useState as useState11 } from "react";
|
3074
3111
|
import { create as create14 } from "zustand";
|
3075
3112
|
|
3076
3113
|
// src/context/stores/EditComposer.ts
|
@@ -3141,7 +3178,7 @@ var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
|
3141
3178
|
};
|
3142
3179
|
var useMessageContext2 = (messageIndex) => {
|
3143
3180
|
const { useThreadMessages, useThreadActions } = useThreadContext();
|
3144
|
-
const [context] =
|
3181
|
+
const [context] = useState11(() => {
|
3145
3182
|
const useMessage = create14(
|
3146
3183
|
() => getMessageState(
|
3147
3184
|
useThreadMessages.getState(),
|
@@ -4030,6 +4067,7 @@ export {
|
|
4030
4067
|
useContentPartDisplay,
|
4031
4068
|
useContentPartImage,
|
4032
4069
|
useContentPartText,
|
4070
|
+
useDangerousInBrowserRuntime,
|
4033
4071
|
useEdgeRuntime,
|
4034
4072
|
useExternalStoreRuntime,
|
4035
4073
|
useLocalRuntime,
|