@threaded/ai 1.0.22 → 1.0.24
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/index.cjs +9 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -159,7 +159,9 @@ interface Thread {
|
|
|
159
159
|
id: string;
|
|
160
160
|
store: ThreadStore;
|
|
161
161
|
generate(step: StepFunction): Promise<ConversationContext>;
|
|
162
|
-
message(content: string, workflow?: StepFunction
|
|
162
|
+
message(content: string, workflow?: StepFunction, options?: {
|
|
163
|
+
abortSignal?: AbortSignal;
|
|
164
|
+
}): Promise<ConversationContext>;
|
|
163
165
|
}
|
|
164
166
|
interface RetryOptions {
|
|
165
167
|
times?: number;
|
|
@@ -292,11 +294,12 @@ declare const tap: (fn: (ctx: ConversationContext) => Promise<void> | void) => S
|
|
|
292
294
|
|
|
293
295
|
declare const when: (condition: (ctx: ConversationContext) => boolean, action: StepFunction) => StepFunction;
|
|
294
296
|
|
|
295
|
-
declare const model: ({ model, schema, system, apiKey, }?: {
|
|
297
|
+
declare const model: ({ model, schema, system, apiKey, baseUrl, }?: {
|
|
296
298
|
model?: string;
|
|
297
299
|
schema?: JsonSchema | StandardSchema;
|
|
298
300
|
system?: string | ((ctx: ConversationContext) => string);
|
|
299
301
|
apiKey?: string;
|
|
302
|
+
baseUrl?: string;
|
|
300
303
|
}) => ComposedFunction;
|
|
301
304
|
|
|
302
305
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -159,7 +159,9 @@ interface Thread {
|
|
|
159
159
|
id: string;
|
|
160
160
|
store: ThreadStore;
|
|
161
161
|
generate(step: StepFunction): Promise<ConversationContext>;
|
|
162
|
-
message(content: string, workflow?: StepFunction
|
|
162
|
+
message(content: string, workflow?: StepFunction, options?: {
|
|
163
|
+
abortSignal?: AbortSignal;
|
|
164
|
+
}): Promise<ConversationContext>;
|
|
163
165
|
}
|
|
164
166
|
interface RetryOptions {
|
|
165
167
|
times?: number;
|
|
@@ -292,11 +294,12 @@ declare const tap: (fn: (ctx: ConversationContext) => Promise<void> | void) => S
|
|
|
292
294
|
|
|
293
295
|
declare const when: (condition: (ctx: ConversationContext) => boolean, action: StepFunction) => StepFunction;
|
|
294
296
|
|
|
295
|
-
declare const model: ({ model, schema, system, apiKey, }?: {
|
|
297
|
+
declare const model: ({ model, schema, system, apiKey, baseUrl, }?: {
|
|
296
298
|
model?: string;
|
|
297
299
|
schema?: JsonSchema | StandardSchema;
|
|
298
300
|
system?: string | ((ctx: ConversationContext) => string);
|
|
299
301
|
apiKey?: string;
|
|
302
|
+
baseUrl?: string;
|
|
300
303
|
}) => ComposedFunction;
|
|
301
304
|
|
|
302
305
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1336,7 +1336,8 @@ var model = ({
|
|
|
1336
1336
|
model: model2 = "openai/gpt-4o-mini",
|
|
1337
1337
|
schema,
|
|
1338
1338
|
system,
|
|
1339
|
-
apiKey
|
|
1339
|
+
apiKey,
|
|
1340
|
+
baseUrl
|
|
1340
1341
|
} = {}) => {
|
|
1341
1342
|
return async (ctxOrMessage) => {
|
|
1342
1343
|
const ctx = typeof ctxOrMessage === "string" ? (
|
|
@@ -1373,7 +1374,7 @@ var model = ({
|
|
|
1373
1374
|
break;
|
|
1374
1375
|
}
|
|
1375
1376
|
currentCtx = await callProvider(
|
|
1376
|
-
{ model: model2, instructions, schema: normalizedSchema, apiKey },
|
|
1377
|
+
{ model: model2, instructions, schema: normalizedSchema, apiKey, baseUrl },
|
|
1377
1378
|
currentCtx
|
|
1378
1379
|
);
|
|
1379
1380
|
if (currentCtx.lastResponse?.tool_calls && currentCtx.tools?.length) {
|
|
@@ -1556,16 +1557,20 @@ var createThread = (id, store) => {
|
|
|
1556
1557
|
await store.set(id, finalContext.history);
|
|
1557
1558
|
return finalContext;
|
|
1558
1559
|
},
|
|
1559
|
-
async message(content, workflow) {
|
|
1560
|
+
async message(content, workflow, options) {
|
|
1560
1561
|
const history = await store.get(id);
|
|
1561
1562
|
const initialContext = {
|
|
1562
1563
|
history: [...history, { role: "user", content }],
|
|
1563
1564
|
tools: [],
|
|
1564
1565
|
toolExecutors: {},
|
|
1565
1566
|
toolLimits: {},
|
|
1566
|
-
toolCallCounts: {}
|
|
1567
|
+
toolCallCounts: {},
|
|
1568
|
+
abortSignal: options?.abortSignal
|
|
1567
1569
|
};
|
|
1568
1570
|
const finalContext = await (workflow || model())(initialContext);
|
|
1571
|
+
if (options?.abortSignal?.aborted) {
|
|
1572
|
+
return finalContext;
|
|
1573
|
+
}
|
|
1569
1574
|
await store.set(id, finalContext.history);
|
|
1570
1575
|
return finalContext;
|
|
1571
1576
|
}
|