@langinsight/ai-sdk 0.0.5 → 0.1.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 +5 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,25 +65,17 @@ for await (const chunk of result.textStream) {
|
|
|
65
65
|
|
|
66
66
|
### Feedback (score)
|
|
67
67
|
|
|
68
|
-
Trace ID
|
|
68
|
+
Trace ID は `handler.result` で取得し、その `output.id` を `score()` に渡してフィードバックを送信する。DB 永続化などは `onSuccess` コールバックでも行える。
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
|
-
let lastOutputTraceId: string | undefined;
|
|
72
|
-
|
|
73
71
|
const handler = new LangInsight.CallbackHandler({
|
|
74
72
|
...options,
|
|
75
|
-
onSuccess: (input, output) => {
|
|
76
|
-
lastOutputTraceId = output.id; // DB 永続化などもここで
|
|
77
|
-
},
|
|
78
73
|
});
|
|
79
74
|
|
|
80
|
-
// report() または onFinish
|
|
81
|
-
await handler.score({ traceId: lastOutputTraceId!, value: 1 }); // 👍
|
|
82
|
-
await handler.score({ traceId: lastOutputTraceId!, value: -1 }); // 👎
|
|
83
|
-
|
|
84
|
-
// または handler.result を使用
|
|
75
|
+
// report() または onFinish の後に
|
|
85
76
|
const { input, output } = await handler.result;
|
|
86
|
-
|
|
77
|
+
await handler.score({ traceId: output.id, value: 1 }); // 👍
|
|
78
|
+
await handler.score({ traceId: output.id, value: -1 }); // 👎
|
|
87
79
|
```
|
|
88
80
|
|
|
89
81
|
## Options
|
|
@@ -104,5 +96,5 @@ console.log("Input trace:", input.id, "Output trace:", output.id);
|
|
|
104
96
|
|
|
105
97
|
- **`report(result, { input })`** — Sends traces for a `generateText` result. Both input and output traces are passed to `onSuccess` on success.
|
|
106
98
|
- **`onFinish({ input })`** — Returns a function suitable for `streamText`'s `onFinish`. Sends traces when the stream finishes; both traces are passed to `onSuccess`.
|
|
107
|
-
- **`score({ traceId, value })`** — Submits feedback (1 = thumbs up, -1 = thumbs down) for the given trace. Use
|
|
99
|
+
- **`score({ traceId, value })`** — Submits feedback (1 = thumbs up, -1 = thumbs down) for the given trace. Use `(await handler.result).output.id` as `traceId`.
|
|
108
100
|
- **`result`** — A promise that resolves with `{ input: Trace, output: Trace }` when traces are sent successfully.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@langinsight/ai-sdk",
|
|
3
3
|
"module": "dist/index.js",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
|
-
"version": "0.0
|
|
5
|
+
"version": "0.1.0",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/bun": "1.3.8",
|
|
26
|
-
"ai": "^6.0.
|
|
26
|
+
"ai": "^6.0.78",
|
|
27
27
|
"tsup": "^8.5.1",
|
|
28
28
|
"typescript": "^5.9.3"
|
|
29
29
|
}
|