@assistant-ui/react 0.7.25 → 0.7.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model-config/useAssistantInstructions.d.ts +6 -1
- package/dist/model-config/useAssistantInstructions.d.ts.map +1 -1
- package/dist/model-config/useAssistantInstructions.js +9 -3
- package/dist/model-config/useAssistantInstructions.js.map +1 -1
- package/dist/model-config/useAssistantInstructions.mjs +9 -3
- package/dist/model-config/useAssistantInstructions.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js +3 -3
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.mjs +3 -3
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.mjs.map +1 -1
- package/package.json +2 -2
- package/src/model-config/useAssistantInstructions.tsx +19 -1
- package/src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx +7 -3
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type AssistantInstructionsConfig = {
|
|
2
|
+
disabled?: boolean | undefined;
|
|
3
|
+
instruction: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const useAssistantInstructions: (config: string | AssistantInstructionsConfig) => void;
|
|
6
|
+
export {};
|
|
2
7
|
//# sourceMappingURL=useAssistantInstructions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAssistantInstructions.d.ts","sourceRoot":"","sources":["../../src/model-config/useAssistantInstructions.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"useAssistantInstructions.d.ts","sourceRoot":"","sources":["../../src/model-config/useAssistantInstructions.tsx"],"names":[],"mappings":"AAKA,KAAK,2BAA2B,GAAG;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AASF,eAAO,MAAM,wBAAwB,WAC3B,MAAM,GAAG,2BAA2B,SAe7C,CAAC"}
|
|
@@ -26,14 +26,20 @@ __export(useAssistantInstructions_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(useAssistantInstructions_exports);
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
var import_context = require("../context/index.js");
|
|
29
|
-
var
|
|
29
|
+
var getInstructions = (instruction) => {
|
|
30
|
+
if (typeof instruction === "string") return { instruction };
|
|
31
|
+
return instruction;
|
|
32
|
+
};
|
|
33
|
+
var useAssistantInstructions = (config) => {
|
|
34
|
+
const { instruction, disabled = false } = getInstructions(config);
|
|
30
35
|
const assistantRuntime = (0, import_context.useAssistantRuntime)();
|
|
31
36
|
(0, import_react.useEffect)(() => {
|
|
32
|
-
|
|
37
|
+
if (disabled) return;
|
|
38
|
+
const config2 = {
|
|
33
39
|
system: instruction
|
|
34
40
|
};
|
|
35
41
|
return assistantRuntime.registerModelConfigProvider({
|
|
36
|
-
getModelConfig: () =>
|
|
42
|
+
getModelConfig: () => config2
|
|
37
43
|
});
|
|
38
44
|
}, [assistantRuntime, instruction]);
|
|
39
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model-config/useAssistantInstructions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantRuntime } from \"../context\";\n\nexport const useAssistantInstructions = (
|
|
1
|
+
{"version":3,"sources":["../../src/model-config/useAssistantInstructions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantRuntime } from \"../context\";\n\ntype AssistantInstructionsConfig = {\n disabled?: boolean | undefined;\n instruction: string;\n};\n\nconst getInstructions = (\n instruction: string | AssistantInstructionsConfig,\n): AssistantInstructionsConfig => {\n if (typeof instruction === \"string\") return { instruction };\n return instruction;\n};\n\nexport const useAssistantInstructions = (\n config: string | AssistantInstructionsConfig,\n) => {\n const { instruction, disabled = false } = getInstructions(config);\n const assistantRuntime = useAssistantRuntime();\n\n useEffect(() => {\n if (disabled) return;\n\n const config = {\n system: instruction,\n };\n return assistantRuntime.registerModelConfigProvider({\n getModelConfig: () => config,\n });\n }, [assistantRuntime, instruction]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAC1B,qBAAoC;AAOpC,IAAM,kBAAkB,CACtB,gBACgC;AAChC,MAAI,OAAO,gBAAgB,SAAU,QAAO,EAAE,YAAY;AAC1D,SAAO;AACT;AAEO,IAAM,2BAA2B,CACtC,WACG;AACH,QAAM,EAAE,aAAa,WAAW,MAAM,IAAI,gBAAgB,MAAM;AAChE,QAAM,uBAAmB,oCAAoB;AAE7C,8BAAU,MAAM;AACd,QAAI,SAAU;AAEd,UAAMA,UAAS;AAAA,MACb,QAAQ;AAAA,IACV;AACA,WAAO,iBAAiB,4BAA4B;AAAA,MAClD,gBAAgB,MAAMA;AAAA,IACxB,CAAC;AAAA,EACH,GAAG,CAAC,kBAAkB,WAAW,CAAC;AACpC;","names":["config"]}
|
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
// src/model-config/useAssistantInstructions.tsx
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
import { useAssistantRuntime } from "../context/index.mjs";
|
|
6
|
-
var
|
|
6
|
+
var getInstructions = (instruction) => {
|
|
7
|
+
if (typeof instruction === "string") return { instruction };
|
|
8
|
+
return instruction;
|
|
9
|
+
};
|
|
10
|
+
var useAssistantInstructions = (config) => {
|
|
11
|
+
const { instruction, disabled = false } = getInstructions(config);
|
|
7
12
|
const assistantRuntime = useAssistantRuntime();
|
|
8
13
|
useEffect(() => {
|
|
9
|
-
|
|
14
|
+
if (disabled) return;
|
|
15
|
+
const config2 = {
|
|
10
16
|
system: instruction
|
|
11
17
|
};
|
|
12
18
|
return assistantRuntime.registerModelConfigProvider({
|
|
13
|
-
getModelConfig: () =>
|
|
19
|
+
getModelConfig: () => config2
|
|
14
20
|
});
|
|
15
21
|
}, [assistantRuntime, instruction]);
|
|
16
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model-config/useAssistantInstructions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantRuntime } from \"../context\";\n\nexport const useAssistantInstructions = (
|
|
1
|
+
{"version":3,"sources":["../../src/model-config/useAssistantInstructions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantRuntime } from \"../context\";\n\ntype AssistantInstructionsConfig = {\n disabled?: boolean | undefined;\n instruction: string;\n};\n\nconst getInstructions = (\n instruction: string | AssistantInstructionsConfig,\n): AssistantInstructionsConfig => {\n if (typeof instruction === \"string\") return { instruction };\n return instruction;\n};\n\nexport const useAssistantInstructions = (\n config: string | AssistantInstructionsConfig,\n) => {\n const { instruction, disabled = false } = getInstructions(config);\n const assistantRuntime = useAssistantRuntime();\n\n useEffect(() => {\n if (disabled) return;\n\n const config = {\n system: instruction,\n };\n return assistantRuntime.registerModelConfigProvider({\n getModelConfig: () => config,\n });\n }, [assistantRuntime, instruction]);\n};\n"],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AAOpC,IAAM,kBAAkB,CACtB,gBACgC;AAChC,MAAI,OAAO,gBAAgB,SAAU,QAAO,EAAE,YAAY;AAC1D,SAAO;AACT;AAEO,IAAM,2BAA2B,CACtC,WACG;AACH,QAAM,EAAE,aAAa,WAAW,MAAM,IAAI,gBAAgB,MAAM;AAChE,QAAM,mBAAmB,oBAAoB;AAE7C,YAAU,MAAM;AACd,QAAI,SAAU;AAEd,UAAMA,UAAS;AAAA,MACb,QAAQ;AAAA,IACV;AACA,WAAO,iBAAiB,4BAA4B;AAAA,MAClD,gBAAgB,MAAMA;AAAA,IACxB,CAAC;AAAA,EACH,GAAG,CAAC,kBAAkB,WAAW,CAAC;AACpC;","names":["config"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EMPTY_THREAD_CORE.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAKnD,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"EMPTY_THREAD_CORE.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAKnD,eAAO,MAAM,iBAAiB,EAAE,iBA4J/B,CAAC"}
|
|
@@ -89,14 +89,14 @@ var EMPTY_THREAD_CORE = {
|
|
|
89
89
|
setRunConfig() {
|
|
90
90
|
throw EMPTY_THREAD_ERROR;
|
|
91
91
|
},
|
|
92
|
-
reset() {
|
|
93
|
-
|
|
92
|
+
async reset() {
|
|
93
|
+
},
|
|
94
|
+
async clearAttachments() {
|
|
94
95
|
},
|
|
95
96
|
send() {
|
|
96
97
|
throw EMPTY_THREAD_ERROR;
|
|
97
98
|
},
|
|
98
99
|
cancel() {
|
|
99
|
-
throw EMPTY_THREAD_ERROR;
|
|
100
100
|
},
|
|
101
101
|
subscribe() {
|
|
102
102
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx"],"sourcesContent":["import { ThreadRuntimeCore } from \"../../internal\";\n\nconst EMPTY_THREAD_ERROR = new Error(\n \"This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead.\",\n);\nexport const EMPTY_THREAD_CORE: ThreadRuntimeCore = {\n getMessageById() {\n return undefined;\n },\n\n getBranches() {\n return [];\n },\n\n switchToBranch() {\n throw EMPTY_THREAD_ERROR;\n },\n\n append() {\n throw EMPTY_THREAD_ERROR;\n },\n\n startRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancelRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n addToolResult() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speak() {\n throw EMPTY_THREAD_ERROR;\n },\n\n stopSpeaking() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getSubmittedFeedback() {\n return undefined;\n },\n\n submitFeedback() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getModelConfig() {\n return {};\n },\n\n composer: {\n attachments: [],\n\n getAttachmentAccept() {\n return \"*\";\n },\n\n async addAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async removeAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n isEditing: false,\n\n canCancel: false,\n isEmpty: true,\n\n text: \"\",\n\n setText() {\n throw EMPTY_THREAD_ERROR;\n },\n\n role: \"user\",\n\n setRole() {\n throw EMPTY_THREAD_ERROR;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw EMPTY_THREAD_ERROR;\n },\n\n reset() {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx"],"sourcesContent":["import { ThreadRuntimeCore } from \"../../internal\";\n\nconst EMPTY_THREAD_ERROR = new Error(\n \"This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead.\",\n);\nexport const EMPTY_THREAD_CORE: ThreadRuntimeCore = {\n getMessageById() {\n return undefined;\n },\n\n getBranches() {\n return [];\n },\n\n switchToBranch() {\n throw EMPTY_THREAD_ERROR;\n },\n\n append() {\n throw EMPTY_THREAD_ERROR;\n },\n\n startRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancelRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n addToolResult() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speak() {\n throw EMPTY_THREAD_ERROR;\n },\n\n stopSpeaking() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getSubmittedFeedback() {\n return undefined;\n },\n\n submitFeedback() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getModelConfig() {\n return {};\n },\n\n composer: {\n attachments: [],\n\n getAttachmentAccept() {\n return \"*\";\n },\n\n async addAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async removeAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n isEditing: false,\n\n canCancel: false,\n isEmpty: true,\n\n text: \"\",\n\n setText() {\n throw EMPTY_THREAD_ERROR;\n },\n\n role: \"user\",\n\n setRole() {\n throw EMPTY_THREAD_ERROR;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async reset() {\n // noop\n },\n\n async clearAttachments() {\n // noop\n },\n\n send() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancel() {\n // noop\n },\n\n subscribe() {\n return () => {};\n },\n\n unstable_on() {\n return () => {};\n },\n },\n\n getEditComposer() {\n return undefined;\n },\n\n beginEdit() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speech: undefined,\n\n capabilities: {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n },\n\n isDisabled: true,\n\n messages: [],\n\n suggestions: [],\n\n extras: undefined,\n\n subscribe() {\n return () => {};\n },\n\n import() {\n throw EMPTY_THREAD_ERROR;\n },\n\n export() {\n return { messages: [] };\n },\n\n unstable_on() {\n return () => {};\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,qBAAqB,IAAI;AAAA,EAC7B;AACF;AACO,IAAM,oBAAuC;AAAA,EAClD,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EAEA,cAAc;AAC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AQ;AAAA,EAER,cAAc;AAAA,IACZ,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,YAAY;AAAA,EAEZ,UAAU,CAAC;AAAA,EAEX,aAAa,CAAC;AAAA,EAEd,QAAQ;AAAA,EAER,YAAY;AACV,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AAAA,EAEA,SAAS;AACP,UAAM;AAAA,EACR;AAAA,EAEA,SAAS;AACP,WAAO,EAAE,UAAU,CAAC,EAAE;AAAA,EACxB;AAAA,EAEA,cAAc;AACZ,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -65,14 +65,14 @@ var EMPTY_THREAD_CORE = {
|
|
|
65
65
|
setRunConfig() {
|
|
66
66
|
throw EMPTY_THREAD_ERROR;
|
|
67
67
|
},
|
|
68
|
-
reset() {
|
|
69
|
-
|
|
68
|
+
async reset() {
|
|
69
|
+
},
|
|
70
|
+
async clearAttachments() {
|
|
70
71
|
},
|
|
71
72
|
send() {
|
|
72
73
|
throw EMPTY_THREAD_ERROR;
|
|
73
74
|
},
|
|
74
75
|
cancel() {
|
|
75
|
-
throw EMPTY_THREAD_ERROR;
|
|
76
76
|
},
|
|
77
77
|
subscribe() {
|
|
78
78
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx"],"sourcesContent":["import { ThreadRuntimeCore } from \"../../internal\";\n\nconst EMPTY_THREAD_ERROR = new Error(\n \"This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead.\",\n);\nexport const EMPTY_THREAD_CORE: ThreadRuntimeCore = {\n getMessageById() {\n return undefined;\n },\n\n getBranches() {\n return [];\n },\n\n switchToBranch() {\n throw EMPTY_THREAD_ERROR;\n },\n\n append() {\n throw EMPTY_THREAD_ERROR;\n },\n\n startRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancelRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n addToolResult() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speak() {\n throw EMPTY_THREAD_ERROR;\n },\n\n stopSpeaking() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getSubmittedFeedback() {\n return undefined;\n },\n\n submitFeedback() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getModelConfig() {\n return {};\n },\n\n composer: {\n attachments: [],\n\n getAttachmentAccept() {\n return \"*\";\n },\n\n async addAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async removeAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n isEditing: false,\n\n canCancel: false,\n isEmpty: true,\n\n text: \"\",\n\n setText() {\n throw EMPTY_THREAD_ERROR;\n },\n\n role: \"user\",\n\n setRole() {\n throw EMPTY_THREAD_ERROR;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw EMPTY_THREAD_ERROR;\n },\n\n reset() {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx"],"sourcesContent":["import { ThreadRuntimeCore } from \"../../internal\";\n\nconst EMPTY_THREAD_ERROR = new Error(\n \"This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead.\",\n);\nexport const EMPTY_THREAD_CORE: ThreadRuntimeCore = {\n getMessageById() {\n return undefined;\n },\n\n getBranches() {\n return [];\n },\n\n switchToBranch() {\n throw EMPTY_THREAD_ERROR;\n },\n\n append() {\n throw EMPTY_THREAD_ERROR;\n },\n\n startRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancelRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n addToolResult() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speak() {\n throw EMPTY_THREAD_ERROR;\n },\n\n stopSpeaking() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getSubmittedFeedback() {\n return undefined;\n },\n\n submitFeedback() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getModelConfig() {\n return {};\n },\n\n composer: {\n attachments: [],\n\n getAttachmentAccept() {\n return \"*\";\n },\n\n async addAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async removeAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n isEditing: false,\n\n canCancel: false,\n isEmpty: true,\n\n text: \"\",\n\n setText() {\n throw EMPTY_THREAD_ERROR;\n },\n\n role: \"user\",\n\n setRole() {\n throw EMPTY_THREAD_ERROR;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async reset() {\n // noop\n },\n\n async clearAttachments() {\n // noop\n },\n\n send() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancel() {\n // noop\n },\n\n subscribe() {\n return () => {};\n },\n\n unstable_on() {\n return () => {};\n },\n },\n\n getEditComposer() {\n return undefined;\n },\n\n beginEdit() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speech: undefined,\n\n capabilities: {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n },\n\n isDisabled: true,\n\n messages: [],\n\n suggestions: [],\n\n extras: undefined,\n\n subscribe() {\n return () => {};\n },\n\n import() {\n throw EMPTY_THREAD_ERROR;\n },\n\n export() {\n return { messages: [] };\n },\n\n unstable_on() {\n return () => {};\n },\n};\n"],"mappings":";AAEA,IAAM,qBAAqB,IAAI;AAAA,EAC7B;AACF;AACO,IAAM,oBAAuC;AAAA,EAClD,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EAEA,cAAc;AACZ,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,iBAAiB;AACf,UAAM;AAAA,EACR;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N,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,YAAY;AAAA,EAEZ,UAAU,CAAC;AAAA,EAEX,aAAa,CAAC;AAAA,EAEd,QAAQ;AAAA,EAER,YAAY;AACV,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AAAA,EAEA,SAAS;AACP,UAAM;AAAA,EACR;AAAA,EAEA,SAAS;AACP,WAAO,EAAE,UAAU,CAAC,EAAE;AAAA,EACxB;AAAA,EAEA,cAAc;AACZ,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"conversational-ui",
|
|
30
30
|
"conversational-ai"
|
|
31
31
|
],
|
|
32
|
-
"version": "0.7.
|
|
32
|
+
"version": "0.7.26",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
|
@@ -120,8 +120,8 @@
|
|
|
120
120
|
"tailwindcss-animate": "^1.0.7",
|
|
121
121
|
"tsup": "8.3.5",
|
|
122
122
|
"tsx": "^4.19.2",
|
|
123
|
-
"@assistant-ui/tsbuildutils": "^0.0.1",
|
|
124
123
|
"@assistant-ui/tailwindcss-transformer": "0.1.0",
|
|
124
|
+
"@assistant-ui/tsbuildutils": "^0.0.1",
|
|
125
125
|
"@assistant-ui/tsconfig": "0.0.0"
|
|
126
126
|
},
|
|
127
127
|
"publishConfig": {
|
|
@@ -3,9 +3,27 @@
|
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { useAssistantRuntime } from "../context";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type AssistantInstructionsConfig = {
|
|
7
|
+
disabled?: boolean | undefined;
|
|
8
|
+
instruction: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getInstructions = (
|
|
12
|
+
instruction: string | AssistantInstructionsConfig,
|
|
13
|
+
): AssistantInstructionsConfig => {
|
|
14
|
+
if (typeof instruction === "string") return { instruction };
|
|
15
|
+
return instruction;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const useAssistantInstructions = (
|
|
19
|
+
config: string | AssistantInstructionsConfig,
|
|
20
|
+
) => {
|
|
21
|
+
const { instruction, disabled = false } = getInstructions(config);
|
|
7
22
|
const assistantRuntime = useAssistantRuntime();
|
|
23
|
+
|
|
8
24
|
useEffect(() => {
|
|
25
|
+
if (disabled) return;
|
|
26
|
+
|
|
9
27
|
const config = {
|
|
10
28
|
system: instruction,
|
|
11
29
|
};
|
|
@@ -90,8 +90,12 @@ export const EMPTY_THREAD_CORE: ThreadRuntimeCore = {
|
|
|
90
90
|
throw EMPTY_THREAD_ERROR;
|
|
91
91
|
},
|
|
92
92
|
|
|
93
|
-
reset() {
|
|
94
|
-
|
|
93
|
+
async reset() {
|
|
94
|
+
// noop
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
async clearAttachments() {
|
|
98
|
+
// noop
|
|
95
99
|
},
|
|
96
100
|
|
|
97
101
|
send() {
|
|
@@ -99,7 +103,7 @@ export const EMPTY_THREAD_CORE: ThreadRuntimeCore = {
|
|
|
99
103
|
},
|
|
100
104
|
|
|
101
105
|
cancel() {
|
|
102
|
-
|
|
106
|
+
// noop
|
|
103
107
|
},
|
|
104
108
|
|
|
105
109
|
subscribe() {
|