@windmill-labs/chat-sdk 1.849.0 → 1.851.0
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/README.md +4 -3
- package/dist/{chat-DjonfE4j.js → chat-D5SvCHXU.js} +6 -7
- package/dist/{chat-C0iOSX6H.cjs → chat-pUgtVqWV.cjs} +6 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/runnable.d.ts +6 -4
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -177,9 +177,9 @@ history, so two agent runnables in one app keep separate conversations. Going th
|
|
|
177
177
|
`wmill.ts` is what makes the same code work in a deployed app and under `wmill app dev`.
|
|
178
178
|
|
|
179
179
|
`createChat` and the assistant-ui runtime take the same options; the AI SDK transport
|
|
180
|
-
does not. The runnable takes `user_message
|
|
181
|
-
the agent's memory is keyed by, so it remembers
|
|
182
|
-
|
|
180
|
+
does not. The runnable takes `user_message`, and the chat passes the conversation id as
|
|
181
|
+
`backendAsync`'s `memoryId` option, which the agent's memory is keyed by, so it remembers
|
|
182
|
+
earlier turns (called from `wmill.ts` without it, it is a single run with no conversation). The agent needs managed
|
|
183
183
|
memory: one whose memory is off takes `previous_messages` instead, the history you keep. A signed-in viewer's turns
|
|
184
184
|
are filed under them, so nobody else can continue their conversations; an anonymous
|
|
185
185
|
visitor's are kept apart per app. The chat makes no request of its own: history is
|
|
@@ -244,6 +244,7 @@ interface ChatState {
|
|
|
244
244
|
history: 'server' | 'local' | 'none'
|
|
245
245
|
loadingMessages: boolean
|
|
246
246
|
hasMoreMessages: boolean
|
|
247
|
+
runningJobId?: string // the flow job the running turn follows
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
interface ChatMessage {
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { C as _assertClassBrand, S as _classPrivateFieldSet2, T as _classPrivateMethodInitSpec, _ as WindmillApiError, a as errorResultMessage, b as turnRunningError, c as isErrorResult, d as randomId, f as sleep, g as TurnRunningError, i as conversationTitle, l as now, m as createStreamEventParser, n as abortError, o as extractChatAnswer, p as truncateTitle, s as isAbortError, t as followJob, v as WindmillChatApi, w as _classPrivateFieldInitSpec, x as _classPrivateFieldGet2 } from "./follow-DXfmfPfr.js";
|
|
2
2
|
//#region src/runnable.ts
|
|
3
3
|
/**
|
|
4
|
-
* `run` and `follow` over a raw app's
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* `run` and `follow` over a raw app's chat runnable (a saved AI agent, or a flow in chat mode),
|
|
5
|
+
* behind the `runnable` option. The conversation id goes as `memoryId`, the run's `memory_id`
|
|
6
|
+
* query parameter, which keys the conversation and its memory.
|
|
7
7
|
*/
|
|
8
8
|
function rawAppRunnable(start, streamJob) {
|
|
9
9
|
return {
|
|
10
10
|
run: async (args, { conversationId }) => {
|
|
11
11
|
try {
|
|
12
|
-
return String(await start({
|
|
13
|
-
...args,
|
|
14
|
-
memory_id: conversationId
|
|
15
|
-
}));
|
|
12
|
+
return String(await start(args, { memoryId: conversationId }));
|
|
16
13
|
} catch (e) {
|
|
17
14
|
const text = e instanceof Error ? e.message : String(e);
|
|
18
15
|
throw turnRunningError(text.slice(text.indexOf("{"), text.lastIndexOf("}") + 1)) ?? e;
|
|
@@ -610,6 +607,7 @@ var ChatImpl = class {
|
|
|
610
607
|
};
|
|
611
608
|
async function _followTurn(turn, isNew) {
|
|
612
609
|
let nextTurn;
|
|
610
|
+
_assertClassBrand(_ChatImpl_brand, this, _set).call(this, { runningJobId: turn.jobId });
|
|
613
611
|
try {
|
|
614
612
|
const stopPolling = _classPrivateFieldGet2(_state, this).history === "server" ? _assertClassBrand(_ChatImpl_brand, this, _startPolling).call(this, turn) : () => {};
|
|
615
613
|
let result;
|
|
@@ -629,6 +627,7 @@ async function _followTurn(turn, isNew) {
|
|
|
629
627
|
_assertClassBrand(_ChatImpl_brand, this, _failTurn).call(this, turn, e);
|
|
630
628
|
} finally {
|
|
631
629
|
if (_classPrivateFieldGet2(_turn, this) === turn) _classPrivateFieldSet2(_turn, this, void 0);
|
|
630
|
+
if (_classPrivateFieldGet2(_state, this).runningJobId === turn.jobId) _assertClassBrand(_ChatImpl_brand, this, _set).call(this, { runningJobId: void 0 });
|
|
632
631
|
}
|
|
633
632
|
if (nextTurn) await this.resumeTurn(nextTurn);
|
|
634
633
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
const require_follow = require("./follow-Dug-Afeu.cjs");
|
|
2
2
|
//#region src/runnable.ts
|
|
3
3
|
/**
|
|
4
|
-
* `run` and `follow` over a raw app's
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* `run` and `follow` over a raw app's chat runnable (a saved AI agent, or a flow in chat mode),
|
|
5
|
+
* behind the `runnable` option. The conversation id goes as `memoryId`, the run's `memory_id`
|
|
6
|
+
* query parameter, which keys the conversation and its memory.
|
|
7
7
|
*/
|
|
8
8
|
function rawAppRunnable(start, streamJob) {
|
|
9
9
|
return {
|
|
10
10
|
run: async (args, { conversationId }) => {
|
|
11
11
|
try {
|
|
12
|
-
return String(await start({
|
|
13
|
-
...args,
|
|
14
|
-
memory_id: conversationId
|
|
15
|
-
}));
|
|
12
|
+
return String(await start(args, { memoryId: conversationId }));
|
|
16
13
|
} catch (e) {
|
|
17
14
|
const text = e instanceof Error ? e.message : String(e);
|
|
18
15
|
throw require_follow.turnRunningError(text.slice(text.indexOf("{"), text.lastIndexOf("}") + 1)) ?? e;
|
|
@@ -610,6 +607,7 @@ var ChatImpl = class {
|
|
|
610
607
|
};
|
|
611
608
|
async function _followTurn(turn, isNew) {
|
|
612
609
|
let nextTurn;
|
|
610
|
+
require_follow._assertClassBrand(_ChatImpl_brand, this, _set).call(this, { runningJobId: turn.jobId });
|
|
613
611
|
try {
|
|
614
612
|
const stopPolling = require_follow._classPrivateFieldGet2(_state, this).history === "server" ? require_follow._assertClassBrand(_ChatImpl_brand, this, _startPolling).call(this, turn) : () => {};
|
|
615
613
|
let result;
|
|
@@ -629,6 +627,7 @@ async function _followTurn(turn, isNew) {
|
|
|
629
627
|
require_follow._assertClassBrand(_ChatImpl_brand, this, _failTurn).call(this, turn, e);
|
|
630
628
|
} finally {
|
|
631
629
|
if (require_follow._classPrivateFieldGet2(_turn, this) === turn) require_follow._classPrivateFieldSet2(_turn, this, void 0);
|
|
630
|
+
if (require_follow._classPrivateFieldGet2(_state, this).runningJobId === turn.jobId) require_follow._assertClassBrand(_ChatImpl_brand, this, _set).call(this, { runningJobId: void 0 });
|
|
632
631
|
}
|
|
633
632
|
if (nextTurn) await this.resumeTurn(nextTurn);
|
|
634
633
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_follow = require("./follow-Dug-Afeu.cjs");
|
|
3
|
-
const require_chat = require("./chat-
|
|
3
|
+
const require_chat = require("./chat-pUgtVqWV.cjs");
|
|
4
4
|
exports.CHAT_UPLOADS_PREFIX = require_chat.CHAT_UPLOADS_PREFIX;
|
|
5
5
|
exports.TurnRunningError = require_follow.TurnRunningError;
|
|
6
6
|
exports.WindmillApiError = require_follow.WindmillApiError;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { _ as WindmillApiError, b as turnRunningError, g as TurnRunningError, h as parseStreamEvents, m as createStreamEventParser, o as extractChatAnswer, r as conversationIdFor, t as followJob, v as WindmillChatApi, y as readServerSentEvents } from "./follow-DXfmfPfr.js";
|
|
2
|
-
import { a as detectRawApp, i as uploadAttachments, n as CHAT_UPLOADS_PREFIX, r as storedAttachmentName, t as createChat } from "./chat-
|
|
2
|
+
import { a as detectRawApp, i as uploadAttachments, n as CHAT_UPLOADS_PREFIX, r as storedAttachmentName, t as createChat } from "./chat-D5SvCHXU.js";
|
|
3
3
|
export { CHAT_UPLOADS_PREFIX, TurnRunningError, WindmillApiError, WindmillChatApi, conversationIdFor, createChat, createStreamEventParser, detectRawApp, extractChatAnswer, followJob, parseStreamEvents, readServerSentEvents, storedAttachmentName, turnRunningError, uploadAttachments };
|
package/dist/react.cjs
CHANGED
package/dist/react.js
CHANGED
package/dist/runnable.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ChatOptions } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* `run` and `follow` over a raw app's
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* `run` and `follow` over a raw app's chat runnable (a saved AI agent, or a flow in chat mode),
|
|
4
|
+
* behind the `runnable` option. The conversation id goes as `memoryId`, the run's `memory_id`
|
|
5
|
+
* query parameter, which keys the conversation and its memory.
|
|
6
6
|
*/
|
|
7
|
-
export declare function rawAppRunnable(start: (args: any
|
|
7
|
+
export declare function rawAppRunnable(start: (args: any, opts: {
|
|
8
|
+
memoryId: string;
|
|
9
|
+
}) => Promise<string>, streamJob: (jobId: string, onUpdate?: (update: {
|
|
8
10
|
new_result_stream?: string;
|
|
9
11
|
}) => void) => Promise<unknown>): Required<Pick<ChatOptions, 'run' | 'follow'>>;
|
package/dist/types.d.ts
CHANGED
|
@@ -77,6 +77,8 @@ export interface ChatState {
|
|
|
77
77
|
history: HistoryMode;
|
|
78
78
|
loadingMessages: boolean;
|
|
79
79
|
hasMoreMessages: boolean;
|
|
80
|
+
/** The flow job the running turn follows, once it is known. */
|
|
81
|
+
runningJobId?: string;
|
|
80
82
|
}
|
|
81
83
|
export type TokenSource = string | (() => string | Promise<string>);
|
|
82
84
|
export type StorageLike = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windmill-labs/chat-sdk",
|
|
3
3
|
"description": "Build chat interfaces on Windmill flows deployed in chat mode, from any frontend or raw app",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.851.0",
|
|
5
5
|
"author": "Ruben Fiszel",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"homepage": "https://github.com/windmill-labs/windmill/tree/main/chat-sdk#readme",
|