@effect-uai/responses 0.17.0 → 0.19.0-dev-20261109183959
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 +4 -4
- package/dist/OpenAIDeepResearch.d.mts +1 -1
- package/dist/OpenAIDeepResearch.mjs +2 -2
- package/dist/OpenAIDeepResearch.mjs.map +1 -1
- package/dist/OpenAIEmbedding.d.mts +1 -1
- package/dist/OpenAIEmbedding.mjs +2 -2
- package/dist/OpenAIEmbedding.mjs.map +1 -1
- package/dist/Responses.d.mts +1 -1
- package/dist/Responses.mjs +2 -2
- package/dist/Responses.mjs.map +1 -1
- package/dist/ResponsesTools.mjs +1 -1
- package/dist/codec.d.mts.map +1 -1
- package/dist/codec.mjs +27 -4
- package/dist/codec.mjs.map +1 -1
- package/dist/codec.test.mjs +56 -1
- package/dist/codec.test.mjs.map +1 -1
- package/dist/dist-DHer1cql.mjs +1533 -0
- package/dist/dist-DHer1cql.mjs.map +1 -0
- package/dist/{test.DNmyFkvJ-N3QqMRwZ.mjs → index.C4tKZ0yW-xEu55bU4.mjs} +8276 -7092
- package/dist/index.C4tKZ0yW-xEu55bU4.mjs.map +1 -0
- package/dist/region.test.mjs +1 -1
- package/dist/responsesTools.test.mjs +1 -1
- package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-EAsCxrDo.mjs} +2 -1
- package/dist/streamEvents.mjs +1 -1
- package/package.json +5 -5
- package/src/OpenAIDeepResearch.ts +1 -1
- package/src/OpenAIEmbedding.ts +1 -1
- package/src/Responses.ts +1 -1
- package/src/codec.test.ts +53 -0
- package/src/codec.ts +39 -4
- package/dist/magic-string.es-CUAnjKYC.mjs +0 -1014
- package/dist/magic-string.es-CUAnjKYC.mjs.map +0 -1
- package/dist/test.DNmyFkvJ-N3QqMRwZ.mjs.map +0 -1
package/dist/codec.test.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { itemsToInput, wireItemToItem } from "./codec.mjs";
|
|
2
|
-
import { n as describe, r as it, t as globalExpect } from "./
|
|
2
|
+
import { n as describe, r as it, t as globalExpect } from "./index.C4tKZ0yW-xEu55bU4.mjs";
|
|
3
|
+
import { fileBase64, fileUrl } from "@effect-uai/core/File";
|
|
4
|
+
import { imageBytes } from "@effect-uai/core/Image";
|
|
5
|
+
import * as Items from "@effect-uai/core/Items";
|
|
3
6
|
//#region src/codec.test.ts
|
|
4
7
|
describe("providerData round-trip", () => {
|
|
5
8
|
it("re-emits a stashed item verbatim, preserving fields our shape drops", () => {
|
|
@@ -88,6 +91,58 @@ describe("providerData is a shared slot", () => {
|
|
|
88
91
|
}]);
|
|
89
92
|
});
|
|
90
93
|
});
|
|
94
|
+
describe("tool output", () => {
|
|
95
|
+
const output = (parts, isError) => itemsToInput([{
|
|
96
|
+
type: "function_call_output",
|
|
97
|
+
call_id: "c1",
|
|
98
|
+
output: parts,
|
|
99
|
+
...isError !== void 0 && { isError }
|
|
100
|
+
}]);
|
|
101
|
+
it("sends text and JSON as one string, JSON serialized once", () => {
|
|
102
|
+
globalExpect(output([Items.text("found 2"), Items.json({
|
|
103
|
+
hits: [1, 2],
|
|
104
|
+
note: "a \"quote\""
|
|
105
|
+
})], true)).toEqual([{
|
|
106
|
+
type: "function_call_output",
|
|
107
|
+
call_id: "c1",
|
|
108
|
+
output: "found 2\n{\"hits\":[1,2],\"note\":\"a \\\"quote\\\"\"}"
|
|
109
|
+
}]);
|
|
110
|
+
});
|
|
111
|
+
it("sends media as native parts: images as image_url, files as file_data or file_url", () => {
|
|
112
|
+
globalExpect(output([
|
|
113
|
+
Items.json({ title: "Home" }),
|
|
114
|
+
Items.image(imageBytes(new Uint8Array([
|
|
115
|
+
1,
|
|
116
|
+
2,
|
|
117
|
+
3
|
|
118
|
+
]), "image/png")),
|
|
119
|
+
Items.file(fileBase64("JVBE", "application/pdf"), "report.pdf"),
|
|
120
|
+
Items.file(fileUrl("https://x/a.pdf"))
|
|
121
|
+
])).toEqual([{
|
|
122
|
+
type: "function_call_output",
|
|
123
|
+
call_id: "c1",
|
|
124
|
+
output: [
|
|
125
|
+
{
|
|
126
|
+
type: "input_text",
|
|
127
|
+
text: "{\"title\":\"Home\"}"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: "input_image",
|
|
131
|
+
image_url: "data:image/png;base64,AQID"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "input_file",
|
|
135
|
+
file_data: "data:application/pdf;base64,JVBE",
|
|
136
|
+
filename: "report.pdf"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: "input_file",
|
|
140
|
+
file_url: "https://x/a.pdf"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}]);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
91
146
|
//#endregion
|
|
92
147
|
export {};
|
|
93
148
|
|
package/dist/codec.test.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.test.mjs","names":[],"sources":["../src/codec.test.ts"],"sourcesContent":["import type { HistoryItem } from \"@effect-uai/core/Items\"\nimport { describe, expect, it } from \"vitest\"\nimport { itemsToInput, wireItemToItem } from \"./codec.js\"\n\ndescribe(\"providerData round-trip\", () => {\n it(\"re-emits a stashed item verbatim, preserving fields our shape drops\", () => {\n // `id` and `encrypted_content` cannot be reconstructed from a Reasoning\n // item, so the round-trip has to go through the stash.\n const items = wireItemToItem({\n type: \"reasoning\",\n id: \"rs_1\",\n encrypted_content: \"opaque-state\",\n })\n expect(itemsToInput(items)).toEqual([\n { type: \"reasoning\", id: \"rs_1\", encrypted_content: \"opaque-state\" },\n ])\n })\n})\n\ndescribe(\"providerData is a shared slot\", () => {\n // Regression: the passthrough used to re-emit the whole `providerData`\n // object as the wire item. An item that had been through another provider\n // first was sent as that provider's data, losing the real content.\n it(\"ignores another provider's data and encodes the item normally\", () => {\n const history: ReadonlyArray<HistoryItem> = [\n {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text: \"hello world\" }],\n providerData: { gemini: { thoughtSignature: \"sig-abc\" } },\n },\n ]\n expect(itemsToInput(history)).toEqual([\n { type: \"message\", role: \"user\", content: [{ type: \"input_text\", text: \"hello world\" }] },\n ])\n })\n\n it(\"does not send a foreign function_call as junk\", () => {\n const history: ReadonlyArray<HistoryItem> = [\n {\n type: \"function_call\",\n call_id: \"c1\",\n name: \"get_weather\",\n arguments: '{\"city\":\"Lisbon\"}',\n providerData: { gemini: { id: \"g1\", thoughtSignature: \"sig-abc\" } },\n },\n ]\n expect(itemsToInput(history)).toEqual([\n {\n type: \"function_call\",\n call_id: \"c1\",\n name: \"get_weather\",\n arguments: '{\"city\":\"Lisbon\"}',\n },\n ])\n })\n\n it(\"re-emits only our key when an item carries several providers' data\", () => {\n const history: ReadonlyArray<HistoryItem> = [\n {\n type: \"reasoning\",\n signature: \"opaque-state\",\n providerData: {\n responses: { type: \"reasoning\", id: \"rs_1\", encrypted_content: \"opaque-state\" },\n gemini: { thoughtSignature: \"sig-abc\" },\n },\n },\n ]\n expect(itemsToInput(history)).toEqual([\n { type: \"reasoning\", id: \"rs_1\", encrypted_content: \"opaque-state\" },\n ])\n })\n\n it(\"falls back to a normal encode when the stashed value is not one of ours\", () => {\n const history: ReadonlyArray<HistoryItem> = [\n {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text: \"hi\" }],\n providerData: { responses: { type: \"not_an_item_we_model\" } },\n },\n ]\n expect(itemsToInput(history)).toEqual([\n { type: \"message\", role: \"user\", content: [{ type: \"input_text\", text: \"hi\" }] },\n ])\n })\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codec.test.mjs","names":[],"sources":["../src/codec.test.ts"],"sourcesContent":["import { fileBase64, fileUrl } from \"@effect-uai/core/File\"\nimport { imageBytes } from \"@effect-uai/core/Image\"\nimport * as Items from \"@effect-uai/core/Items\"\nimport type { HistoryItem } from \"@effect-uai/core/Items\"\nimport { describe, expect, it } from \"vitest\"\nimport { itemsToInput, wireItemToItem } from \"./codec.js\"\n\ndescribe(\"providerData round-trip\", () => {\n it(\"re-emits a stashed item verbatim, preserving fields our shape drops\", () => {\n // `id` and `encrypted_content` cannot be reconstructed from a Reasoning\n // item, so the round-trip has to go through the stash.\n const items = wireItemToItem({\n type: \"reasoning\",\n id: \"rs_1\",\n encrypted_content: \"opaque-state\",\n })\n expect(itemsToInput(items)).toEqual([\n { type: \"reasoning\", id: \"rs_1\", encrypted_content: \"opaque-state\" },\n ])\n })\n})\n\ndescribe(\"providerData is a shared slot\", () => {\n // Regression: the passthrough used to re-emit the whole `providerData`\n // object as the wire item. An item that had been through another provider\n // first was sent as that provider's data, losing the real content.\n it(\"ignores another provider's data and encodes the item normally\", () => {\n const history: ReadonlyArray<HistoryItem> = [\n {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text: \"hello world\" }],\n providerData: { gemini: { thoughtSignature: \"sig-abc\" } },\n },\n ]\n expect(itemsToInput(history)).toEqual([\n { type: \"message\", role: \"user\", content: [{ type: \"input_text\", text: \"hello world\" }] },\n ])\n })\n\n it(\"does not send a foreign function_call as junk\", () => {\n const history: ReadonlyArray<HistoryItem> = [\n {\n type: \"function_call\",\n call_id: \"c1\",\n name: \"get_weather\",\n arguments: '{\"city\":\"Lisbon\"}',\n providerData: { gemini: { id: \"g1\", thoughtSignature: \"sig-abc\" } },\n },\n ]\n expect(itemsToInput(history)).toEqual([\n {\n type: \"function_call\",\n call_id: \"c1\",\n name: \"get_weather\",\n arguments: '{\"city\":\"Lisbon\"}',\n },\n ])\n })\n\n it(\"re-emits only our key when an item carries several providers' data\", () => {\n const history: ReadonlyArray<HistoryItem> = [\n {\n type: \"reasoning\",\n signature: \"opaque-state\",\n providerData: {\n responses: { type: \"reasoning\", id: \"rs_1\", encrypted_content: \"opaque-state\" },\n gemini: { thoughtSignature: \"sig-abc\" },\n },\n },\n ]\n expect(itemsToInput(history)).toEqual([\n { type: \"reasoning\", id: \"rs_1\", encrypted_content: \"opaque-state\" },\n ])\n })\n\n it(\"falls back to a normal encode when the stashed value is not one of ours\", () => {\n const history: ReadonlyArray<HistoryItem> = [\n {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text: \"hi\" }],\n providerData: { responses: { type: \"not_an_item_we_model\" } },\n },\n ]\n expect(itemsToInput(history)).toEqual([\n { type: \"message\", role: \"user\", content: [{ type: \"input_text\", text: \"hi\" }] },\n ])\n })\n})\n\ndescribe(\"tool output\", () => {\n const output = (parts: Items.ToolCallOutput[\"output\"], isError?: boolean) =>\n itemsToInput([\n {\n type: \"function_call_output\",\n call_id: \"c1\",\n output: parts,\n ...(isError !== undefined && { isError }),\n },\n ])\n\n it(\"sends text and JSON as one string, JSON serialized once\", () => {\n expect(\n output([Items.text(\"found 2\"), Items.json({ hits: [1, 2], note: 'a \"quote\"' })], true),\n ).toEqual([\n {\n type: \"function_call_output\",\n call_id: \"c1\",\n output: 'found 2\\n{\"hits\":[1,2],\"note\":\"a \\\\\"quote\\\\\"\"}',\n },\n ])\n })\n\n it(\"sends media as native parts: images as image_url, files as file_data or file_url\", () => {\n expect(\n output([\n Items.json({ title: \"Home\" }),\n Items.image(imageBytes(new Uint8Array([1, 2, 3]), \"image/png\")),\n Items.file(fileBase64(\"JVBE\", \"application/pdf\"), \"report.pdf\"),\n Items.file(fileUrl(\"https://x/a.pdf\")),\n ]),\n ).toEqual([\n {\n type: \"function_call_output\",\n call_id: \"c1\",\n output: [\n { type: \"input_text\", text: '{\"title\":\"Home\"}' },\n { type: \"input_image\", image_url: \"data:image/png;base64,AQID\" },\n {\n type: \"input_file\",\n file_data: \"data:application/pdf;base64,JVBE\",\n filename: \"report.pdf\",\n },\n { type: \"input_file\", file_url: \"https://x/a.pdf\" },\n ],\n },\n ])\n })\n})\n"],"mappings":";;;;;;AAOA,SAAS,iCAAiC;CACxC,GAAG,6EAA6E;EAG9E,MAAM,QAAQ,eAAe;GAC3B,MAAM;GACN,IAAI;GACJ,mBAAm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