apple-local-llm 0.0.2 → 1.0.0
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 +17 -4
- package/bin/fm-proxy +0 -0
- package/dist/client.d.ts +3 -1
- package/dist/client.js +2 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ Generate a response.
|
|
|
117
117
|
const result = await client.responses.create({
|
|
118
118
|
input: "Your prompt here",
|
|
119
119
|
model: "default", // Optional: model identifier
|
|
120
|
-
max_output_tokens:
|
|
120
|
+
max_output_tokens: 500, // Optional: limit response tokens
|
|
121
121
|
stream: false, // Optional
|
|
122
122
|
signal: abortController.signal, // Optional: AbortSignal
|
|
123
123
|
timeoutMs: 60000, // Optional: request timeout (ms)
|
|
@@ -236,6 +236,9 @@ fm-proxy "What is the capital of France?"
|
|
|
236
236
|
fm-proxy --stream "Tell me a story"
|
|
237
237
|
fm-proxy -s "Tell me a story"
|
|
238
238
|
|
|
239
|
+
# Limit output tokens
|
|
240
|
+
fm-proxy --max-tokens=50 "Count to 100"
|
|
241
|
+
|
|
239
242
|
# Start HTTP server
|
|
240
243
|
fm-proxy --serve
|
|
241
244
|
fm-proxy --serve --port=3000
|
|
@@ -282,14 +285,24 @@ curl http://127.0.0.1:8080/health
|
|
|
282
285
|
# Simple generation
|
|
283
286
|
curl -X POST http://127.0.0.1:8080/generate \
|
|
284
287
|
-H "Content-Type: application/json" \
|
|
285
|
-
-d '{"
|
|
288
|
+
-d '{"input": "What is 2+2?"}'
|
|
286
289
|
# Response: {"text":"2+2 equals 4."}
|
|
287
290
|
|
|
291
|
+
# With max_output_tokens
|
|
292
|
+
curl -X POST http://127.0.0.1:8080/generate \
|
|
293
|
+
-H "Content-Type: application/json" \
|
|
294
|
+
-d '{"input": "Count to 100", "max_output_tokens": 50}'
|
|
295
|
+
|
|
296
|
+
# With structured output (response_format)
|
|
297
|
+
curl -X POST http://127.0.0.1:8080/generate \
|
|
298
|
+
-H "Content-Type: application/json" \
|
|
299
|
+
-d '{"input": "List 3 colors", "response_format": {"type": "json_schema", "json_schema": {"name": "Colors", "schema": {"type": "object", "properties": {"colors": {"type": "array", "items": {"type": "string"}}}}}}}'
|
|
300
|
+
|
|
288
301
|
# With authentication
|
|
289
302
|
curl -X POST http://127.0.0.1:8080/generate \
|
|
290
303
|
-H "Content-Type: application/json" \
|
|
291
304
|
-H "Authorization: Bearer <token>" \
|
|
292
|
-
-d '{"
|
|
305
|
+
-d '{"input": "Hello"}'
|
|
293
306
|
```
|
|
294
307
|
|
|
295
308
|
#### Streaming (SSE)
|
|
@@ -299,7 +312,7 @@ Add `"stream": true` to get Server-Sent Events with OpenAI-compatible chunks:
|
|
|
299
312
|
```bash
|
|
300
313
|
curl -N -X POST http://127.0.0.1:8080/generate \
|
|
301
314
|
-H "Content-Type: application/json" \
|
|
302
|
-
-d '{"
|
|
315
|
+
-d '{"input": "Write a haiku", "stream": true}'
|
|
303
316
|
```
|
|
304
317
|
|
|
305
318
|
Response:
|
package/bin/fm-proxy
CHANGED
|
Binary file
|
package/dist/client.d.ts
CHANGED
|
@@ -93,11 +93,13 @@ export declare class AppleLocalLLMClient {
|
|
|
93
93
|
private checkCompatibility;
|
|
94
94
|
private getCapabilities;
|
|
95
95
|
private createResponse;
|
|
96
|
-
stream(params: Omit<ResponsesCreateParams, "stream">): AsyncGenerator<{
|
|
96
|
+
stream(params: Omit<ResponsesCreateParams, "stream" | "response_format">): AsyncGenerator<{
|
|
97
97
|
delta: string;
|
|
98
|
+
request_id: string;
|
|
98
99
|
} | {
|
|
99
100
|
done: true;
|
|
100
101
|
text: string;
|
|
102
|
+
request_id: string;
|
|
101
103
|
}, void, unknown>;
|
|
102
104
|
private cancelResponse;
|
|
103
105
|
shutdown(): Promise<void>;
|
package/dist/client.js
CHANGED
|
@@ -125,7 +125,6 @@ export class AppleLocalLLMClient {
|
|
|
125
125
|
input: params.input,
|
|
126
126
|
max_output_tokens: params.max_output_tokens,
|
|
127
127
|
stream: true,
|
|
128
|
-
response_format: params.response_format,
|
|
129
128
|
}, (event) => {
|
|
130
129
|
const result = event.result;
|
|
131
130
|
if (result?.delta) {
|
|
@@ -207,10 +206,10 @@ export class AppleLocalLLMClient {
|
|
|
207
206
|
}
|
|
208
207
|
const result = event.result;
|
|
209
208
|
if (result.event === "delta" && result.delta) {
|
|
210
|
-
yield { delta: result.delta };
|
|
209
|
+
yield { delta: result.delta, request_id: result.request_id };
|
|
211
210
|
}
|
|
212
211
|
else if (result.event === "done") {
|
|
213
|
-
yield { done: true, text: result.text ?? "" };
|
|
212
|
+
yield { done: true, text: result.text ?? "", request_id: result.request_id };
|
|
214
213
|
break;
|
|
215
214
|
}
|
|
216
215
|
else if (result.event === "error") {
|