Skip to content

Commit 8157b9c

Browse files
committed
max_tokens optional
1 parent 30d25a9 commit 8157b9c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oneping",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "Query LLMs and Whisper straight from the web.",
55
"type": "module",
66
"author": "Doug Hanley",

src/curl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,13 @@ function prepare_request(query, args) {
173173
const body = provider.body ?? {};
174174
const model = provider.model ? { model: provider.model } : {};
175175
const max_tokens_name = provider.max_tokens_name ?? 'max_tokens';
176+
const toks = (max_tokens != null) ? { [max_tokens_name]: max_tokens } : {};
176177
const authorize = provider.authorize ? provider.authorize(api_key) : {};
177178
const message = provider.payload(query, { system, history, prefill });
178179

179180
// prepare request
180181
const headers = { 'Content-Type': 'application/json', ...authorize, ...head };
181-
const payload = { ...message, ...model, stream, [max_tokens_name]: max_tokens, ...body };
182+
const payload = { ...message, ...model, ...toks, stream, ...body };
182183

183184
// relevant parameters
184185
return { provider, url, headers, payload };
@@ -230,6 +231,7 @@ async function* stream(query, args) {
230231

231232
// check status
232233
if (!response.ok) {
234+
const data = await response.json();
233235
throw new Error(`Status ${response.status}: ${data.error.message}`);
234236
}
235237

0 commit comments

Comments
 (0)