Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ export function buildApi(deps: ApiDeps): Router {
// concurrent callers each measured an untouched counter and every one of them passed.
let out;
try {
out = await market.chat({ ...body, requestId: body.request_id, messagesBase: body.messages_base, messagesPatched: body.messages_patched, patchIds: body.patch_ids ?? [body.patch_id!], visitor, caller: { operator, address: caller } });
out = await market.chat({ ...body, maxTokens: body.max_tokens, requestId: body.request_id, messagesBase: body.messages_base, messagesPatched: body.messages_patched, patchIds: body.patch_ids ?? [body.patch_id!], visitor, caller: { operator, address: caller } });
} catch (e) {
if (mine) market.refundChatQuota(mine);
if (network && !mineIsShared) market.refundChatQuota(network);
Expand Down
11 changes: 11 additions & 0 deletions test/guard-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ test('D1: the node sends the configured stop sequences, and no penalties by defa
assert.equal(b.presence_penalty, undefined);
});

test('HTTP max_tokens reaches both model calls and defaults to 200', async () => {
for (const limit of [1, 128, 1024, undefined]) {
bodies.length = 0;
const response = await ask('token budget test', { mode: 'compare', ...(limit === undefined ? {} : { max_tokens: limit }) });
assert.equal(response.status, 200);
const requests = bodies.filter(body => body.path === '/v1/chat/completions');
assert.equal(requests.length, 2);
assert.ok(requests.every(body => body.max_tokens === (limit ?? 200)));
}
});

test('D1: "<think>" is dropped from the stop list when the caller asked for thinking', async () => {
bodies.length = 0;
await ask('안녕하세요', { thinking: true });
Expand Down