@semalt-ai/code 1.4.0 → 1.4.1
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/README.md +1 -0
- package/index.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -12,6 +12,8 @@ const { URL } = require('url');
|
|
|
12
12
|
|
|
13
13
|
const PACKAGE_JSON = require('./package.json');
|
|
14
14
|
|
|
15
|
+
const DEFAULT_API_TIMEOUT_MS = 15 * 60 * 1000;
|
|
16
|
+
|
|
15
17
|
// ── Config ────────────────────────────────────────────────────────────────────
|
|
16
18
|
|
|
17
19
|
const DEFAULT_CONFIG = {
|
|
@@ -20,6 +22,7 @@ const DEFAULT_CONFIG = {
|
|
|
20
22
|
default_model: 'default',
|
|
21
23
|
temperature: 0.7,
|
|
22
24
|
max_tokens: 4096,
|
|
25
|
+
request_timeout_ms: DEFAULT_API_TIMEOUT_MS,
|
|
23
26
|
stream: true,
|
|
24
27
|
models: [],
|
|
25
28
|
};
|
|
@@ -538,6 +541,7 @@ async function chatStream(messages, { model, temperature, maxTokens } = {}) {
|
|
|
538
541
|
try {
|
|
539
542
|
res = await httpRequest(apiUrl('/v1/chat/completions'), {
|
|
540
543
|
method: 'POST',
|
|
544
|
+
timeout: config.request_timeout_ms,
|
|
541
545
|
headers: {
|
|
542
546
|
'Content-Type': 'application/json',
|
|
543
547
|
'Authorization': `Bearer ${config.api_key}`,
|
|
@@ -639,6 +643,7 @@ async function chatSync(messages, { model } = {}) {
|
|
|
639
643
|
try {
|
|
640
644
|
res = await httpRequest(apiUrl('/v1/chat/completions'), {
|
|
641
645
|
method: 'POST',
|
|
646
|
+
timeout: config.request_timeout_ms,
|
|
642
647
|
headers: {
|
|
643
648
|
'Content-Type': 'application/json',
|
|
644
649
|
'Authorization': `Bearer ${config.api_key}`,
|