fix: keep mock openai responses requests
This commit is contained in:
@@ -589,6 +589,7 @@ export async function getReplyFromConfig(
|
|||||||
(agentCfg?.elevatedDefault as ElevatedLevel | undefined) ??
|
(agentCfg?.elevatedDefault as ElevatedLevel | undefined) ??
|
||||||
"on")
|
"on")
|
||||||
: "off";
|
: "off";
|
||||||
|
const _providerKey = sessionCtx.Provider?.trim().toLowerCase();
|
||||||
const resolvedBlockStreaming =
|
const resolvedBlockStreaming =
|
||||||
opts?.disableBlockStreaming === true
|
opts?.disableBlockStreaming === true
|
||||||
? "off"
|
? "off"
|
||||||
|
|||||||
@@ -278,6 +278,10 @@ describe("gateway (mock openai): tool calling", () => {
|
|||||||
|
|
||||||
const originalFetch = globalThis.fetch;
|
const originalFetch = globalThis.fetch;
|
||||||
const openaiResponsesUrl = "https://api.openai.com/v1/responses";
|
const openaiResponsesUrl = "https://api.openai.com/v1/responses";
|
||||||
|
const isOpenAIResponsesRequest = (url: string) =>
|
||||||
|
url === openaiResponsesUrl ||
|
||||||
|
url.startsWith(`${openaiResponsesUrl}/`) ||
|
||||||
|
url.startsWith(`${openaiResponsesUrl}?`);
|
||||||
const fetchImpl = async (
|
const fetchImpl = async (
|
||||||
input: RequestInfo | URL,
|
input: RequestInfo | URL,
|
||||||
init?: RequestInit,
|
init?: RequestInit,
|
||||||
@@ -289,7 +293,7 @@ describe("gateway (mock openai): tool calling", () => {
|
|||||||
? input.toString()
|
? input.toString()
|
||||||
: input.url;
|
: input.url;
|
||||||
|
|
||||||
if (url === openaiResponsesUrl) {
|
if (isOpenAIResponsesRequest(url)) {
|
||||||
const bodyText =
|
const bodyText =
|
||||||
typeof (init as { body?: unknown } | undefined)?.body !== "undefined"
|
typeof (init as { body?: unknown } | undefined)?.body !== "undefined"
|
||||||
? decodeBodyText((init as { body?: unknown }).body)
|
? decodeBodyText((init as { body?: unknown }).body)
|
||||||
|
|||||||
Reference in New Issue
Block a user