@deepseek-ai/dsh-session-title-llm 0.2.2-rc.1 → 0.2.2-rc.2
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/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/package.json +14 -11
- package/src/index.ts +291 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,QAAQ,4BAA4B,CAAC;IAC1C,UAAU,oBAAoB;QAC5B,eAAe,EAAE,IAAI,CAAA;KACtB;CACF;AAED,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,gBAAgB;QACxB,uBAAuB,EAAE;YAAE,IAAI,EAAE,uBAAuB,CAAA;SAAE,GAAG,aAAa,CAAA;KAC3E;CACF;AAED,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EAEZ,oBAAoB,EACpB,OAAO,EACP,iBAAiB,EAClB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,gCAAgC,CAAA;AAEvC,gFAAgF;AAChF,MAAM,WAAW,+BAA+B;IAC9C,sEAAsE;IACtE,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAA;IAC9C,iEAAiE;IACjE,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAA;IAClC,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,yBA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AM;YACd,QAAQ;YACR,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;YAC7B,OAAO,EAAE,eAAe;YACxB,MAAM,EAAE,YAAY,CAAC,MAAM;SAC5B,CAAC,CAAA;QACF,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,2BAA2B,EAAE;YAClD,aAAa;YACb,WAAW,EAAE,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC;YACtC,KAAK;YACL,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,QAAQ;YACR,SAAS;YACT,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;SACrG,CAAC,CAAA;QACF,YAAY,CAAC,MAAM,CAAC,cAAc,EAAE,CAAA;QACpC,MAAM,SAAS,GAAG,IAAI,cAAc,EAAE,CAAA;QACtC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/C,YAAY,CAAC,MAAM,CAAC,cAAc,EAAE,CAAA;YACpC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC;QACD,YAAY,CAAC,MAAM,CAAC,cAAc,EAAE,CAAA;QACpC,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAC/C,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;;;;;;;;;CAC5D"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-session-title-llm",
|
|
3
3
|
"description": "Shared LLM generation policy for DeepSeek Harness session-title providers",
|
|
4
|
-
"version": "0.2.2-rc.
|
|
4
|
+
"version": "0.2.2-rc.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -23,25 +23,28 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"lib/index.js",
|
|
26
|
-
"lib/types/**/*.d.ts"
|
|
26
|
+
"lib/types/**/*.d.ts",
|
|
27
|
+
"lib/types/**/*.d.ts.map",
|
|
28
|
+
"lib/**/*.js.map",
|
|
29
|
+
"src"
|
|
27
30
|
],
|
|
28
31
|
"license": "MIT",
|
|
29
32
|
"peerDependencies": {
|
|
30
33
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
31
|
-
"@deepseek-ai/dsh-llm": "0.2.2-rc.
|
|
32
|
-
"@deepseek-ai/dsh-session": "0.2.2-rc.
|
|
33
|
-
"@deepseek-ai/dsh-session-title": "0.2.2-rc.
|
|
34
|
-
"@deepseek-ai/dsh-timeout": "0.2.2-rc.
|
|
34
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.2",
|
|
35
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.2",
|
|
36
|
+
"@deepseek-ai/dsh-session-title": "0.2.2-rc.2",
|
|
37
|
+
"@deepseek-ai/dsh-timeout": "0.2.2-rc.2"
|
|
35
38
|
},
|
|
36
39
|
"dependencies": {
|
|
37
|
-
"@deepseek-ai/dsh-util-values": "0.2.2-rc.
|
|
40
|
+
"@deepseek-ai/dsh-util-values": "0.2.2-rc.2",
|
|
38
41
|
"@deepseek-ai/schemastery": "~3.19.0"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
42
|
-
"@deepseek-ai/dsh-llm": "0.2.2-rc.
|
|
43
|
-
"@deepseek-ai/dsh-session": "0.2.2-rc.
|
|
44
|
-
"@deepseek-ai/dsh-session-title": "0.2.2-rc.
|
|
45
|
-
"@deepseek-ai/dsh-timeout": "0.2.2-rc.
|
|
45
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.2",
|
|
46
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.2",
|
|
47
|
+
"@deepseek-ai/dsh-session-title": "0.2.2-rc.2",
|
|
48
|
+
"@deepseek-ai/dsh-timeout": "0.2.2-rc.2"
|
|
46
49
|
}
|
|
47
50
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared execution policy for model-backed session-title providers: route
|
|
3
|
+
* preparation, input/token/time bounds, cancellation, exact auxiliary request
|
|
4
|
+
* logging, and stream assembly. Title wording, length targets, reasoning
|
|
5
|
+
* selection, and output interpretation belong to each provider.
|
|
6
|
+
* @module @deepseek-ai/dsh-session-title-llm
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare module '@deepseek-ai/dsh-llm/types' {
|
|
10
|
+
interface LlmRequestPurposeMap {
|
|
11
|
+
'session-title': true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
16
|
+
import z from '@deepseek-ai/schemastery'
|
|
17
|
+
import { createUserMessage, BlockAssembler } from '@deepseek-ai/dsh-llm'
|
|
18
|
+
import type { ContextFormed } from '@deepseek-ai/dsh-llm'
|
|
19
|
+
declare module '@deepseek-ai/dsh-llm' {
|
|
20
|
+
interface MessageSourceMap {
|
|
21
|
+
'dsh-session-title-llm': { kind: 'dsh-session-title-llm' } & ContextFormed
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
ContentBlock,
|
|
27
|
+
FinishReason,
|
|
28
|
+
GenerateOptions,
|
|
29
|
+
LlmResolvedModelInfo,
|
|
30
|
+
Message,
|
|
31
|
+
ReasoningEffortId,
|
|
32
|
+
} from '@deepseek-ai/dsh-llm'
|
|
33
|
+
import { deadline, MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
|
|
34
|
+
import { assertNever, deepFreeze } from '@deepseek-ai/dsh-util-values'
|
|
35
|
+
import type { SessionSeq } from '@deepseek-ai/dsh-session'
|
|
36
|
+
import { SessionTitleProviderId } from '@deepseek-ai/dsh-session-title'
|
|
37
|
+
import type {
|
|
38
|
+
SessionTitleModelIdentity,
|
|
39
|
+
SessionTitleProviderRequest,
|
|
40
|
+
} from '@deepseek-ai/dsh-session-title'
|
|
41
|
+
|
|
42
|
+
/** Exact model-visible request recorded before one auxiliary title dispatch. */
|
|
43
|
+
export interface SessionTitleLlmRequestEventData {
|
|
44
|
+
/** Registered title-provider identity responsible for the request. */
|
|
45
|
+
readonly titleProvider: SessionTitleProviderId
|
|
46
|
+
/** Exact human `user/message` seqs represented in `messages`. */
|
|
47
|
+
readonly messageSeqs: SessionSeq[]
|
|
48
|
+
/** Exact auxiliary LLM route. */
|
|
49
|
+
readonly route: SessionTitleModelIdentity
|
|
50
|
+
/** Exact auxiliary system prompt. */
|
|
51
|
+
readonly system: string
|
|
52
|
+
/** Exact auxiliary message list. */
|
|
53
|
+
readonly messages: Message[]
|
|
54
|
+
/** Exact auxiliary output-token cap. */
|
|
55
|
+
readonly maxTokens: number
|
|
56
|
+
/** Resolved reasoning effort when recorded; older requests can omit it. */
|
|
57
|
+
readonly reasoningEffort?: ReasoningEffortId
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare module '@deepseek-ai/dsh-session/types' {
|
|
61
|
+
interface SessionEventMap {
|
|
62
|
+
/** Log-only pre-dispatch record of one session-title model request. */
|
|
63
|
+
'session/title-llm-request': SessionTitleLlmRequestEventData
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Capability-owned timeout reason code for auxiliary title requests. */
|
|
68
|
+
export const SESSION_TITLE_TIMEOUT_CODE = 'SESSION_TITLE_TIMEOUT'
|
|
69
|
+
|
|
70
|
+
/** Required execution controls for one model-backed title request. */
|
|
71
|
+
export interface SessionTitleLlmConfig {
|
|
72
|
+
/** Maximum UTF-8 bytes in the provider-prepared user input. */
|
|
73
|
+
readonly maxInputBytes: number
|
|
74
|
+
/** Output-token cap for the title request, independent of conversation requests. */
|
|
75
|
+
readonly maxOutputTokens: number
|
|
76
|
+
/** End-to-end auxiliary request deadline in milliseconds. */
|
|
77
|
+
readonly timeoutMs: number
|
|
78
|
+
/** Optional explicit provider route; must be paired with `model`. */
|
|
79
|
+
readonly provider?: string
|
|
80
|
+
/** Optional explicit model id; must be paired with `provider`. */
|
|
81
|
+
readonly model?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Validated immutable execution controls. */
|
|
85
|
+
export interface ResolvedSessionTitleLlmConfig extends SessionTitleLlmConfig {}
|
|
86
|
+
|
|
87
|
+
/** Shared Loader field schemas with no library defaults. */
|
|
88
|
+
export const SessionTitleLlmConfigFields = {
|
|
89
|
+
maxInputBytes: z.number().step(1).min(1).required(),
|
|
90
|
+
maxOutputTokens: z.number().step(1).min(1).required(),
|
|
91
|
+
timeoutMs: z.number().step(1).min(1).max(MAX_TIMER_DELAY_MS).required(),
|
|
92
|
+
provider: z.string(),
|
|
93
|
+
model: z.string(),
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Shared Loader schema with no library defaults. */
|
|
97
|
+
export const SessionTitleLlmConfigSchema: z<SessionTitleLlmConfig> = z.object(SessionTitleLlmConfigFields)
|
|
98
|
+
|
|
99
|
+
/** Complete execution-control key set for direct construction validation. */
|
|
100
|
+
const CONFIG_KEYS: ReadonlySet<string> = new Set([
|
|
101
|
+
'maxInputBytes',
|
|
102
|
+
'maxOutputTokens',
|
|
103
|
+
'timeoutMs',
|
|
104
|
+
'provider',
|
|
105
|
+
'model',
|
|
106
|
+
])
|
|
107
|
+
|
|
108
|
+
/** Validate one positive integer limit. */
|
|
109
|
+
function assertPositiveInteger(name: string, value: number): void {
|
|
110
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
111
|
+
throw new Error(`session-title-llm: ${name} must be a positive integer`)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Validate and detach required execution controls.
|
|
117
|
+
* @param config - untrusted execution configuration.
|
|
118
|
+
* @returns immutable controls with optional route absence preserved.
|
|
119
|
+
*/
|
|
120
|
+
export function resolveSessionTitleLlmConfig(
|
|
121
|
+
config: SessionTitleLlmConfig,
|
|
122
|
+
): ResolvedSessionTitleLlmConfig {
|
|
123
|
+
const candidate: unknown = config
|
|
124
|
+
if (candidate === null || typeof candidate !== 'object') {
|
|
125
|
+
throw new Error('session-title-llm: configuration is required')
|
|
126
|
+
}
|
|
127
|
+
const value = candidate as SessionTitleLlmConfig
|
|
128
|
+
for (const key of Object.keys(value)) {
|
|
129
|
+
if (!CONFIG_KEYS.has(key)) throw new Error(`session-title-llm: unknown config key "${key}"`)
|
|
130
|
+
}
|
|
131
|
+
assertPositiveInteger('maxInputBytes', value.maxInputBytes)
|
|
132
|
+
assertPositiveInteger('maxOutputTokens', value.maxOutputTokens)
|
|
133
|
+
assertPositiveInteger('timeoutMs', value.timeoutMs)
|
|
134
|
+
if (value.timeoutMs > MAX_TIMER_DELAY_MS) {
|
|
135
|
+
throw new Error(`session-title-llm: timeoutMs must not exceed ${MAX_TIMER_DELAY_MS}`)
|
|
136
|
+
}
|
|
137
|
+
const hasProvider = value.provider !== undefined
|
|
138
|
+
const hasModel = value.model !== undefined
|
|
139
|
+
if (hasProvider !== hasModel) {
|
|
140
|
+
throw new Error('session-title-llm: provider and model must be supplied together')
|
|
141
|
+
}
|
|
142
|
+
if (hasProvider
|
|
143
|
+
&& (typeof value.provider !== 'string' || value.provider.length === 0
|
|
144
|
+
|| typeof value.model !== 'string' || value.model.length === 0)) {
|
|
145
|
+
throw new Error('session-title-llm: provider and model overrides must be non-empty strings')
|
|
146
|
+
}
|
|
147
|
+
return deepFreeze({ ...value })
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Provider-prepared model input, source-message attribution, and the
|
|
152
|
+
* provider-owned reasoning selector forwarded to `ctx.llm.prepareCall`.
|
|
153
|
+
*/
|
|
154
|
+
export interface SessionTitleLlmPreparedRequest {
|
|
155
|
+
/** Exact system prompt supplied by the provider. */
|
|
156
|
+
readonly system: string
|
|
157
|
+
/** Exact user message text supplied by the provider, including any framing. */
|
|
158
|
+
readonly input: string
|
|
159
|
+
/** Exact human `user/message` seqs represented by `input`, in log order. */
|
|
160
|
+
readonly messageSeqs: readonly SessionSeq[]
|
|
161
|
+
/**
|
|
162
|
+
* Provider-owned reasoning selection for the captured route. The execution
|
|
163
|
+
* module combines only the returned effort with its fixed output-token cap.
|
|
164
|
+
* @param model - detached, deeply frozen metadata from the captured adapter generation.
|
|
165
|
+
* @returns a supported effort id, or `undefined` to use the route's normal default.
|
|
166
|
+
*/
|
|
167
|
+
readonly selectReasoningEffort: (model: Readonly<LlmResolvedModelInfo>) => ReasoningEffortId | undefined
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Terminal finish kinds forwarded to a provider for its own interpretation. */
|
|
171
|
+
export type SessionTitleLlmFinish = Extract<FinishReason, { kind: 'stop' | 'tool-calls' | 'max-tokens' }>
|
|
172
|
+
|
|
173
|
+
/** Assembled auxiliary model response for one provider to interpret. */
|
|
174
|
+
export interface SessionTitleLlmResponse {
|
|
175
|
+
/** Assembled content blocks in stream order; the provider rejects unwanted block types. */
|
|
176
|
+
readonly blocks: readonly ContentBlock[]
|
|
177
|
+
/** Terminal finish reason forwarded without title-output interpretation. */
|
|
178
|
+
readonly finish: SessionTitleLlmFinish
|
|
179
|
+
/** Exact auxiliary model route that produced the response. */
|
|
180
|
+
readonly model: SessionTitleModelIdentity
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Resolve the explicit pair or the exact route captured from `request/header`. */
|
|
184
|
+
function resolveRoute(
|
|
185
|
+
config: ResolvedSessionTitleLlmConfig,
|
|
186
|
+
request: SessionTitleProviderRequest,
|
|
187
|
+
): SessionTitleModelIdentity {
|
|
188
|
+
if (config.provider !== undefined && config.model !== undefined) {
|
|
189
|
+
return { provider: config.provider, model: config.model }
|
|
190
|
+
}
|
|
191
|
+
if (request.route === undefined) {
|
|
192
|
+
throw new Error('session-title-llm: no logged request route is available; configure provider and model together')
|
|
193
|
+
}
|
|
194
|
+
return request.route
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Classify one terminal finish reason. Operational failures throw; every other
|
|
199
|
+
* terminal kind is returned for the provider to accept or reject.
|
|
200
|
+
* @param finish - terminal finish reason from the assembled stream.
|
|
201
|
+
* @returns the provider-facing finish reason.
|
|
202
|
+
* @throws {Error} on a provider or caller abort, or an impossible finish variant.
|
|
203
|
+
*/
|
|
204
|
+
function terminalFinish(finish: FinishReason): SessionTitleLlmFinish {
|
|
205
|
+
switch (finish.kind) {
|
|
206
|
+
case 'stop':
|
|
207
|
+
case 'tool-calls':
|
|
208
|
+
case 'max-tokens':
|
|
209
|
+
return finish
|
|
210
|
+
case 'error':
|
|
211
|
+
case 'aborted': {
|
|
212
|
+
const error = new Error(finish.failure.message) as Error & { code?: string }
|
|
213
|
+
error.code = finish.failure.code
|
|
214
|
+
throw error
|
|
215
|
+
}
|
|
216
|
+
/* v8 ignore next -- closed FinishReason union exhaustiveness guard */
|
|
217
|
+
default: return assertNever(finish, 'FinishReason')
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Execute one prepared auxiliary title request.
|
|
223
|
+
*
|
|
224
|
+
* The provider owns the system prompt, user input, reasoning selection, and
|
|
225
|
+
* output interpretation. This function owns route preparation, the final input
|
|
226
|
+
* byte limit, the output-token cap, the end-to-end deadline, cancellation, the
|
|
227
|
+
* exact `session/title-llm-request` record, and stream assembly.
|
|
228
|
+
* @param ctx - context exposing the registered LLM service.
|
|
229
|
+
* @param config - validated execution controls.
|
|
230
|
+
* @param request - service-owned session, route, message snapshot, current title, and cancellation.
|
|
231
|
+
* @param titleProvider - registered title-provider identity recorded with the request.
|
|
232
|
+
* @param prepared - provider system prompt, input, source-message seqs, and reasoning selector.
|
|
233
|
+
* @returns assembled response blocks, terminal finish, and the exact route used.
|
|
234
|
+
* @throws {Error} when input bounds, route preparation, the deadline, cancellation, or an operational finish failure occurs.
|
|
235
|
+
*/
|
|
236
|
+
export async function executeSessionTitleLlm(
|
|
237
|
+
ctx: Context,
|
|
238
|
+
config: ResolvedSessionTitleLlmConfig,
|
|
239
|
+
request: SessionTitleProviderRequest,
|
|
240
|
+
titleProvider: SessionTitleProviderId,
|
|
241
|
+
prepared: SessionTitleLlmPreparedRequest,
|
|
242
|
+
): Promise<SessionTitleLlmResponse> {
|
|
243
|
+
request.signal.throwIfAborted()
|
|
244
|
+
if (prepared.messageSeqs.length === 0) {
|
|
245
|
+
throw new Error('session-title-llm: at least one source message is required')
|
|
246
|
+
}
|
|
247
|
+
const inputBytes = Buffer.byteLength(prepared.input, 'utf8')
|
|
248
|
+
if (inputBytes > config.maxInputBytes) {
|
|
249
|
+
throw new Error(`session-title-llm: input is ${inputBytes} bytes, exceeding maxInputBytes ${config.maxInputBytes}`)
|
|
250
|
+
}
|
|
251
|
+
const route = resolveRoute(config, request)
|
|
252
|
+
const messages: Message[] = [createUserMessage({
|
|
253
|
+
content: [{ type: 'text', text: prepared.input }],
|
|
254
|
+
source: { kind: 'dsh-session-title-llm' },
|
|
255
|
+
})]
|
|
256
|
+
using callDeadline = deadline(request.signal, config.timeoutMs, SESSION_TITLE_TIMEOUT_CODE)
|
|
257
|
+
const maxTokens = config.maxOutputTokens
|
|
258
|
+
const call = await ctx.llm.prepareCall({
|
|
259
|
+
...route,
|
|
260
|
+
maxTokens,
|
|
261
|
+
}, callDeadline.signal, (controls, model) => {
|
|
262
|
+
const effort = prepared.selectReasoningEffort(model)
|
|
263
|
+
return { ...controls, ...effort === undefined ? {} : { reasoningEffort: effort } }
|
|
264
|
+
})
|
|
265
|
+
const options: GenerateOptions = deepFreeze({
|
|
266
|
+
...call.config,
|
|
267
|
+
messages,
|
|
268
|
+
system: prepared.system,
|
|
269
|
+
sessionId: request.session.id,
|
|
270
|
+
purpose: 'session-title',
|
|
271
|
+
signal: callDeadline.signal,
|
|
272
|
+
})
|
|
273
|
+
request.session.append('session/title-llm-request', {
|
|
274
|
+
titleProvider,
|
|
275
|
+
messageSeqs: [...prepared.messageSeqs],
|
|
276
|
+
route,
|
|
277
|
+
system: prepared.system,
|
|
278
|
+
messages,
|
|
279
|
+
maxTokens,
|
|
280
|
+
...call.config.reasoningEffort === undefined ? {} : { reasoningEffort: call.config.reasoningEffort },
|
|
281
|
+
})
|
|
282
|
+
callDeadline.signal.throwIfAborted()
|
|
283
|
+
const assembler = new BlockAssembler()
|
|
284
|
+
for await (const chunk of call.stream(options)) {
|
|
285
|
+
callDeadline.signal.throwIfAborted()
|
|
286
|
+
assembler.push(chunk)
|
|
287
|
+
}
|
|
288
|
+
callDeadline.signal.throwIfAborted()
|
|
289
|
+
const finish = terminalFinish(assembler.finish)
|
|
290
|
+
return { blocks: assembler.blocks(), finish, model: route }
|
|
291
|
+
}
|