@midscene/core 1.12.8 → 1.12.9-beta-20260917120835.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/es/agent/utils.mjs +1 -1
- package/dist/es/ai-model/service-caller/call-ai.mjs +151 -40
- package/dist/es/ai-model/service-caller/call-ai.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/codex/call-codex.mjs +26 -14
- package/dist/es/ai-model/service-caller/codex/call-codex.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/codex/codex-app-server.mjs +12 -16
- package/dist/es/ai-model/service-caller/codex/codex-app-server.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/index.mjs +3 -3
- package/dist/es/ai-model/service-caller/model-call.mjs +49 -0
- package/dist/es/ai-model/service-caller/model-call.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/openai/call-openai.mjs +69 -0
- package/dist/es/ai-model/service-caller/openai/call-openai.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/openai/chat-completion/chat-completion.mjs +50 -0
- package/dist/es/ai-model/service-caller/openai/chat-completion/chat-completion.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/openai/chat-completion/non-stream.mjs +37 -0
- package/dist/es/ai-model/service-caller/openai/chat-completion/non-stream.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/openai/chat-completion/stream.mjs +78 -0
- package/dist/es/ai-model/service-caller/openai/chat-completion/stream.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/openai/chat-completion/utils.mjs +15 -0
- package/dist/es/ai-model/service-caller/openai/chat-completion/utils.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/{openai-client.mjs → openai/openai-client.mjs} +9 -21
- package/dist/es/ai-model/service-caller/openai/openai-client.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/{openai-error.mjs → openai/openai-request-context.mjs} +14 -46
- package/dist/es/ai-model/service-caller/openai/openai-request-context.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/proxy/index.mjs +2 -0
- package/dist/es/ai-model/service-caller/proxy/proxy-deps.node.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/proxy/proxy-deps.stub.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/{proxy.mjs → proxy/proxy.mjs} +2 -2
- package/dist/es/ai-model/service-caller/proxy/proxy.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/request-timeout.mjs +59 -18
- package/dist/es/ai-model/service-caller/request-timeout.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/semantic-retry.mjs +9 -4
- package/dist/es/ai-model/service-caller/semantic-retry.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/utils.mjs +25 -8
- package/dist/es/ai-model/service-caller/utils.mjs.map +1 -1
- package/dist/es/device/index.mjs +44 -21
- package/dist/es/device/index.mjs.map +1 -1
- package/dist/es/report-html-template.mjs +1 -1
- package/dist/es/types.mjs.map +1 -1
- package/dist/es/utils.mjs +1 -1
- package/dist/lib/agent/utils.js +1 -1
- package/dist/lib/ai-model/service-caller/call-ai.js +151 -46
- package/dist/lib/ai-model/service-caller/call-ai.js.map +1 -1
- package/dist/lib/ai-model/service-caller/codex/call-codex.js +30 -15
- package/dist/lib/ai-model/service-caller/codex/call-codex.js.map +1 -1
- package/dist/lib/ai-model/service-caller/codex/codex-app-server.js +12 -16
- package/dist/lib/ai-model/service-caller/codex/codex-app-server.js.map +1 -1
- package/dist/lib/ai-model/service-caller/index.js +7 -7
- package/dist/lib/ai-model/service-caller/model-call.js +89 -0
- package/dist/lib/ai-model/service-caller/model-call.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/call-openai.js +103 -0
- package/dist/lib/ai-model/service-caller/openai/call-openai.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/chat-completion/chat-completion.js +87 -0
- package/dist/lib/ai-model/service-caller/openai/chat-completion/chat-completion.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/chat-completion/non-stream.js +71 -0
- package/dist/lib/ai-model/service-caller/openai/chat-completion/non-stream.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/chat-completion/stream.js +112 -0
- package/dist/lib/ai-model/service-caller/openai/chat-completion/stream.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/chat-completion/types.js.map +1 -0
- package/dist/lib/ai-model/service-caller/{chat-completion → openai/chat-completion}/utils.js +3 -29
- package/dist/lib/ai-model/service-caller/openai/chat-completion/utils.js.map +1 -0
- package/dist/lib/ai-model/service-caller/{openai-client.js → openai/openai-client.js} +9 -21
- package/dist/lib/ai-model/service-caller/openai/openai-client.js.map +1 -0
- package/dist/lib/ai-model/service-caller/{openai-error.js → openai/openai-request-context.js} +14 -46
- package/dist/lib/ai-model/service-caller/openai/openai-request-context.js.map +1 -0
- package/dist/lib/ai-model/service-caller/proxy/index.js +38 -0
- package/dist/lib/ai-model/service-caller/proxy/index.js.map +1 -0
- package/dist/lib/ai-model/service-caller/proxy/proxy-deps.node.js.map +1 -0
- package/dist/lib/ai-model/service-caller/proxy/proxy-deps.stub.js.map +1 -0
- package/dist/lib/ai-model/service-caller/{proxy.js → proxy/proxy.js} +4 -4
- package/dist/lib/ai-model/service-caller/proxy/proxy.js.map +1 -0
- package/dist/lib/ai-model/service-caller/request-timeout.js +67 -20
- package/dist/lib/ai-model/service-caller/request-timeout.js.map +1 -1
- package/dist/lib/ai-model/service-caller/semantic-retry.js +9 -4
- package/dist/lib/ai-model/service-caller/semantic-retry.js.map +1 -1
- package/dist/lib/ai-model/service-caller/utils.js +30 -13
- package/dist/lib/ai-model/service-caller/utils.js.map +1 -1
- package/dist/lib/device/index.js +56 -21
- package/dist/lib/device/index.js.map +1 -1
- package/dist/lib/report-html-template.js +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/types/ai-model/service-caller/call-ai.d.ts +2 -24
- package/dist/types/ai-model/service-caller/codex/call-codex.d.ts +7 -1
- package/dist/types/ai-model/service-caller/codex/codex-app-server.d.ts +1 -2
- package/dist/types/ai-model/service-caller/index.d.ts +3 -3
- package/dist/types/ai-model/service-caller/model-call.d.ts +26 -0
- package/dist/types/ai-model/service-caller/openai/call-openai.d.ts +3 -0
- package/dist/types/ai-model/service-caller/openai/chat-completion/chat-completion.d.ts +10 -0
- package/dist/types/ai-model/service-caller/openai/chat-completion/non-stream.d.ts +3 -0
- package/dist/types/ai-model/service-caller/openai/chat-completion/stream.d.ts +3 -0
- package/dist/types/ai-model/service-caller/openai/chat-completion/types.d.ts +10 -0
- package/dist/types/ai-model/service-caller/openai/chat-completion/utils.d.ts +5 -0
- package/dist/types/ai-model/service-caller/openai/openai-client.d.ts +14 -0
- package/dist/types/ai-model/service-caller/openai/openai-request-context.d.ts +18 -0
- package/dist/types/ai-model/service-caller/proxy/index.d.ts +1 -0
- package/dist/types/ai-model/service-caller/{proxy.d.ts → proxy/proxy.d.ts} +1 -1
- package/dist/types/ai-model/service-caller/request-timeout.d.ts +14 -11
- package/dist/types/ai-model/service-caller/types.d.ts +19 -0
- package/dist/types/ai-model/service-caller/utils.d.ts +10 -4
- package/dist/types/device/index.d.ts +28 -6
- package/dist/types/types.d.ts +5 -0
- package/package.json +6 -6
- package/dist/es/ai-model/service-caller/call.mjs +0 -56
- package/dist/es/ai-model/service-caller/call.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/chat-completion/call.mjs +0 -101
- package/dist/es/ai-model/service-caller/chat-completion/call.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/chat-completion/non-stream.mjs +0 -80
- package/dist/es/ai-model/service-caller/chat-completion/non-stream.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/chat-completion/stream.mjs +0 -87
- package/dist/es/ai-model/service-caller/chat-completion/stream.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/chat-completion/utils.mjs +0 -35
- package/dist/es/ai-model/service-caller/chat-completion/utils.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/openai-client.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/openai-error.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/proxy-deps.node.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/proxy-deps.stub.mjs.map +0 -1
- package/dist/es/ai-model/service-caller/proxy.mjs.map +0 -1
- package/dist/lib/ai-model/service-caller/call.js +0 -90
- package/dist/lib/ai-model/service-caller/call.js.map +0 -1
- package/dist/lib/ai-model/service-caller/chat-completion/call.js +0 -135
- package/dist/lib/ai-model/service-caller/chat-completion/call.js.map +0 -1
- package/dist/lib/ai-model/service-caller/chat-completion/non-stream.js +0 -114
- package/dist/lib/ai-model/service-caller/chat-completion/non-stream.js.map +0 -1
- package/dist/lib/ai-model/service-caller/chat-completion/stream.js +0 -121
- package/dist/lib/ai-model/service-caller/chat-completion/stream.js.map +0 -1
- package/dist/lib/ai-model/service-caller/chat-completion/types.js.map +0 -1
- package/dist/lib/ai-model/service-caller/chat-completion/utils.js.map +0 -1
- package/dist/lib/ai-model/service-caller/openai-client.js.map +0 -1
- package/dist/lib/ai-model/service-caller/openai-error.js.map +0 -1
- package/dist/lib/ai-model/service-caller/proxy-deps.node.js.map +0 -1
- package/dist/lib/ai-model/service-caller/proxy-deps.stub.js.map +0 -1
- package/dist/lib/ai-model/service-caller/proxy.js.map +0 -1
- package/dist/types/ai-model/service-caller/call.d.ts +0 -4
- package/dist/types/ai-model/service-caller/chat-completion/call.d.ts +0 -2
- package/dist/types/ai-model/service-caller/chat-completion/non-stream.d.ts +0 -2
- package/dist/types/ai-model/service-caller/chat-completion/stream.d.ts +0 -2
- package/dist/types/ai-model/service-caller/chat-completion/types.d.ts +0 -25
- package/dist/types/ai-model/service-caller/chat-completion/utils.d.ts +0 -12
- package/dist/types/ai-model/service-caller/openai-client.d.ts +0 -14
- package/dist/types/ai-model/service-caller/openai-error.d.ts +0 -26
- /package/dist/es/ai-model/service-caller/{chat-completion → openai/chat-completion}/types.mjs +0 -0
- /package/dist/es/ai-model/service-caller/{proxy-deps.node.mjs → proxy/proxy-deps.node.mjs} +0 -0
- /package/dist/es/ai-model/service-caller/{proxy-deps.stub.mjs → proxy/proxy-deps.stub.mjs} +0 -0
- /package/dist/lib/ai-model/service-caller/{chat-completion → openai/chat-completion}/types.js +0 -0
- /package/dist/lib/ai-model/service-caller/{proxy-deps.node.js → proxy/proxy-deps.node.js} +0 -0
- /package/dist/lib/ai-model/service-caller/{proxy-deps.stub.js → proxy/proxy-deps.stub.js} +0 -0
- /package/dist/types/ai-model/service-caller/{proxy-deps.node.d.ts → proxy/proxy-deps.node.d.ts} +0 -0
- /package/dist/types/ai-model/service-caller/{proxy-deps.stub.d.ts → proxy/proxy-deps.stub.d.ts} +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
callChatCompletion: ()=>callChatCompletion,
|
|
28
|
+
prepareChatCompletion: ()=>prepareChatCompletion
|
|
29
|
+
});
|
|
30
|
+
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
31
|
+
const index_js_namespaceObject = require("../../proxy/index.js");
|
|
32
|
+
const external_utils_js_namespaceObject = require("../../utils.js");
|
|
33
|
+
const external_non_stream_js_namespaceObject = require("./non-stream.js");
|
|
34
|
+
const external_stream_js_namespaceObject = require("./stream.js");
|
|
35
|
+
const prepareChatCompletion = async ({ messages, modelRuntime, options })=>{
|
|
36
|
+
const debugCall = (0, logger_namespaceObject.getDebug)('ai:call');
|
|
37
|
+
const { config: modelConfig, adapter } = modelRuntime;
|
|
38
|
+
const modelCallInput = {
|
|
39
|
+
intent: modelConfig.intent,
|
|
40
|
+
userConfig: {
|
|
41
|
+
temperature: modelConfig.temperature,
|
|
42
|
+
reasoningEnabled: modelConfig.reasoningEnabled,
|
|
43
|
+
reasoningEffort: modelConfig.reasoningEffort,
|
|
44
|
+
reasoningBudget: modelConfig.reasoningBudget,
|
|
45
|
+
responseFormat: modelConfig.responseFormat
|
|
46
|
+
},
|
|
47
|
+
semanticRetryAttempt: options?.semanticRetryAttempt,
|
|
48
|
+
requiresOriginalImageDetail: options?.requiresOriginalImageDetail,
|
|
49
|
+
expectedJsonObjectResponse: options?.expectedJsonObjectResponse
|
|
50
|
+
};
|
|
51
|
+
const { config: adapterChatCompletionParams } = adapter.chatCompletion.buildChatCompletionParams(modelCallInput);
|
|
52
|
+
debugCall(`adapter chat completion params: ${(0, external_utils_js_namespaceObject.stringifyForDebug)({
|
|
53
|
+
config: adapterChatCompletionParams
|
|
54
|
+
})}`);
|
|
55
|
+
const requestBodyParams = {
|
|
56
|
+
...adapterChatCompletionParams,
|
|
57
|
+
...modelConfig.extraBody ?? {}
|
|
58
|
+
};
|
|
59
|
+
const imageDetail = adapter.chatCompletion.resolveImageDetail(modelCallInput);
|
|
60
|
+
const messagesWithImageDetail = (0, external_utils_js_namespaceObject.applyImageDetail)({
|
|
61
|
+
imageDetail,
|
|
62
|
+
messages
|
|
63
|
+
});
|
|
64
|
+
const proxyAgent = await (0, index_js_namespaceObject.createProxyAgentIfNeeded)({
|
|
65
|
+
socksProxy: modelConfig.socksProxy,
|
|
66
|
+
httpProxy: modelConfig.httpProxy
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
messages: messagesWithImageDetail,
|
|
70
|
+
requestParams: requestBodyParams,
|
|
71
|
+
proxyAgent
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
function callChatCompletion(options, stream) {
|
|
75
|
+
return stream ? (0, external_stream_js_namespaceObject.callChatCompletionStream)(options) : (0, external_non_stream_js_namespaceObject.callChatCompletionNonStreaming)(options);
|
|
76
|
+
}
|
|
77
|
+
exports.callChatCompletion = __webpack_exports__.callChatCompletion;
|
|
78
|
+
exports.prepareChatCompletion = __webpack_exports__.prepareChatCompletion;
|
|
79
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
80
|
+
"callChatCompletion",
|
|
81
|
+
"prepareChatCompletion"
|
|
82
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
83
|
+
Object.defineProperty(exports, '__esModule', {
|
|
84
|
+
value: true
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=chat-completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/openai/chat-completion/chat-completion.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/chat-completion/chat-completion.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport type { ChatCompletionCallInput } from '../../../model-adapter/types';\nimport { createProxyAgentIfNeeded } from '../../proxy';\nimport type { ModelCallContext, OpenAIProtocolCallResult } from '../../types';\nimport { applyImageDetail, stringifyForDebug } from '../../utils';\nimport { callChatCompletionNonStreaming } from './non-stream';\nimport { callChatCompletionStream } from './stream';\nimport type { ChatCompletionCallOptions } from './types';\n\nexport const prepareChatCompletion = async ({\n messages,\n modelRuntime,\n options,\n}: Pick<ModelCallContext, 'messages' | 'modelRuntime' | 'options'>) => {\n const debugCall = getDebug('ai:call');\n const { config: modelConfig, adapter } = modelRuntime;\n\n const modelCallInput: ChatCompletionCallInput = {\n intent: modelConfig.intent,\n userConfig: {\n temperature: modelConfig.temperature,\n reasoningEnabled: modelConfig.reasoningEnabled,\n reasoningEffort: modelConfig.reasoningEffort,\n reasoningBudget: modelConfig.reasoningBudget,\n responseFormat: modelConfig.responseFormat,\n },\n semanticRetryAttempt: options?.semanticRetryAttempt,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n expectedJsonObjectResponse: options?.expectedJsonObjectResponse,\n };\n\n const { config: adapterChatCompletionParams } =\n adapter.chatCompletion.buildChatCompletionParams(modelCallInput);\n\n debugCall(\n `adapter chat completion params: ${stringifyForDebug({\n config: adapterChatCompletionParams,\n })}`,\n );\n\n const requestBodyParams = {\n ...adapterChatCompletionParams,\n ...(modelConfig.extraBody ?? {}),\n };\n\n const imageDetail = adapter.chatCompletion.resolveImageDetail(modelCallInput);\n\n // Some adapters request original image detail to preserve screenshot\n // resolution for localization-sensitive tasks.\n const messagesWithImageDetail = applyImageDetail({ imageDetail, messages });\n\n const proxyAgent = await createProxyAgentIfNeeded({\n socksProxy: modelConfig.socksProxy,\n httpProxy: modelConfig.httpProxy,\n });\n\n return {\n messages: messagesWithImageDetail,\n requestParams: requestBodyParams,\n proxyAgent,\n };\n};\n\nexport function callChatCompletion(\n options: ChatCompletionCallOptions,\n stream: boolean,\n): Promise<OpenAIProtocolCallResult> {\n return stream\n ? callChatCompletionStream(options)\n : callChatCompletionNonStreaming(options);\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","prepareChatCompletion","messages","modelRuntime","options","debugCall","getDebug","modelConfig","adapter","modelCallInput","adapterChatCompletionParams","stringifyForDebug","requestBodyParams","imageDetail","messagesWithImageDetail","applyImageDetail","proxyAgent","createProxyAgentIfNeeded","callChatCompletion","stream","callChatCompletionStream","callChatCompletionNonStreaming"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;ACGO,MAAMI,wBAAwB,OAAO,EAC1CC,QAAQ,EACRC,YAAY,EACZC,OAAO,EACyD;IAChE,MAAMC,YAAYC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;IAC3B,MAAM,EAAE,QAAQC,WAAW,EAAEC,OAAO,EAAE,GAAGL;IAEzC,MAAMM,iBAA0C;QAC9C,QAAQF,YAAY,MAAM;QAC1B,YAAY;YACV,aAAaA,YAAY,WAAW;YACpC,kBAAkBA,YAAY,gBAAgB;YAC9C,iBAAiBA,YAAY,eAAe;YAC5C,iBAAiBA,YAAY,eAAe;YAC5C,gBAAgBA,YAAY,cAAc;QAC5C;QACA,sBAAsBH,SAAS;QAC/B,6BAA6BA,SAAS;QACtC,4BAA4BA,SAAS;IACvC;IAEA,MAAM,EAAE,QAAQM,2BAA2B,EAAE,GAC3CF,QAAQ,cAAc,CAAC,yBAAyB,CAACC;IAEnDJ,UACE,CAAC,gCAAgC,EAAEM,AAAAA,IAAAA,kCAAAA,iBAAAA,AAAAA,EAAkB;QACnD,QAAQD;IACV,IAAI;IAGN,MAAME,oBAAoB;QACxB,GAAGF,2BAA2B;QAC9B,GAAIH,YAAY,SAAS,IAAI,CAAC,CAAC;IACjC;IAEA,MAAMM,cAAcL,QAAQ,cAAc,CAAC,kBAAkB,CAACC;IAI9D,MAAMK,0BAA0BC,AAAAA,IAAAA,kCAAAA,gBAAAA,AAAAA,EAAiB;QAAEF;QAAaX;IAAS;IAEzE,MAAMc,aAAa,MAAMC,AAAAA,IAAAA,yBAAAA,wBAAAA,AAAAA,EAAyB;QAChD,YAAYV,YAAY,UAAU;QAClC,WAAWA,YAAY,SAAS;IAClC;IAEA,OAAO;QACL,UAAUO;QACV,eAAeF;QACfI;IACF;AACF;AAEO,SAASE,mBACdd,OAAkC,EAClCe,MAAe;IAEf,OAAOA,SACHC,AAAAA,IAAAA,mCAAAA,wBAAAA,AAAAA,EAAyBhB,WACzBiB,AAAAA,IAAAA,uCAAAA,8BAAAA,AAAAA,EAA+BjB;AACrC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
callChatCompletionNonStreaming: ()=>callChatCompletionNonStreaming
|
|
28
|
+
});
|
|
29
|
+
const external_utils_js_namespaceObject = require("../../utils.js");
|
|
30
|
+
const external_utils_js_namespaceObject_1 = require("./utils.js");
|
|
31
|
+
const callChatCompletionNonStreaming = async ({ completion, openAIRequestContext, modelRuntime, messages, requestBodyParams, requestSignal })=>{
|
|
32
|
+
const { config: { modelName }, adapter } = modelRuntime;
|
|
33
|
+
requestSignal.throwIfAborted();
|
|
34
|
+
const result = await completion.create({
|
|
35
|
+
model: modelName,
|
|
36
|
+
messages,
|
|
37
|
+
...requestBodyParams,
|
|
38
|
+
stream: false
|
|
39
|
+
}, {
|
|
40
|
+
signal: requestSignal
|
|
41
|
+
});
|
|
42
|
+
requestSignal.throwIfAborted();
|
|
43
|
+
const requestId = result._request_id ?? openAIRequestContext.responseRequestId?.requestId;
|
|
44
|
+
if (!result.choices) throw new Error(`invalid response from LLM service: ${JSON.stringify(result)}`);
|
|
45
|
+
const rawChoiceMessage = result.choices[0].message;
|
|
46
|
+
const parsedMessage = adapter.chatCompletion.extractContentAndReasoning(result.choices[0].message);
|
|
47
|
+
const reasoningContent = parsedMessage.reasoning_content;
|
|
48
|
+
const content = (0, external_utils_js_namespaceObject_1.resolveContentWithReasoningFallback)({
|
|
49
|
+
content: parsedMessage.content,
|
|
50
|
+
reasoningContent,
|
|
51
|
+
useReasoningAsContentFallback: adapter.chatCompletion.useReasoningAsContentFallback
|
|
52
|
+
});
|
|
53
|
+
if (!(0, external_utils_js_namespaceObject.hasUsableText)(content)) throw new external_utils_js_namespaceObject.AIResponseParseError('empty content from AI model', content || '', void 0, rawChoiceMessage);
|
|
54
|
+
return {
|
|
55
|
+
content,
|
|
56
|
+
reasoningContent,
|
|
57
|
+
rawChoiceMessage,
|
|
58
|
+
rawUsage: result.usage,
|
|
59
|
+
requestId,
|
|
60
|
+
responseModelName: result.model
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.callChatCompletionNonStreaming = __webpack_exports__.callChatCompletionNonStreaming;
|
|
64
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
65
|
+
"callChatCompletionNonStreaming"
|
|
66
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
67
|
+
Object.defineProperty(exports, '__esModule', {
|
|
68
|
+
value: true
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=non-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/openai/chat-completion/non-stream.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/chat-completion/non-stream.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { OpenAIProtocolCallResult } from '../../types';\nimport { AIResponseParseError, hasUsableText } from '../../utils';\nimport type { ChatCompletionCallOptions } from './types';\nimport { resolveContentWithReasoningFallback } from './utils';\n\nexport const callChatCompletionNonStreaming = async ({\n completion,\n openAIRequestContext,\n modelRuntime,\n messages,\n requestBodyParams,\n requestSignal,\n}: ChatCompletionCallOptions): Promise<OpenAIProtocolCallResult> => {\n const {\n config: { modelName },\n adapter,\n } = modelRuntime;\n requestSignal.throwIfAborted();\n const result = await completion.create(\n {\n model: modelName,\n messages,\n ...requestBodyParams,\n stream: false,\n },\n { signal: requestSignal },\n );\n\n requestSignal.throwIfAborted();\n\n const requestId =\n result._request_id ?? openAIRequestContext.responseRequestId?.requestId;\n\n if (!result.choices) {\n throw new Error(\n `invalid response from LLM service: ${JSON.stringify(result)}`,\n );\n }\n\n const rawChoiceMessage = result.choices[0].message;\n const parsedMessage = adapter.chatCompletion.extractContentAndReasoning(\n result.choices[0].message,\n );\n const reasoningContent = parsedMessage.reasoning_content;\n const content = resolveContentWithReasoningFallback({\n content: parsedMessage.content,\n reasoningContent,\n useReasoningAsContentFallback:\n adapter.chatCompletion.useReasoningAsContentFallback,\n });\n\n if (!hasUsableText(content)) {\n throw new AIResponseParseError(\n 'empty content from AI model',\n content || '',\n undefined,\n rawChoiceMessage,\n );\n }\n\n return {\n content,\n reasoningContent,\n rawChoiceMessage,\n rawUsage: result.usage,\n requestId,\n responseModelName: result.model,\n };\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","callChatCompletionNonStreaming","completion","openAIRequestContext","modelRuntime","messages","requestBodyParams","requestSignal","modelName","adapter","result","requestId","Error","JSON","rawChoiceMessage","parsedMessage","reasoningContent","content","res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,CAAC,0BAA0B,CACrEC,OAAO,OAAO,CAAC,EAAE,CAAC,OAAO;IAE3B,MAAMM,mBAAmBD,cAAc,iBAAiB;IACxD,MAAME,UAAUC,AAAAA,IAAAA,oCAAAA,mCAAAA,AAAAA,EAAoC;QAClD,SAASH,cAAc,OAAO;QAC9BC;QACA,+BACEP,QAAQ,cAAc,CAAC,6BAA6B;IACxD;IAEA,IAAI,CAACU,AAAAA,IAAAA,kCAAAA,aAAAA,AAAAA,EAAcF,UACjB,MAAM,IAAIG,kCAAAA,oBAAoBA,CAC5B,+BACAH,WAAW,IACXI,QACAP;IAIJ,OAAO;QACLG;QACAD;QACAF;QACA,UAAUJ,OAAO,KAAK;QACtBC;QACA,mBAAmBD,OAAO,KAAK;IACjC;AACF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
callChatCompletionStream: ()=>callChatCompletionStream
|
|
28
|
+
});
|
|
29
|
+
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
30
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
31
|
+
const callChatCompletionStream = async ({ completion, openAIRequestContext, modelRuntime, messages, requestBodyParams, requestSignal, onChunk, recordEvent })=>{
|
|
32
|
+
(0, utils_namespaceObject.assert)('function' == typeof onChunk, 'onChunk is required when stream is true');
|
|
33
|
+
const { adapter } = modelRuntime;
|
|
34
|
+
const { modelName } = modelRuntime.config;
|
|
35
|
+
let accumulated = '';
|
|
36
|
+
let accumulatedReasoning = '';
|
|
37
|
+
let usage;
|
|
38
|
+
let responseModelName;
|
|
39
|
+
requestSignal.throwIfAborted();
|
|
40
|
+
const stream = await completion.create({
|
|
41
|
+
model: modelName,
|
|
42
|
+
messages,
|
|
43
|
+
...requestBodyParams,
|
|
44
|
+
stream: true,
|
|
45
|
+
stream_options: {
|
|
46
|
+
...requestBodyParams.stream_options,
|
|
47
|
+
include_usage: true
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
stream: true,
|
|
51
|
+
signal: requestSignal
|
|
52
|
+
});
|
|
53
|
+
const requestId = stream._request_id ?? openAIRequestContext.responseRequestId?.requestId;
|
|
54
|
+
let chunkSequence = 0;
|
|
55
|
+
for await (const chunk of stream){
|
|
56
|
+
requestSignal.throwIfAborted();
|
|
57
|
+
chunkSequence += 1;
|
|
58
|
+
recordEvent?.({
|
|
59
|
+
type: 'chunk',
|
|
60
|
+
sequence: chunkSequence,
|
|
61
|
+
chunk
|
|
62
|
+
});
|
|
63
|
+
const parsedChunk = adapter.chatCompletion.extractContentAndReasoning(chunk.choices?.[0]?.delta);
|
|
64
|
+
const content = parsedChunk.content || '';
|
|
65
|
+
const reasoning_content = parsedChunk.reasoning_content || '';
|
|
66
|
+
if (chunk.usage) usage = chunk.usage;
|
|
67
|
+
if (chunk.model) responseModelName = chunk.model;
|
|
68
|
+
if (content || reasoning_content) {
|
|
69
|
+
accumulated += content;
|
|
70
|
+
accumulatedReasoning += reasoning_content;
|
|
71
|
+
const chunkData = {
|
|
72
|
+
content,
|
|
73
|
+
reasoning_content,
|
|
74
|
+
accumulated,
|
|
75
|
+
isComplete: false,
|
|
76
|
+
usage: void 0
|
|
77
|
+
};
|
|
78
|
+
onChunk(chunkData);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const finalAccumulated = (0, external_utils_js_namespaceObject.resolveContentWithReasoningFallback)({
|
|
82
|
+
content: accumulated,
|
|
83
|
+
reasoningContent: accumulatedReasoning,
|
|
84
|
+
useReasoningAsContentFallback: adapter.chatCompletion.useReasoningAsContentFallback
|
|
85
|
+
});
|
|
86
|
+
accumulated = finalAccumulated || '';
|
|
87
|
+
const finalChunk = {
|
|
88
|
+
content: '',
|
|
89
|
+
accumulated,
|
|
90
|
+
reasoning_content: '',
|
|
91
|
+
isComplete: true,
|
|
92
|
+
usage
|
|
93
|
+
};
|
|
94
|
+
onChunk(finalChunk);
|
|
95
|
+
return {
|
|
96
|
+
content: accumulated,
|
|
97
|
+
reasoningContent: accumulatedReasoning,
|
|
98
|
+
rawChoiceMessage: void 0,
|
|
99
|
+
rawUsage: usage,
|
|
100
|
+
requestId,
|
|
101
|
+
responseModelName
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
exports.callChatCompletionStream = __webpack_exports__.callChatCompletionStream;
|
|
105
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
106
|
+
"callChatCompletionStream"
|
|
107
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
108
|
+
Object.defineProperty(exports, '__esModule', {
|
|
109
|
+
value: true
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/openai/chat-completion/stream.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/chat-completion/stream.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { CodeGenerationChunk } from '@/types';\nimport { assert } from '@midscene/shared/utils';\nimport type OpenAI from 'openai';\nimport type { Stream } from 'openai/streaming';\nimport type { OpenAIProtocolCallResult } from '../../types';\nimport type { ChatCompletionCallOptions } from './types';\nimport { resolveContentWithReasoningFallback } from './utils';\n\nexport const callChatCompletionStream = async ({\n completion,\n openAIRequestContext,\n modelRuntime,\n messages,\n requestBodyParams,\n requestSignal,\n onChunk,\n recordEvent,\n}: ChatCompletionCallOptions): Promise<OpenAIProtocolCallResult> => {\n assert(\n typeof onChunk === 'function',\n 'onChunk is required when stream is true',\n );\n const { adapter } = modelRuntime;\n const { modelName } = modelRuntime.config;\n let accumulated = '';\n let accumulatedReasoning = '';\n let usage: OpenAI.CompletionUsage | undefined;\n let responseModelName: string | undefined;\n requestSignal.throwIfAborted();\n const stream = (await completion.create(\n {\n model: modelName,\n messages,\n ...requestBodyParams,\n stream: true,\n stream_options: {\n ...(requestBodyParams.stream_options as\n | Record<string, unknown>\n | undefined),\n include_usage: true,\n },\n },\n {\n stream: true,\n signal: requestSignal,\n },\n )) as Stream<OpenAI.Chat.Completions.ChatCompletionChunk> & {\n _request_id?: string | null;\n };\n\n const requestId =\n stream._request_id ?? openAIRequestContext.responseRequestId?.requestId;\n\n let chunkSequence = 0;\n for await (const chunk of stream) {\n requestSignal.throwIfAborted();\n chunkSequence += 1;\n recordEvent?.({\n type: 'chunk',\n sequence: chunkSequence,\n chunk,\n });\n const parsedChunk = adapter.chatCompletion.extractContentAndReasoning(\n chunk.choices?.[0]?.delta,\n );\n const content = parsedChunk.content || '';\n const reasoning_content = parsedChunk.reasoning_content || '';\n\n // Check for usage info in any chunk (OpenAI provides usage in separate chunks)\n if (chunk.usage) {\n usage = chunk.usage;\n }\n if (chunk.model) {\n responseModelName = chunk.model;\n }\n\n if (content || reasoning_content) {\n accumulated += content;\n accumulatedReasoning += reasoning_content;\n const chunkData: CodeGenerationChunk = {\n content,\n reasoning_content,\n accumulated,\n isComplete: false,\n usage: undefined,\n };\n onChunk(chunkData);\n }\n }\n\n const finalAccumulated = resolveContentWithReasoningFallback({\n content: accumulated,\n reasoningContent: accumulatedReasoning,\n useReasoningAsContentFallback:\n adapter.chatCompletion.useReasoningAsContentFallback,\n });\n accumulated = finalAccumulated || '';\n\n // Send final chunk\n const finalChunk: CodeGenerationChunk = {\n content: '',\n accumulated,\n reasoning_content: '',\n isComplete: true,\n usage,\n };\n onChunk(finalChunk);\n return {\n content: accumulated,\n reasoningContent: accumulatedReasoning,\n rawChoiceMessage: undefined,\n rawUsage: usage,\n requestId,\n responseModelName,\n };\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","callChatCompletionStream","completion","openAIRequestContext","modelRuntime","messages","requestBodyParams","requestSignal","onChunk","recordEvent","assert","adapter","modelName","accumulated","accumulatedReasoning","usage","responseModelName","stream","requestId","chunkSequence","chunk","parsedChunk","content","reasoning_content","chunkData","undefined","finalAccumulated","resolveContentWithReasoningFallback","finalChunk"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACz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Ac,CAAC,0BAA0B,CACnES,MAAM,OAAO,EAAE,CAAC,EAAE,EAAE;QAEtB,MAAME,UAAUD,YAAY,OAAO,IAAI;QACvC,MAAME,oBAAoBF,YAAY,iBAAiB,IAAI;QAG3D,IAAID,MAAM,KAAK,EACbL,QAAQK,MAAM,KAAK;QAErB,IAAIA,MAAM,KAAK,EACbJ,oBAAoBI,MAAM,KAAK;QAGjC,IAAIE,WAAWC,mBAAmB;YAChCV,eAAeS;YACfR,wBAAwBS;YACxB,MAAMC,YAAiC;gBACrCF;gBACAC;gBACAV;gBACA,YAAY;gBACZ,OAAOY;YACT;YACAjB,QAAQgB;QACV;IACF;IAEA,MAAME,mBAAmBC,AAAAA,IAAAA,kCAAAA,mCAAAA,AAAAA,EAAoC;QAC3D,SAASd;QACT,kBAAkBC;QAClB,+BACEH,QAAQ,cAAc,CAAC,6BAA6B;IACxD;IACAE,cAAca,oBAAoB;IAGlC,MAAME,aAAkC;QACtC,SAAS;QACTf;QACA,mBAAmB;QACnB,YAAY;QACZE;IACF;IACAP,QAAQoB;IACR,OAAO;QACL,SAASf;QACT,kBAAkBC;QAClB,kBAAkBW;QAClB,UAAUV;QACVG;QACAF;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/openai/chat-completion/types.js","sources":["webpack/runtime/make_namespace_object"],"sourcesContent":["// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","Symbol","Object"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOC,UAA0BA,OAAO,WAAW,EACrDC,OAAO,cAAc,CAAC,UAASD,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEC,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
|
package/dist/lib/ai-model/service-caller/{chat-completion → openai/chat-completion}/utils.js
RENAMED
|
@@ -24,34 +24,12 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
resolveContentWithReasoningFallback: ()=>resolveContentWithReasoningFallback,
|
|
29
|
-
applyImageDetail: ()=>applyImageDetail
|
|
27
|
+
resolveContentWithReasoningFallback: ()=>resolveContentWithReasoningFallback
|
|
30
28
|
});
|
|
31
29
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
32
|
-
const
|
|
33
|
-
if (!imageDetail) return messages;
|
|
34
|
-
return messages.map((msg)=>{
|
|
35
|
-
if (!Array.isArray(msg.content)) return msg;
|
|
36
|
-
const content = msg.content.map((part)=>{
|
|
37
|
-
if (part && 'image_url' === part.type && part.image_url?.url) return {
|
|
38
|
-
...part,
|
|
39
|
-
image_url: {
|
|
40
|
-
...part.image_url,
|
|
41
|
-
detail: imageDetail
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
return part;
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
...msg,
|
|
48
|
-
content
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
const hasUsableText = (value)=>'string' == typeof value && value.trim().length > 0;
|
|
30
|
+
const external_utils_js_namespaceObject = require("../../utils.js");
|
|
53
31
|
const resolveContentWithReasoningFallback = ({ content, reasoningContent, useReasoningAsContentFallback })=>{
|
|
54
|
-
if (!hasUsableText(content) && useReasoningAsContentFallback && hasUsableText(reasoningContent)) {
|
|
32
|
+
if (!(0, external_utils_js_namespaceObject.hasUsableText)(content) && useReasoningAsContentFallback && (0, external_utils_js_namespaceObject.hasUsableText)(reasoningContent)) {
|
|
55
33
|
const warnCall = (0, logger_namespaceObject.getDebug)('ai:call', {
|
|
56
34
|
console: true
|
|
57
35
|
});
|
|
@@ -60,12 +38,8 @@ const resolveContentWithReasoningFallback = ({ content, reasoningContent, useRea
|
|
|
60
38
|
}
|
|
61
39
|
return content;
|
|
62
40
|
};
|
|
63
|
-
exports.applyImageDetail = __webpack_exports__.applyImageDetail;
|
|
64
|
-
exports.hasUsableText = __webpack_exports__.hasUsableText;
|
|
65
41
|
exports.resolveContentWithReasoningFallback = __webpack_exports__.resolveContentWithReasoningFallback;
|
|
66
42
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
67
|
-
"applyImageDetail",
|
|
68
|
-
"hasUsableText",
|
|
69
43
|
"resolveContentWithReasoningFallback"
|
|
70
44
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
71
45
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/openai/chat-completion/utils.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/chat-completion/utils.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { hasUsableText } from '../../utils';\n\nexport const resolveContentWithReasoningFallback = ({\n content,\n reasoningContent,\n useReasoningAsContentFallback,\n}: {\n content: string | undefined;\n reasoningContent: string;\n useReasoningAsContentFallback: boolean;\n}): string | undefined => {\n if (\n !hasUsableText(content) &&\n useReasoningAsContentFallback &&\n hasUsableText(reasoningContent)\n ) {\n const warnCall = getDebug('ai:call', { console: true });\n warnCall('empty content from AI model, using reasoning content');\n return reasoningContent;\n }\n\n return content;\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","resolveContentWithReasoningFallback","content","reasoningContent","useReasoningAsContentFallback","hasUsableText","warnCall","getDebug"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACHO,MAAMI,sCAAsC,CAAC,EAClDC,OAAO,EACPC,gBAAgB,EAChBC,6BAA6B,EAK9B;IACC,IACE,CAACC,AAAAA,IAAAA,kCAAAA,aAAAA,AAAAA,EAAcH,YACfE,iCACAC,AAAAA,IAAAA,kCAAAA,aAAAA,AAAAA,EAAcF,mBACd;QACA,MAAMG,WAAWC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS,WAAW;YAAE,SAAS;QAAK;QACrDD,SAAS;QACT,OAAOH;IACT;IAEA,OAAOD;AACT"}
|
|
@@ -40,11 +40,9 @@ const logger_namespaceObject = require("@midscene/shared/logger");
|
|
|
40
40
|
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
41
41
|
const external_openai_namespaceObject = require("openai");
|
|
42
42
|
var external_openai_default = /*#__PURE__*/ __webpack_require__.n(external_openai_namespaceObject);
|
|
43
|
-
const external_utils_js_namespaceObject = require("
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const external_request_timeout_js_namespaceObject = require("./request-timeout.js");
|
|
47
|
-
const createAndWrapClient = async ({ openaiBaseURL, openaiApiKey, openaiExtraConfig, createOpenAIClient, effectiveTimeoutMs, proxyAgent, executionId, openAIErrorResponseContext })=>{
|
|
43
|
+
const external_utils_js_namespaceObject = require("../../../utils.js");
|
|
44
|
+
const external_openai_request_context_js_namespaceObject = require("./openai-request-context.js");
|
|
45
|
+
const createAndWrapClient = async ({ openaiBaseURL, openaiApiKey, openaiExtraConfig, createOpenAIClient, effectiveTimeoutMs, proxyAgent, executionId, openAIRequestContext })=>{
|
|
48
46
|
const warnClient = (0, logger_namespaceObject.getDebug)('ai:call', {
|
|
49
47
|
console: true
|
|
50
48
|
});
|
|
@@ -62,7 +60,7 @@ const createAndWrapClient = async ({ openaiBaseURL, openaiApiKey, openaiExtraCon
|
|
|
62
60
|
'x-midscene-version': (0, external_utils_js_namespaceObject.getVersion)(),
|
|
63
61
|
'x-midscene-execution-id': executionId
|
|
64
62
|
},
|
|
65
|
-
fetch: (0,
|
|
63
|
+
fetch: (0, external_openai_request_context_js_namespaceObject.wrapOpenAICompatibleFetch)(openAIRequestContext),
|
|
66
64
|
maxRetries: 0,
|
|
67
65
|
...null !== effectiveTimeoutMs ? {
|
|
68
66
|
timeout: effectiveTimeoutMs
|
|
@@ -91,16 +89,9 @@ const createAndWrapClient = async ({ openaiBaseURL, openaiApiKey, openaiExtraCon
|
|
|
91
89
|
}
|
|
92
90
|
return openai;
|
|
93
91
|
};
|
|
94
|
-
async function createChatClient({ modelConfig, executionId, recordEvent }) {
|
|
95
|
-
const {
|
|
96
|
-
const
|
|
97
|
-
socksProxy,
|
|
98
|
-
httpProxy
|
|
99
|
-
});
|
|
100
|
-
const effectiveTimeoutMs = (0, external_request_timeout_js_namespaceObject.resolveEffectiveTimeoutMs)({
|
|
101
|
-
timeout
|
|
102
|
-
});
|
|
103
|
-
const openAIErrorResponseContext = {
|
|
92
|
+
async function createChatClient({ modelConfig, proxyAgent, effectiveTimeoutMs, executionId, recordEvent }) {
|
|
93
|
+
const { openaiBaseURL, openaiApiKey, openaiExtraConfig, createOpenAIClient } = modelConfig;
|
|
94
|
+
const openAIRequestContext = {
|
|
104
95
|
recordEvent
|
|
105
96
|
};
|
|
106
97
|
const openai = await createAndWrapClient({
|
|
@@ -111,14 +102,11 @@ async function createChatClient({ modelConfig, executionId, recordEvent }) {
|
|
|
111
102
|
effectiveTimeoutMs,
|
|
112
103
|
proxyAgent,
|
|
113
104
|
executionId,
|
|
114
|
-
|
|
105
|
+
openAIRequestContext
|
|
115
106
|
});
|
|
116
107
|
return {
|
|
117
108
|
completion: openai.chat.completions,
|
|
118
|
-
|
|
119
|
-
modelDescription,
|
|
120
|
-
modelFamily,
|
|
121
|
-
openAIErrorResponseContext
|
|
109
|
+
openAIRequestContext
|
|
122
110
|
};
|
|
123
111
|
}
|
|
124
112
|
exports.createChatClient = __webpack_exports__.createChatClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/openai/openai-client.js","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/service-caller/openai/openai-client.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {\n type IModelConfig,\n MIDSCENE_LANGFUSE_DEBUG,\n MIDSCENE_LANGSMITH_DEBUG,\n globalConfigManager,\n} from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport { ifInBrowser } from '@midscene/shared/utils';\nimport OpenAI from 'openai';\nimport { getVersion } from '../../../utils';\nimport type { createProxyAgentIfNeeded } from '../proxy';\nimport {\n type OpenAIRequestContext,\n wrapOpenAICompatibleFetch,\n} from './openai-request-context';\n\nconst createAndWrapClient = async ({\n openaiBaseURL,\n openaiApiKey,\n openaiExtraConfig,\n createOpenAIClient,\n effectiveTimeoutMs,\n proxyAgent,\n executionId,\n openAIRequestContext,\n}: {\n openaiBaseURL: IModelConfig['openaiBaseURL'];\n openaiApiKey: IModelConfig['openaiApiKey'];\n openaiExtraConfig: IModelConfig['openaiExtraConfig'];\n createOpenAIClient: IModelConfig['createOpenAIClient'];\n effectiveTimeoutMs: number | null;\n proxyAgent: Awaited<ReturnType<typeof createProxyAgentIfNeeded>>;\n executionId: string;\n openAIRequestContext: OpenAIRequestContext;\n}): Promise<OpenAI> => {\n const warnClient = getDebug('ai:call', { console: true });\n\n const openAIOptions = {\n baseURL: openaiBaseURL,\n apiKey: openaiApiKey,\n // Use fetchOptions.dispatcher for fetch-based SDK instead of httpAgent\n // Note: Type assertion needed due to undici version mismatch between dependencies\n ...(proxyAgent ? { fetchOptions: { dispatcher: proxyAgent as any } } : {}),\n ...openaiExtraConfig,\n // Midscene exposes this setting through MIDSCENE_*_INIT_CONFIG_JSON, so\n // defaultHeaders is expected to be a plain JSON object rather than another\n // HeadersLike representation supported by the OpenAI SDK.\n defaultHeaders: {\n ...(openaiExtraConfig?.defaultHeaders as\n | Record<string, string>\n | undefined),\n // These Midscene-owned headers intentionally override user-supplied\n // headers with the same names.\n 'x-midscene-version': getVersion(),\n 'x-midscene-execution-id': executionId,\n },\n fetch: wrapOpenAICompatibleFetch(openAIRequestContext),\n // Midscene handles request retries in callAI(), so disable SDK-level retries\n // to avoid duplicate attempts and duplicated backoff latency.\n maxRetries: 0,\n // Disabling the Midscene hard timeout leaves the SDK timeout at its\n // configured value or default; it does not disable SDK/network timeouts.\n ...(effectiveTimeoutMs !== null ? { timeout: effectiveTimeoutMs } : {}),\n dangerouslyAllowBrowser: true,\n };\n\n const baseOpenAI = new OpenAI(openAIOptions);\n\n let openai: OpenAI = baseOpenAI;\n\n // LangSmith wrapper\n if (\n openai &&\n globalConfigManager.getEnvConfigInBoolean(MIDSCENE_LANGSMITH_DEBUG)\n ) {\n if (ifInBrowser) {\n throw new Error('langsmith is not supported in browser');\n }\n warnClient('DEBUGGING MODE: langsmith wrapper enabled');\n // Use variable to prevent static analysis by bundlers\n const langsmithModule = 'langsmith/wrappers';\n const { wrapOpenAI } = await import(langsmithModule);\n openai = wrapOpenAI(openai);\n }\n\n // Langfuse wrapper\n if (\n openai &&\n globalConfigManager.getEnvConfigInBoolean(MIDSCENE_LANGFUSE_DEBUG)\n ) {\n if (ifInBrowser) {\n throw new Error('langfuse is not supported in browser');\n }\n warnClient('DEBUGGING MODE: langfuse wrapper enabled');\n // Use variable to prevent static analysis by bundlers\n const langfuseModule = '@langfuse/openai';\n const { observeOpenAI } = await import(langfuseModule);\n openai = observeOpenAI(openai);\n }\n\n if (createOpenAIClient) {\n const wrappedClient = await createOpenAIClient(baseOpenAI, openAIOptions);\n\n if (wrappedClient) {\n openai = wrappedClient as OpenAI;\n }\n }\n\n return openai;\n};\n\nexport async function createChatClient({\n modelConfig,\n proxyAgent,\n effectiveTimeoutMs,\n executionId,\n recordEvent,\n}: {\n modelConfig: IModelConfig;\n proxyAgent: Awaited<ReturnType<typeof createProxyAgentIfNeeded>>;\n effectiveTimeoutMs: number | null;\n executionId: string;\n recordEvent?: (event: Record<string, unknown>) => void;\n}): Promise<{\n completion: OpenAI.Chat.Completions;\n openAIRequestContext: OpenAIRequestContext;\n}> {\n const { openaiBaseURL, openaiApiKey, openaiExtraConfig, createOpenAIClient } =\n modelConfig;\n\n const openAIRequestContext: OpenAIRequestContext = {\n recordEvent,\n };\n\n const openai = await createAndWrapClient({\n openaiBaseURL,\n openaiApiKey,\n openaiExtraConfig,\n createOpenAIClient,\n effectiveTimeoutMs,\n proxyAgent,\n executionId,\n openAIRequestContext,\n });\n\n return {\n completion: openai.chat.completions,\n openAIRequestContext,\n };\n}\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","createAndWrapClient","openaiBaseURL","openaiApiKey","openaiExtraConfig","createOpenAIClient","effectiveTimeoutMs","proxyAgent","executionId","openAIRequestContext","warnClient","getDebug","openAIOptions","getVersion","wrapOpenAICompatibleFetch","baseOpenAI","OpenAI","openai","globalConfigManager","MIDSCENE_LANGSMITH_DEBUG","ifInBrowser","Error","langsmithModule","wrapOpenAI","MIDSCENE_LANGFUSE_DEBUG","langfuseModule","observeOpenAI","wrappedClient","createChatClient","modelConfig","recordEvent"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAA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,WAAWA,EACb,MAAM,IAAIC,MAAM;QAElBX,WAAW;QAEX,MAAMY,kBAAkB;QACxB,MAAM,EAAEC,UAAU,EAAE,GAAG,MAAM,MAAM,CAACD;QACpCL,SAASM,WAAWN;IACtB;IAGA,IACEA,UACAC,oBAAAA,mBAAAA,CAAAA,qBAAyC,CAACM,oBAAAA,uBAAuBA,GACjE;QACA,IAAIJ,sBAAAA,WAAWA,EACb,MAAM,IAAIC,MAAM;QAElBX,WAAW;QAEX,MAAMe,iBAAiB;QACvB,MAAM,EAAEC,aAAa,EAAE,GAAG,MAAM,MAAM,CAACD;QACvCR,SAASS,cAAcT;IACzB;IAEA,IAAIZ,oBAAoB;QACtB,MAAMsB,gBAAgB,MAAMtB,mBAAmBU,YAAYH;QAE3D,IAAIe,eACFV,SAASU;IAEb;IAEA,OAAOV;AACT;AAEO,eAAeW,iBAAiB,EACrCC,WAAW,EACXtB,UAAU,EACVD,kBAAkB,EAClBE,WAAW,EACXsB,WAAW,EAOZ;IAIC,MAAM,EAAE5B,aAAa,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,kBAAkB,EAAE,GAC1EwB;IAEF,MAAMpB,uBAA6C;QACjDqB;IACF;IAEA,MAAMb,SAAS,MAAMhB,oBAAoB;QACvCC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,OAAO;QACL,YAAYQ,OAAO,IAAI,CAAC,WAAW;QACnCR;IACF;AACF"}
|
package/dist/lib/ai-model/service-caller/{openai-error.js → openai/openai-request-context.js}
RENAMED
|
@@ -73,14 +73,11 @@ function getDefaultFetch() {
|
|
|
73
73
|
}
|
|
74
74
|
function wrapOpenAICompatibleFetch(context) {
|
|
75
75
|
const baseFetch = getDefaultFetch();
|
|
76
|
-
let attempt = 0;
|
|
77
76
|
return async (input, init)=>{
|
|
78
|
-
attempt += 1;
|
|
79
77
|
if (context.recordEvent) {
|
|
80
78
|
const request = new Request(input, init);
|
|
81
79
|
context.recordEvent({
|
|
82
80
|
type: 'request',
|
|
83
|
-
attempt,
|
|
84
81
|
request: {
|
|
85
82
|
url: request.url,
|
|
86
83
|
method: request.method,
|
|
@@ -94,43 +91,27 @@ function wrapOpenAICompatibleFetch(context) {
|
|
|
94
91
|
} catch (error) {
|
|
95
92
|
const fetchErrorSummary = formatFetchErrorForReport(error);
|
|
96
93
|
debugOpenAIFetch('OpenAI-compatible fetch failed', fetchErrorSummary);
|
|
97
|
-
context.
|
|
98
|
-
context.fetchErrors.push({
|
|
99
|
-
attempt,
|
|
100
|
-
error: fetchErrorSummary
|
|
101
|
-
});
|
|
94
|
+
context.fetchError = fetchErrorSummary;
|
|
102
95
|
context.recordEvent?.({
|
|
103
96
|
type: 'error',
|
|
104
|
-
attempt,
|
|
105
97
|
error: fetchErrorSummary
|
|
106
98
|
});
|
|
107
99
|
throw error;
|
|
108
100
|
}
|
|
109
101
|
const requestId = response.headers.get('x-request-id') ?? response.headers.get('x-model-request-id');
|
|
110
|
-
if (requestId) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
status: response.status,
|
|
116
|
-
ok: response.ok
|
|
117
|
-
});
|
|
118
|
-
}
|
|
102
|
+
if (requestId) context.responseRequestId = {
|
|
103
|
+
requestId,
|
|
104
|
+
status: response.status,
|
|
105
|
+
ok: response.ok
|
|
106
|
+
};
|
|
119
107
|
if (!response.ok) {
|
|
120
108
|
const rawResponseBody = await response.clone().text().catch(()=>void 0);
|
|
121
|
-
|
|
122
|
-
context.rawResponseBodies ??= [];
|
|
123
|
-
context.rawResponseBodies.push({
|
|
124
|
-
attempt,
|
|
125
|
-
body: rawResponseBody
|
|
126
|
-
});
|
|
127
|
-
}
|
|
109
|
+
context.rawResponseBody = rawResponseBody;
|
|
128
110
|
}
|
|
129
111
|
if (context.recordEvent) {
|
|
130
112
|
const isStream = response.headers.get('content-type')?.includes('text/event-stream');
|
|
131
113
|
const body = isStream ? void 0 : await response.clone().text().catch(()=>void 0);
|
|
132
114
|
const httpResponse = {
|
|
133
|
-
attempt,
|
|
134
115
|
status: response.status,
|
|
135
116
|
ok: response.ok,
|
|
136
117
|
headers: headersToEntries(response.headers),
|
|
@@ -138,8 +119,7 @@ function wrapOpenAICompatibleFetch(context) {
|
|
|
138
119
|
body
|
|
139
120
|
}
|
|
140
121
|
};
|
|
141
|
-
context.
|
|
142
|
-
context.httpResponses.push(httpResponse);
|
|
122
|
+
context.httpResponse = httpResponse;
|
|
143
123
|
if (!response.ok) context.recordEvent({
|
|
144
124
|
type: 'error',
|
|
145
125
|
...httpResponse
|
|
@@ -150,24 +130,12 @@ function wrapOpenAICompatibleFetch(context) {
|
|
|
150
130
|
}
|
|
151
131
|
function formatOpenAIAPIErrorDetails(_error, context) {
|
|
152
132
|
const details = [];
|
|
153
|
-
if (context.
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
details.push(`OpenAI
|
|
157
|
-
}
|
|
158
|
-
const errorResponseRequestIds = context.responseRequestIds?.filter(({ ok })=>!ok);
|
|
159
|
-
if (errorResponseRequestIds?.length === 1) {
|
|
160
|
-
const { attempt, requestId, status } = errorResponseRequestIds[0];
|
|
161
|
-
details.push(`OpenAI error response request ID (attempt ${attempt}, status ${status}): ${requestId}`);
|
|
162
|
-
} else if (errorResponseRequestIds?.length) {
|
|
163
|
-
const requestIdDetails = errorResponseRequestIds.map(({ attempt, requestId, status })=>`Attempt ${attempt} (status ${status}): ${requestId}`).join('\n');
|
|
164
|
-
details.push(`OpenAI error response request IDs:\n${requestIdDetails}`);
|
|
165
|
-
}
|
|
166
|
-
if (context.fetchErrors?.length === 1) details.push(`OpenAI fetch error (attempt ${context.fetchErrors[0].attempt}): ${context.fetchErrors[0].error}`);
|
|
167
|
-
else if (context.fetchErrors?.length) {
|
|
168
|
-
const fetchErrorDetails = context.fetchErrors.map(({ attempt, error })=>`Attempt ${attempt}: ${error}`).join('\n');
|
|
169
|
-
details.push(`OpenAI fetch errors:\n${fetchErrorDetails}`);
|
|
133
|
+
if (void 0 !== context.rawResponseBody) details.push(`OpenAI raw error response body: ${truncateErrorResponseBody(context.rawResponseBody)}`);
|
|
134
|
+
if (context.responseRequestId && !context.responseRequestId.ok) {
|
|
135
|
+
const { requestId, status } = context.responseRequestId;
|
|
136
|
+
details.push(`OpenAI error response request ID (status ${status}): ${requestId}`);
|
|
170
137
|
}
|
|
138
|
+
if (void 0 !== context.fetchError) details.push(`OpenAI fetch error: ${context.fetchError}`);
|
|
171
139
|
if (!details.length) return '';
|
|
172
140
|
return `\n${details.join('\n')}`;
|
|
173
141
|
}
|
|
@@ -181,4 +149,4 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
181
149
|
value: true
|
|
182
150
|
});
|
|
183
151
|
|
|
184
|
-
//# sourceMappingURL=openai-
|
|
152
|
+
//# sourceMappingURL=openai-request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/service-caller/openai/openai-request-context.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/service-caller/openai/openai-request-context.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\n\nconst MAX_ERROR_RESPONSE_BODY_LENGTH = 4000;\nconst MAX_FETCH_ERROR_LENGTH = 4000;\n\nconst debugOpenAIFetch = getDebug('ai:call');\n\nexport interface OpenAIRequestContext {\n recordEvent?: (event: Record<string, unknown>) => void;\n responseRequestId?: {\n requestId: string;\n status: number;\n ok: boolean;\n };\n rawResponseBody?: string;\n fetchError?: string;\n httpResponse?: {\n status: number;\n ok: boolean;\n headers: Array<[string, string]>;\n body?: string;\n };\n}\n\nfunction headersToEntries(\n headers: HeadersInit | undefined,\n): Array<[string, string]> {\n const entries: Array<[string, string]> = [];\n new Headers(headers).forEach((value, key) => entries.push([key, value]));\n return entries;\n}\n\nfunction truncateText(text: string, maxLength: number): string {\n if (text.length <= maxLength) {\n return text;\n }\n\n return `${text.slice(0, maxLength)}... [truncated, ${text.length} chars total]`;\n}\n\nfunction truncateErrorResponseBody(body: string): string {\n return truncateText(body, MAX_ERROR_RESPONSE_BODY_LENGTH);\n}\n\nfunction getErrorCode(error: unknown): string | undefined {\n if (!error || typeof error !== 'object') {\n return undefined;\n }\n\n const code = (error as { code?: unknown }).code;\n return typeof code === 'string' ? code : undefined;\n}\n\nfunction formatErrorSummary(error: unknown): string {\n if (error instanceof Error) {\n const code = getErrorCode(error);\n const codeText = code ? ` [${code}]` : '';\n return `${error.name}${codeText}: ${error.message}`;\n }\n\n return String(error);\n}\n\nfunction formatFetchErrorForReport(error: unknown): string {\n const details = [formatErrorSummary(error)];\n const cause =\n error && typeof error === 'object'\n ? (error as { cause?: unknown }).cause\n : undefined;\n\n if (cause !== undefined) {\n details.push(`Cause: ${formatErrorSummary(cause)}`);\n }\n\n return truncateText(details.join('\\n'), MAX_FETCH_ERROR_LENGTH);\n}\n\n// Mirrors OpenAI SDK's default fetch selection:\n// openai@6.3.0 src/client.ts sets `this.fetch = options.fetch ?? Shims.getDefaultFetch()`,\n// and src/internal/shims.ts resolves that default to global `fetch`.\nfunction getDefaultFetch(): typeof fetch {\n if (typeof globalThis.fetch === 'function') {\n return globalThis.fetch;\n }\n\n throw new Error(\n '`fetch` is not defined as a global; check that the runtime provides globalThis.fetch or polyfill it before creating the OpenAI client',\n );\n}\n\nexport function wrapOpenAICompatibleFetch(\n context: OpenAIRequestContext,\n): typeof fetch {\n const baseFetch = getDefaultFetch();\n\n return async (input, init) => {\n if (context.recordEvent) {\n // Midscene does not expose a custom fetch hook. The OpenAI SDK therefore\n // always invokes this wrapper with standard Fetch API input and init.\n const request = new Request(input, init);\n context.recordEvent({\n type: 'request',\n request: {\n url: request.url,\n method: request.method,\n body: await request\n .clone()\n .text()\n .catch(() => undefined),\n },\n });\n }\n let response: Response;\n try {\n response = await baseFetch(input, init);\n } catch (error) {\n const fetchErrorSummary = formatFetchErrorForReport(error);\n debugOpenAIFetch('OpenAI-compatible fetch failed', fetchErrorSummary);\n context.fetchError = fetchErrorSummary;\n context.recordEvent?.({\n type: 'error',\n error: fetchErrorSummary,\n });\n throw error;\n }\n\n const requestId =\n response.headers.get('x-request-id') ??\n response.headers.get('x-model-request-id');\n\n if (requestId) {\n context.responseRequestId = {\n requestId,\n status: response.status,\n ok: response.ok,\n };\n }\n\n if (!response.ok) {\n // OpenAI SDK only exposes the `error` field for JSON error responses.\n // Non-standard provider bodies like `{ err: 'xxx' }` would otherwise be\n // hidden from Midscene's final error message.\n const rawResponseBody = await response\n .clone()\n .text()\n .catch(() => undefined);\n\n context.rawResponseBody = rawResponseBody;\n }\n\n if (context.recordEvent) {\n const isStream = response.headers\n .get('content-type')\n ?.includes('text/event-stream');\n const body = isStream\n ? undefined\n : await response\n .clone()\n .text()\n .catch(() => undefined);\n const httpResponse = {\n status: response.status,\n ok: response.ok,\n headers: headersToEntries(response.headers),\n ...(body === undefined ? {} : { body }),\n };\n context.httpResponse = httpResponse;\n if (!response.ok) {\n context.recordEvent({ type: 'error', ...httpResponse });\n }\n }\n\n return response;\n };\n}\n\nexport function formatOpenAIAPIErrorDetails(\n _error: unknown,\n context: OpenAIRequestContext,\n): string {\n const details: string[] = [];\n\n if (context.rawResponseBody !== undefined) {\n details.push(\n `OpenAI raw error response body: ${truncateErrorResponseBody(context.rawResponseBody)}`,\n );\n }\n\n if (context.responseRequestId && !context.responseRequestId.ok) {\n const { requestId, status } = context.responseRequestId;\n details.push(\n `OpenAI error response request ID (status ${status}): ${requestId}`,\n );\n }\n\n if (context.fetchError !== undefined) {\n details.push(`OpenAI fetch error: ${context.fetchError}`);\n }\n\n if (!details.length) {\n return '';\n }\n\n return `\\n${details.join('\\n')}`;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","MAX_ERROR_RESPONSE_BODY_LENGTH","MAX_FETCH_ERROR_LENGTH","debugOpenAIFetch","getDebug","headersToEntries","headers","entries","Headers","value","truncateText","text","maxLength","truncateErrorResponseBody","body","getErrorCode","error","code","undefined","formatErrorSummary","Error","codeText","String","formatFetchErrorForReport","details","cause","getDefaultFetch","globalThis","wrapOpenAICompatibleFetch","context","baseFetch","input","init","request","Request","response","fetchErrorSummary","requestId","rawResponseBody","isStream","httpResponse","formatOpenAIAPIErrorDetails","_error","status"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACJA,MAAMI,iCAAiC;AACvC,MAAMC,yBAAyB;AAE/B,MAAMC,mBAAmBC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;AAmBlC,SAASC,iBACPC,OAA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