@meuecommerce/frete-adapter-node 0.14.0 → 0.15.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/dist/cjs/index.js +2 -1
- package/dist/cjs/openAIDimensionEstimator.js +3 -15
- package/dist/cjs/openAIResponsesAgentRunner.js +30 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/openAIDimensionEstimator.d.ts +10 -0
- package/dist/openAIDimensionEstimator.js +4 -16
- package/dist/openAIResponsesAgentRunner.d.ts +29 -0
- package/dist/openAIResponsesAgentRunner.js +29 -4
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createOpenAIBoxDistributor = exports.PgDimensionMemory = exports.DIMENSION_MEMORY_SCHEMA_SQL = exports.createOpenAIResponsesAgentRunner = exports.createOpenAIDimensionEstimator = exports.DIMENSION_PROMPT_VERSION = exports.EnvSecretStore = exports.InMemoryDimensionMemory = exports.InMemorySettingsStore = exports.createCorreiosLabelHttpClient = exports.createCorreiosHttpClient = void 0;
|
|
3
|
+
exports.createOpenAIBoxDistributor = exports.PgDimensionMemory = exports.DIMENSION_MEMORY_SCHEMA_SQL = exports.createOpenAIResponsesAgentRunner = exports.DEFAULT_IMAGE_DETAIL = exports.createOpenAIDimensionEstimator = exports.DIMENSION_PROMPT_VERSION = exports.EnvSecretStore = exports.InMemoryDimensionMemory = exports.InMemorySettingsStore = exports.createCorreiosLabelHttpClient = exports.createCorreiosHttpClient = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @meuecommerce/frete-adapter-node — Node implementations of @meuecommerce/frete ports.
|
|
6
6
|
*
|
|
@@ -21,6 +21,7 @@ var openAIDimensionEstimator_js_1 = require("./openAIDimensionEstimator.js");
|
|
|
21
21
|
Object.defineProperty(exports, "DIMENSION_PROMPT_VERSION", { enumerable: true, get: function () { return openAIDimensionEstimator_js_1.DIMENSION_PROMPT_VERSION; } });
|
|
22
22
|
Object.defineProperty(exports, "createOpenAIDimensionEstimator", { enumerable: true, get: function () { return openAIDimensionEstimator_js_1.createOpenAIDimensionEstimator; } });
|
|
23
23
|
var openAIResponsesAgentRunner_js_1 = require("./openAIResponsesAgentRunner.js");
|
|
24
|
+
Object.defineProperty(exports, "DEFAULT_IMAGE_DETAIL", { enumerable: true, get: function () { return openAIResponsesAgentRunner_js_1.DEFAULT_IMAGE_DETAIL; } });
|
|
24
25
|
Object.defineProperty(exports, "createOpenAIResponsesAgentRunner", { enumerable: true, get: function () { return openAIResponsesAgentRunner_js_1.createOpenAIResponsesAgentRunner; } });
|
|
25
26
|
var pgDimensionMemory_js_1 = require("./pgDimensionMemory.js");
|
|
26
27
|
Object.defineProperty(exports, "DIMENSION_MEMORY_SCHEMA_SQL", { enumerable: true, get: function () { return pgDimensionMemory_js_1.DIMENSION_MEMORY_SCHEMA_SQL; } });
|
|
@@ -80,19 +80,6 @@ function descreverProduto(p, i) {
|
|
|
80
80
|
.join("\n");
|
|
81
81
|
return `${linha}\n${contexto}`;
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Uma URL de foto só é aceita se for utilizável como está.
|
|
85
|
-
*
|
|
86
|
-
* `http(s)` e `data:` são o que a API aceita. Qualquer outra coisa — caminho
|
|
87
|
-
* relativo, `wix:image://`, string vazia — faria a requisição inteira ser
|
|
88
|
-
* rejeitada, e com ela os cinco produtos do lote, não só o da foto ruim.
|
|
89
|
-
* Descartar a foto e estimar pelo texto é sempre melhor que perder o lote.
|
|
90
|
-
*/
|
|
91
|
-
function fotoUtilizavel(url) {
|
|
92
|
-
if (!url)
|
|
93
|
-
return false;
|
|
94
|
-
return /^https?:\/\//i.test(url) || /^data:image\//i.test(url);
|
|
95
|
-
}
|
|
96
83
|
/**
|
|
97
84
|
* As fotos do lote, na ordem dos produtos, com o índice a que cada uma pertence.
|
|
98
85
|
*
|
|
@@ -106,7 +93,7 @@ function fotoUtilizavel(url) {
|
|
|
106
93
|
function fotosDoLote(products) {
|
|
107
94
|
return products
|
|
108
95
|
.map((p, i) => ({ indice: i + 1, url: p.imageUrl }))
|
|
109
|
-
.filter((f) =>
|
|
96
|
+
.filter((f) => (0, frete_1.usablePhotoUrl)(f.url));
|
|
110
97
|
}
|
|
111
98
|
/** A linha do prompt que amarra cada foto ao produto dela. */
|
|
112
99
|
function descreverFotos(fotos, total) {
|
|
@@ -199,7 +186,7 @@ function validateAndOptimize(aiResult, products, boxes) {
|
|
|
199
186
|
return { products: optimized };
|
|
200
187
|
}
|
|
201
188
|
function createOpenAIDimensionEstimator(options) {
|
|
202
|
-
const { apiKey, fetch, model = "gpt-4o-mini", temperature = 0.1, apiUrl, timeoutMs, runner } = options;
|
|
189
|
+
const { apiKey, fetch, model = "gpt-4o-mini", temperature = 0.1, apiUrl, timeoutMs, imageDetail, runner } = options;
|
|
203
190
|
const agent = runner ??
|
|
204
191
|
(0, openAIResponsesAgentRunner_js_1.createOpenAIResponsesAgentRunner)({
|
|
205
192
|
apiKey: apiKey ?? "",
|
|
@@ -207,6 +194,7 @@ function createOpenAIDimensionEstimator(options) {
|
|
|
207
194
|
model,
|
|
208
195
|
...(apiUrl ? { apiUrl } : {}),
|
|
209
196
|
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
197
|
+
...(imageDetail ? { imageDetail } : {}),
|
|
210
198
|
});
|
|
211
199
|
return {
|
|
212
200
|
async estimate(products, boxes, productSamples = []) {
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_IMAGE_DETAIL = void 0;
|
|
3
4
|
exports.extractOutputText = extractOutputText;
|
|
4
5
|
exports.findRefusal = findRefusal;
|
|
5
6
|
exports.createOpenAIResponsesAgentRunner = createOpenAIResponsesAgentRunner;
|
|
7
|
+
/**
|
|
8
|
+
* `low` de propósito, e é uma escolha de custo medida, não um palpite.
|
|
9
|
+
*
|
|
10
|
+
* No gpt-4o-mini a imagem é cobrada por ladrilho de 512px: 2.833 de base mais
|
|
11
|
+
* 5.667 por ladrilho. Uma foto de produto quadrada, que é o formato padrão da
|
|
12
|
+
* Wix, vira quatro ladrilhos — 25.501 tokens. Com `low` a conta é fixa em 2.833
|
|
13
|
+
* **independentemente do tamanho do original**, o que dá 9x menos na parte da
|
|
14
|
+
* imagem.
|
|
15
|
+
*
|
|
16
|
+
* Isso saiu de produção, não de estimativa: o primeiro lote com foto, em
|
|
17
|
+
* 2026-09-15, gastou 180.113 tokens de entrada para 7 produtos. A fórmula
|
|
18
|
+
* acima prevê 180.119.
|
|
19
|
+
*
|
|
20
|
+
* **O que ainda não foi medido é a qualidade.** Não existe dataset de eval com
|
|
21
|
+
* foto — o `amostras-lojistas.json` tem nome e dimensões digitadas pelo
|
|
22
|
+
* lojista, nada de imagem — então qual `detail` estima melhor é pergunta em
|
|
23
|
+
* aberto. Por isso isto é opção com padrão, e não constante: quando o dataset
|
|
24
|
+
* com foto existir, comparar os dois é trocar este argumento.
|
|
25
|
+
*/
|
|
26
|
+
exports.DEFAULT_IMAGE_DETAIL = "low";
|
|
6
27
|
/** The model's text, accepting both shapes the Responses API delivers it in. */
|
|
7
28
|
function extractOutputText(json) {
|
|
8
29
|
if (typeof json.output_text === "string" && json.output_text.trim())
|
|
@@ -31,7 +52,7 @@ function findRefusal(json) {
|
|
|
31
52
|
return null;
|
|
32
53
|
}
|
|
33
54
|
function createOpenAIResponsesAgentRunner(options) {
|
|
34
|
-
const { apiKey, fetch = globalThis.fetch, model: defaultModel = "gpt-4o-mini", apiUrl = "https://api.openai.com/v1/responses", timeoutMs = 20000, } = options;
|
|
55
|
+
const { apiKey, fetch = globalThis.fetch, model: defaultModel = "gpt-4o-mini", apiUrl = "https://api.openai.com/v1/responses", timeoutMs = 20000, imageDetail = exports.DEFAULT_IMAGE_DETAIL, } = options;
|
|
35
56
|
if (!apiKey)
|
|
36
57
|
throw new Error("createOpenAIResponsesAgentRunner: apiKey is required");
|
|
37
58
|
if (typeof fetch !== "function")
|
|
@@ -41,14 +62,19 @@ function createOpenAIResponsesAgentRunner(options) {
|
|
|
41
62
|
const input = [];
|
|
42
63
|
if (request.system)
|
|
43
64
|
input.push({ role: "system", content: request.system });
|
|
44
|
-
//
|
|
45
|
-
//
|
|
65
|
+
// Com imagem o turno do usuário vira lista em vez de string. O `detail`
|
|
66
|
+
// vai sempre explícito: omiti-lo é o que deixa a OpenAI escolher `high`,
|
|
67
|
+
// e essa omissão custou 9x na primeira passada em produção.
|
|
46
68
|
if (request.images?.length) {
|
|
47
69
|
input.push({
|
|
48
70
|
role: "user",
|
|
49
71
|
content: [
|
|
50
72
|
{ type: "input_text", text: request.user },
|
|
51
|
-
...request.images.map((url) => ({
|
|
73
|
+
...request.images.map((url) => ({
|
|
74
|
+
type: "input_image",
|
|
75
|
+
image_url: url,
|
|
76
|
+
detail: imageDetail,
|
|
77
|
+
})),
|
|
52
78
|
],
|
|
53
79
|
});
|
|
54
80
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,10 +14,10 @@ export { InMemoryDimensionMemory } from "./inMemoryDimensionMemory.js";
|
|
|
14
14
|
export { EnvSecretStore } from "./envSecretStore.js";
|
|
15
15
|
export type { EnvSecretStoreOptions } from "./envSecretStore.js";
|
|
16
16
|
export { DIMENSION_PROMPT_VERSION, createOpenAIDimensionEstimator } from "./openAIDimensionEstimator.js";
|
|
17
|
-
export { createOpenAIResponsesAgentRunner } from "./openAIResponsesAgentRunner.js";
|
|
17
|
+
export { DEFAULT_IMAGE_DETAIL, createOpenAIResponsesAgentRunner } from "./openAIResponsesAgentRunner.js";
|
|
18
18
|
export { DIMENSION_MEMORY_SCHEMA_SQL, PgDimensionMemory } from "./pgDimensionMemory.js";
|
|
19
19
|
export type { PgDimensionMemoryOptions, SqlClient } from "./pgDimensionMemory.js";
|
|
20
|
-
export type { OpenAIResponsesAgentRunnerOptions } from "./openAIResponsesAgentRunner.js";
|
|
20
|
+
export type { ImageDetail, OpenAIResponsesAgentRunnerOptions } from "./openAIResponsesAgentRunner.js";
|
|
21
21
|
export type { OpenAIDimensionEstimatorOptions } from "./openAIDimensionEstimator.js";
|
|
22
22
|
export { createOpenAIBoxDistributor } from "./openAIBoxDistributor.js";
|
|
23
23
|
export type { OpenAIBoxDistributorOptions } from "./openAIBoxDistributor.js";
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,6 @@ export { InMemorySettingsStore } from "./inMemorySettingsStore.js";
|
|
|
10
10
|
export { InMemoryDimensionMemory } from "./inMemoryDimensionMemory.js";
|
|
11
11
|
export { EnvSecretStore } from "./envSecretStore.js";
|
|
12
12
|
export { DIMENSION_PROMPT_VERSION, createOpenAIDimensionEstimator } from "./openAIDimensionEstimator.js";
|
|
13
|
-
export { createOpenAIResponsesAgentRunner } from "./openAIResponsesAgentRunner.js";
|
|
13
|
+
export { DEFAULT_IMAGE_DETAIL, createOpenAIResponsesAgentRunner } from "./openAIResponsesAgentRunner.js";
|
|
14
14
|
export { DIMENSION_MEMORY_SCHEMA_SQL, PgDimensionMemory } from "./pgDimensionMemory.js";
|
|
15
15
|
export { createOpenAIBoxDistributor } from "./openAIBoxDistributor.js";
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* (e.g. via a `SecretStore`), keeping secret handling out of this module.
|
|
20
20
|
*/
|
|
21
21
|
import type { LlmAgentRunner, ProductDimensionEstimator } from "@meuecommerce/frete";
|
|
22
|
+
import { type ImageDetail } from "./openAIResponsesAgentRunner.js";
|
|
22
23
|
type FetchLike = typeof globalThis.fetch;
|
|
23
24
|
/**
|
|
24
25
|
* Bump whenever the prompt or the schema changes. It is written next to every
|
|
@@ -33,6 +34,15 @@ export interface OpenAIDimensionEstimatorOptions {
|
|
|
33
34
|
temperature?: number;
|
|
34
35
|
apiUrl?: string;
|
|
35
36
|
timeoutMs?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Quanto da imagem o modelo olha. Omitido, vale o padrão do runner (`low`).
|
|
39
|
+
*
|
|
40
|
+
* Existe aqui, e não só no runner, para que comparar `low` contra `high` num
|
|
41
|
+
* eval seja trocar um argumento — que é como a pergunta em aberto sobre
|
|
42
|
+
* qualidade vai ser respondida quando houver dataset com foto. Não tem efeito
|
|
43
|
+
* nenhum sobre produto sem foto.
|
|
44
|
+
*/
|
|
45
|
+
imageDetail?: ImageDetail;
|
|
36
46
|
/**
|
|
37
47
|
* Run the call through an existing {@link LlmAgentRunner} instead of building
|
|
38
48
|
* one. Pass it to share a runner across use cases, or to substitute the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { productNameKey } from "@meuecommerce/frete";
|
|
1
|
+
import { productNameKey, usablePhotoUrl } from "@meuecommerce/frete";
|
|
2
2
|
import { createOpenAIResponsesAgentRunner } from "./openAIResponsesAgentRunner.js";
|
|
3
3
|
/**
|
|
4
4
|
* Bump whenever the prompt or the schema changes. It is written next to every
|
|
@@ -76,19 +76,6 @@ function descreverProduto(p, i) {
|
|
|
76
76
|
.join("\n");
|
|
77
77
|
return `${linha}\n${contexto}`;
|
|
78
78
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Uma URL de foto só é aceita se for utilizável como está.
|
|
81
|
-
*
|
|
82
|
-
* `http(s)` e `data:` são o que a API aceita. Qualquer outra coisa — caminho
|
|
83
|
-
* relativo, `wix:image://`, string vazia — faria a requisição inteira ser
|
|
84
|
-
* rejeitada, e com ela os cinco produtos do lote, não só o da foto ruim.
|
|
85
|
-
* Descartar a foto e estimar pelo texto é sempre melhor que perder o lote.
|
|
86
|
-
*/
|
|
87
|
-
function fotoUtilizavel(url) {
|
|
88
|
-
if (!url)
|
|
89
|
-
return false;
|
|
90
|
-
return /^https?:\/\//i.test(url) || /^data:image\//i.test(url);
|
|
91
|
-
}
|
|
92
79
|
/**
|
|
93
80
|
* As fotos do lote, na ordem dos produtos, com o índice a que cada uma pertence.
|
|
94
81
|
*
|
|
@@ -102,7 +89,7 @@ function fotoUtilizavel(url) {
|
|
|
102
89
|
function fotosDoLote(products) {
|
|
103
90
|
return products
|
|
104
91
|
.map((p, i) => ({ indice: i + 1, url: p.imageUrl }))
|
|
105
|
-
.filter((f) =>
|
|
92
|
+
.filter((f) => usablePhotoUrl(f.url));
|
|
106
93
|
}
|
|
107
94
|
/** A linha do prompt que amarra cada foto ao produto dela. */
|
|
108
95
|
function descreverFotos(fotos, total) {
|
|
@@ -195,7 +182,7 @@ function validateAndOptimize(aiResult, products, boxes) {
|
|
|
195
182
|
return { products: optimized };
|
|
196
183
|
}
|
|
197
184
|
export function createOpenAIDimensionEstimator(options) {
|
|
198
|
-
const { apiKey, fetch, model = "gpt-4o-mini", temperature = 0.1, apiUrl, timeoutMs, runner } = options;
|
|
185
|
+
const { apiKey, fetch, model = "gpt-4o-mini", temperature = 0.1, apiUrl, timeoutMs, imageDetail, runner } = options;
|
|
199
186
|
const agent = runner ??
|
|
200
187
|
createOpenAIResponsesAgentRunner({
|
|
201
188
|
apiKey: apiKey ?? "",
|
|
@@ -203,6 +190,7 @@ export function createOpenAIDimensionEstimator(options) {
|
|
|
203
190
|
model,
|
|
204
191
|
...(apiUrl ? { apiUrl } : {}),
|
|
205
192
|
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
193
|
+
...(imageDetail ? { imageDetail } : {}),
|
|
206
194
|
});
|
|
207
195
|
return {
|
|
208
196
|
async estimate(products, boxes, productSamples = []) {
|
|
@@ -12,12 +12,41 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { LlmAgentRunner } from "@meuecommerce/frete";
|
|
14
14
|
type FetchLike = typeof globalThis.fetch;
|
|
15
|
+
/**
|
|
16
|
+
* Quanto da imagem o modelo olha. Ver {@link DEFAULT_IMAGE_DETAIL}.
|
|
17
|
+
*
|
|
18
|
+
* `auto` é o padrão da OpenAI quando o campo não vai, e para foto de produto
|
|
19
|
+
* ele resolve como `high` — foi assim que o custo apareceu em produção.
|
|
20
|
+
*/
|
|
21
|
+
export type ImageDetail = "low" | "high" | "auto";
|
|
22
|
+
/**
|
|
23
|
+
* `low` de propósito, e é uma escolha de custo medida, não um palpite.
|
|
24
|
+
*
|
|
25
|
+
* No gpt-4o-mini a imagem é cobrada por ladrilho de 512px: 2.833 de base mais
|
|
26
|
+
* 5.667 por ladrilho. Uma foto de produto quadrada, que é o formato padrão da
|
|
27
|
+
* Wix, vira quatro ladrilhos — 25.501 tokens. Com `low` a conta é fixa em 2.833
|
|
28
|
+
* **independentemente do tamanho do original**, o que dá 9x menos na parte da
|
|
29
|
+
* imagem.
|
|
30
|
+
*
|
|
31
|
+
* Isso saiu de produção, não de estimativa: o primeiro lote com foto, em
|
|
32
|
+
* 2026-09-15, gastou 180.113 tokens de entrada para 7 produtos. A fórmula
|
|
33
|
+
* acima prevê 180.119.
|
|
34
|
+
*
|
|
35
|
+
* **O que ainda não foi medido é a qualidade.** Não existe dataset de eval com
|
|
36
|
+
* foto — o `amostras-lojistas.json` tem nome e dimensões digitadas pelo
|
|
37
|
+
* lojista, nada de imagem — então qual `detail` estima melhor é pergunta em
|
|
38
|
+
* aberto. Por isso isto é opção com padrão, e não constante: quando o dataset
|
|
39
|
+
* com foto existir, comparar os dois é trocar este argumento.
|
|
40
|
+
*/
|
|
41
|
+
export declare const DEFAULT_IMAGE_DETAIL: ImageDetail;
|
|
15
42
|
export interface OpenAIResponsesAgentRunnerOptions {
|
|
16
43
|
apiKey: string;
|
|
17
44
|
fetch?: FetchLike;
|
|
18
45
|
model?: string;
|
|
19
46
|
apiUrl?: string;
|
|
20
47
|
timeoutMs?: number;
|
|
48
|
+
/** Ver {@link DEFAULT_IMAGE_DETAIL}. */
|
|
49
|
+
imageDetail?: ImageDetail;
|
|
21
50
|
}
|
|
22
51
|
interface ResponsesPayload {
|
|
23
52
|
error?: {
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `low` de propósito, e é uma escolha de custo medida, não um palpite.
|
|
3
|
+
*
|
|
4
|
+
* No gpt-4o-mini a imagem é cobrada por ladrilho de 512px: 2.833 de base mais
|
|
5
|
+
* 5.667 por ladrilho. Uma foto de produto quadrada, que é o formato padrão da
|
|
6
|
+
* Wix, vira quatro ladrilhos — 25.501 tokens. Com `low` a conta é fixa em 2.833
|
|
7
|
+
* **independentemente do tamanho do original**, o que dá 9x menos na parte da
|
|
8
|
+
* imagem.
|
|
9
|
+
*
|
|
10
|
+
* Isso saiu de produção, não de estimativa: o primeiro lote com foto, em
|
|
11
|
+
* 2026-09-15, gastou 180.113 tokens de entrada para 7 produtos. A fórmula
|
|
12
|
+
* acima prevê 180.119.
|
|
13
|
+
*
|
|
14
|
+
* **O que ainda não foi medido é a qualidade.** Não existe dataset de eval com
|
|
15
|
+
* foto — o `amostras-lojistas.json` tem nome e dimensões digitadas pelo
|
|
16
|
+
* lojista, nada de imagem — então qual `detail` estima melhor é pergunta em
|
|
17
|
+
* aberto. Por isso isto é opção com padrão, e não constante: quando o dataset
|
|
18
|
+
* com foto existir, comparar os dois é trocar este argumento.
|
|
19
|
+
*/
|
|
20
|
+
export const DEFAULT_IMAGE_DETAIL = "low";
|
|
1
21
|
/** The model's text, accepting both shapes the Responses API delivers it in. */
|
|
2
22
|
export function extractOutputText(json) {
|
|
3
23
|
if (typeof json.output_text === "string" && json.output_text.trim())
|
|
@@ -26,7 +46,7 @@ export function findRefusal(json) {
|
|
|
26
46
|
return null;
|
|
27
47
|
}
|
|
28
48
|
export function createOpenAIResponsesAgentRunner(options) {
|
|
29
|
-
const { apiKey, fetch = globalThis.fetch, model: defaultModel = "gpt-4o-mini", apiUrl = "https://api.openai.com/v1/responses", timeoutMs = 20000, } = options;
|
|
49
|
+
const { apiKey, fetch = globalThis.fetch, model: defaultModel = "gpt-4o-mini", apiUrl = "https://api.openai.com/v1/responses", timeoutMs = 20000, imageDetail = DEFAULT_IMAGE_DETAIL, } = options;
|
|
30
50
|
if (!apiKey)
|
|
31
51
|
throw new Error("createOpenAIResponsesAgentRunner: apiKey is required");
|
|
32
52
|
if (typeof fetch !== "function")
|
|
@@ -36,14 +56,19 @@ export function createOpenAIResponsesAgentRunner(options) {
|
|
|
36
56
|
const input = [];
|
|
37
57
|
if (request.system)
|
|
38
58
|
input.push({ role: "system", content: request.system });
|
|
39
|
-
//
|
|
40
|
-
//
|
|
59
|
+
// Com imagem o turno do usuário vira lista em vez de string. O `detail`
|
|
60
|
+
// vai sempre explícito: omiti-lo é o que deixa a OpenAI escolher `high`,
|
|
61
|
+
// e essa omissão custou 9x na primeira passada em produção.
|
|
41
62
|
if (request.images?.length) {
|
|
42
63
|
input.push({
|
|
43
64
|
role: "user",
|
|
44
65
|
content: [
|
|
45
66
|
{ type: "input_text", text: request.user },
|
|
46
|
-
...request.images.map((url) => ({
|
|
67
|
+
...request.images.map((url) => ({
|
|
68
|
+
type: "input_image",
|
|
69
|
+
image_url: url,
|
|
70
|
+
detail: imageDetail,
|
|
71
|
+
})),
|
|
47
72
|
],
|
|
48
73
|
});
|
|
49
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meuecommerce/frete-adapter-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Node implementation of @meuecommerce/frete ports (Correios HTTP client) using global fetch. Used by the Shopify/Fly deployment and the MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@meuecommerce/frete": "^0.
|
|
34
|
+
"@meuecommerce/frete": "^0.15.0"
|
|
35
35
|
},
|
|
36
36
|
"module": "./dist/index.js",
|
|
37
37
|
"repository": {
|