✨ extraBodyProperties
This commit is contained in:
parent
c8d793ec45
commit
7ad086a0fe
5 changed files with 48 additions and 3 deletions
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -503,6 +503,7 @@ export interface RequestOptions {
|
|||
caBundlePath?: string | string[];
|
||||
proxy?: string;
|
||||
headers?: { [key: string]: string };
|
||||
extraBodyProperties?: { [key: string]: string };
|
||||
}
|
||||
|
||||
export interface StepWithParams {
|
||||
|
|
|
|||
11
docs/static/schemas/config.json
vendored
11
docs/static/schemas/config.json
vendored
|
|
@ -87,6 +87,14 @@
|
|||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"extraBodyProperties": {
|
||||
"title": "Extra Body Properties",
|
||||
"description": "This object will be merged with the body when making the HTTP requests",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -216,7 +224,8 @@
|
|||
"verifySsl": null,
|
||||
"caBundlePath": null,
|
||||
"proxy": null,
|
||||
"headers": null
|
||||
"headers": null,
|
||||
"extraBodyProperties": null
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -87,6 +87,14 @@
|
|||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"extraBodyProperties": {
|
||||
"title": "Extra Body Properties",
|
||||
"description": "This object will be merged with the body when making the HTTP requests",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -216,7 +224,8 @@
|
|||
"verifySsl": null,
|
||||
"caBundlePath": null,
|
||||
"proxy": null,
|
||||
"headers": null
|
||||
"headers": null,
|
||||
"extraBodyProperties": null
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -94,6 +94,14 @@
|
|||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"extraBodyProperties": {
|
||||
"title": "Extra Body Properties",
|
||||
"description": "This object will be merged with the body when making the HTTP requests",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -223,7 +231,8 @@
|
|||
"verifySsl": null,
|
||||
"caBundlePath": null,
|
||||
"proxy": null,
|
||||
"headers": null
|
||||
"headers": null,
|
||||
"extraBodyProperties": null
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -148,8 +148,25 @@ function setupLlm(llm: ILLM): ILLM {
|
|||
headers[key] = value as string;
|
||||
}
|
||||
|
||||
let updatedBody: string | undefined = undefined;
|
||||
try {
|
||||
if (
|
||||
llm.requestOptions?.extraBodyProperties &&
|
||||
typeof init.body === "string"
|
||||
) {
|
||||
const parsedBody = JSON.parse(init.body);
|
||||
updatedBody = JSON.stringify({
|
||||
...parsedBody,
|
||||
...llm.requestOptions.extraBodyProperties,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Unable to parse HTTP request body: ", e);
|
||||
}
|
||||
|
||||
const resp = await fetch(input, {
|
||||
...init,
|
||||
body: updatedBody ?? init.body,
|
||||
headers,
|
||||
agent,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue