bios-sdk 0.1.1-rc.26 → 0.1.1-rc.35
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 +33 -0
- package/dist/resources/inference.d.ts +6 -0
- package/dist/resources/inference.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,6 +107,39 @@ for await (const chunk of client.inference.streamChatCompletions({
|
|
|
107
107
|
// controller.abort() cancels an unfinished generation.
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
#### Serverless catalog models
|
|
111
|
+
|
|
112
|
+
Call any catalog model by id on the unified `/v1` endpoint with a workspace
|
|
113
|
+
platform key that carries the serverless scope — no per-deployment key. The
|
|
114
|
+
gateway routes by `model`; dedicated deployments and serverless models share the
|
|
115
|
+
same endpoint. `reasoningEffort` is forwarded to the endpoint, and streaming
|
|
116
|
+
surfaces `content` and `reasoning_content` deltas incrementally.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const client = new BiOS({
|
|
120
|
+
inferenceKey: 'bios-platform-key-with-serverless-scope',
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
for await (const chunk of client.inference.streamChatCompletions({
|
|
124
|
+
model: 'meta-llama/Llama-3.1-8B-Instruct', // serverless catalog id
|
|
125
|
+
messages: [{ role: 'user', content: 'Explain tensor parallelism briefly.' }],
|
|
126
|
+
reasoningEffort: 'low',
|
|
127
|
+
})) {
|
|
128
|
+
const delta = (chunk.choices as any)?.[0]?.delta ?? {};
|
|
129
|
+
if (delta.reasoning_content) process.stdout.write(delta.reasoning_content);
|
|
130
|
+
if (delta.content) process.stdout.write(delta.content);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Non-streaming; the final chunk carries `usage` when the model reports it.
|
|
134
|
+
const completion = await client.inference.chatCompletions({
|
|
135
|
+
model: 'meta-llama/Llama-3.1-8B-Instruct',
|
|
136
|
+
messages: [{ role: 'user', content: 'One sentence on GPUs.' }],
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Streaming billing is charged server-side on completed usage; the SDK only needs
|
|
141
|
+
to request `usage` where the endpoint exposes it (no client change).
|
|
142
|
+
|
|
110
143
|
### Models
|
|
111
144
|
|
|
112
145
|
The catalog lists only models hosted on BiOS (the platform's own verified
|
|
@@ -24,6 +24,12 @@ export interface ChatCompletionParams extends Record<string, unknown> {
|
|
|
24
24
|
name: string;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Standardized reasoning effort. Forwarded to `/v1/chat/completions` as
|
|
29
|
+
* `reasoning_effort`. Use `'none'` to disable reasoning where the model
|
|
30
|
+
* allows it.
|
|
31
|
+
*/
|
|
32
|
+
reasoningEffort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'max';
|
|
27
33
|
inferenceKey?: string;
|
|
28
34
|
idempotencyKey?: string;
|
|
29
35
|
requestId?: string;
|
|
@@ -580,7 +580,7 @@ export class Inference {
|
|
|
580
580
|
// OpenAI-compatible key-scoped inference — `/v1/chat/completions`
|
|
581
581
|
// --------------------------------------------------------------------------
|
|
582
582
|
prepare(params, stream) {
|
|
583
|
-
const { messages, model, tools, toolChoice, inferenceKey, idempotencyKey, requestId, signal, ...extra } = params;
|
|
583
|
+
const { messages, model, tools, toolChoice, reasoningEffort, inferenceKey, idempotencyKey, requestId, signal, ...extra } = params;
|
|
584
584
|
const key = inferenceKey || this.key;
|
|
585
585
|
if (!key)
|
|
586
586
|
throw new Error('an inferenceKey is required');
|
|
@@ -591,6 +591,8 @@ export class Inference {
|
|
|
591
591
|
body.tools = tools;
|
|
592
592
|
if (toolChoice !== undefined)
|
|
593
593
|
body.tool_choice = toolChoice;
|
|
594
|
+
if (reasoningEffort !== undefined)
|
|
595
|
+
body.reasoning_effort = reasoningEffort;
|
|
594
596
|
validateChatRequest(body);
|
|
595
597
|
const headers = {
|
|
596
598
|
Authorization: `Bearer ${key}`,
|