Skip to content

Commit ed1f973

Browse files
committed
fix: standardize reasoning guards to truthy checks
Change `if (reasoning !== undefined)` to `if (reasoning)` in helpers.ts and ollama.ts for consistency with the fixture-loader convention where empty string means no reasoning.
1 parent 4b42f33 commit ed1f973

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function buildTextChunks(
8282
});
8383

8484
// Reasoning chunks (emitted before content chunks)
85-
if (reasoning !== undefined) {
85+
if (reasoning) {
8686
for (let i = 0; i < reasoning.length; i += chunkSize) {
8787
const slice = reasoning.slice(i, i + chunkSize);
8888
chunks.push({
@@ -219,7 +219,7 @@ export function buildTextCompletion(
219219
role: "assistant",
220220
content,
221221
refusal: null,
222-
...(reasoning !== undefined ? { reasoning_content: reasoning } : {}),
222+
...(reasoning ? { reasoning_content: reasoning } : {}),
223223
},
224224
finish_reason: "stop",
225225
},

src/ollama.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function buildOllamaChatTextResponse(content: string, model: string, reasoning?:
167167
message: {
168168
role: "assistant",
169169
content,
170-
...(reasoning !== undefined ? { reasoning_content: reasoning } : {}),
170+
...(reasoning ? { reasoning_content: reasoning } : {}),
171171
},
172172
done: true,
173173
...DURATION_FIELDS,
@@ -312,7 +312,7 @@ function buildOllamaGenerateTextResponse(
312312
model,
313313
created_at: new Date().toISOString(),
314314
response: content,
315-
...(reasoning !== undefined ? { reasoning_content: reasoning } : {}),
315+
...(reasoning ? { reasoning_content: reasoning } : {}),
316316
done: true,
317317
...DURATION_FIELDS,
318318
context: [],

0 commit comments

Comments
 (0)