@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neutrome/lilsdk",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -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 prompt = new ProgramView(request).messages
255
+ const content = new ProgramView(request).messages
252
256
  .filter((message) => message.role === "user")
253
257
  .at(-1)?.text.trim();
254
- if (!prompt) return "";
255
- return summarize(ctx, summarizer, INITIAL_PROMPT, prompt);
258
+ if (!content) return "";
259
+ return summarize(ctx, summarizer, prompt, content);
256
260
  }
257
261
 
258
262
  function withoutThinking(program: Program): Program {