@neutrome/lilsdk 0.6.4 → 0.6.5
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/package.json
CHANGED
|
@@ -25,6 +25,8 @@ const INITIAL_PROMPT =
|
|
|
25
25
|
|
|
26
26
|
/** Options accepted by {@link createCollapsedReasoner}. */
|
|
27
27
|
export type CollapsedReasonerOptions = {
|
|
28
|
+
/** Prompt used to initialize the reasoner's state. */
|
|
29
|
+
initialPrompt?: string;
|
|
28
30
|
/** Prompt used for periodic progress updates. */
|
|
29
31
|
prompt?: string;
|
|
30
32
|
/** Prompt used when an update must be attempted. */
|
|
@@ -87,7 +89,7 @@ export function createCollapsedReasoner(
|
|
|
87
89
|
wake?.();
|
|
88
90
|
wakePromise = nextWake();
|
|
89
91
|
};
|
|
90
|
-
const initial = summarizeInitial(ctx, summarizer, request).then(
|
|
92
|
+
const initial = summarizeInitial(ctx, summarizer, request, settings.initialPrompt).then(
|
|
91
93
|
(summary) => {
|
|
92
94
|
if (summary && acceptsSummaries && phase === 0) ready.push(summary);
|
|
93
95
|
notify();
|
|
@@ -218,6 +220,7 @@ function parseOptions(options: CollapsedReasonerOptions) {
|
|
|
218
220
|
return {
|
|
219
221
|
interval,
|
|
220
222
|
forcedInterval,
|
|
223
|
+
initialPrompt: options.initialPrompt ?? INITIAL_PROMPT,
|
|
221
224
|
prompt: options.prompt ?? DEFAULT_PROMPT,
|
|
222
225
|
forcedPrompt: options.forcedPrompt ?? DEFAULT_FORCED_PROMPT,
|
|
223
226
|
};
|
|
@@ -247,12 +250,13 @@ async function summarizeInitial(
|
|
|
247
250
|
ctx: ExecutorContext,
|
|
248
251
|
summarizer: ExecutorInput,
|
|
249
252
|
request: Program,
|
|
253
|
+
prompt: string,
|
|
250
254
|
): Promise<string> {
|
|
251
|
-
const
|
|
255
|
+
const content = new ProgramView(request).messages
|
|
252
256
|
.filter((message) => message.role === "user")
|
|
253
257
|
.at(-1)?.text.trim();
|
|
254
|
-
if (!
|
|
255
|
-
return summarize(ctx, summarizer,
|
|
258
|
+
if (!content) return "";
|
|
259
|
+
return summarize(ctx, summarizer, prompt, content);
|
|
256
260
|
}
|
|
257
261
|
|
|
258
262
|
function withoutThinking(program: Program): Program {
|