fix: input value error when tweaks are active (#4288)
fix: remove input value when tweaks are active to prevent error on api call
This commit is contained in:
parent
c8bdcf36b0
commit
4aa7aed0a9
6 changed files with 21 additions and 16 deletions
|
|
@ -12,6 +12,7 @@ export function getCurlRunCode({
|
|||
isAuth,
|
||||
tweaksBuildedObject,
|
||||
endpointName,
|
||||
activeTweaks,
|
||||
}: GetCodeType): string {
|
||||
let tweaksString = "{}";
|
||||
const inputs = useFlowStore.getState().inputs;
|
||||
|
|
@ -28,7 +29,7 @@ export function getCurlRunCode({
|
|||
-H 'Content-Type: application/json'\\${
|
||||
!isAuth ? `\n -H 'x-api-key: <your api key>'\\` : ""
|
||||
}
|
||||
-d '{"input_value": "message",
|
||||
-d '{${!activeTweaks ? `"input_value": "message",` : ""}
|
||||
"output_type": ${hasChatOutput ? '"chat"' : '"text"'},
|
||||
"input_type": ${hasChatInput ? '"chat"' : '"text"'},
|
||||
"tweaks": ${tweaksString}}'
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export default function getJsApiCode({
|
|||
isAuth,
|
||||
tweaksBuildedObject,
|
||||
endpointName,
|
||||
activeTweaks,
|
||||
}: GetCodeType): string {
|
||||
let tweaksString = "{}";
|
||||
if (tweaksBuildedObject)
|
||||
|
|
@ -49,7 +50,7 @@ export default function getJsApiCode({
|
|||
|
||||
async initiateSession(flowId, inputValue, inputType = 'chat', outputType = 'chat', stream = false, tweaks = {}) {
|
||||
const endpoint = \`/api/v1/run/\${flowId}?stream=\${stream}\`;
|
||||
return this.post(endpoint, { input_value: inputValue, input_type: inputType, output_type: outputType, tweaks: tweaks });
|
||||
return this.post(endpoint, { ${activeTweaks ? "" : "input_value: inputValue, "}input_type: inputType, output_type: outputType, tweaks: tweaks });
|
||||
}
|
||||
|
||||
async handleStream(streamUrl, onUpdate, onClose, onError) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export default function getPythonApiCode({
|
|||
flowId,
|
||||
tweaksBuildedObject,
|
||||
endpointName,
|
||||
activeTweaks,
|
||||
}: GetCodeType): string {
|
||||
let tweaksString = "{}";
|
||||
if (tweaksBuildedObject)
|
||||
|
|
@ -61,7 +62,7 @@ def run_flow(message: str,
|
|||
api_url = f"{BASE_API_URL}/api/v1/run/{endpoint}"
|
||||
|
||||
payload = {
|
||||
"input_value": message,
|
||||
${!activeTweaks ? `"input_value": message,` : ""}
|
||||
"output_type": output_type,
|
||||
"input_type": input_type,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { GetCodeType } from "@/types/tweaks";
|
|||
export default function getPythonCode({
|
||||
flowName,
|
||||
tweaksBuildedObject,
|
||||
activeTweaks,
|
||||
}: GetCodeType): string {
|
||||
let tweaksString = "{}";
|
||||
if (tweaksBuildedObject)
|
||||
|
|
@ -21,8 +22,7 @@ export default function getPythonCode({
|
|||
TWEAKS = ${tweaksString}
|
||||
|
||||
result = run_flow_from_json(flow="${flowName}.json",
|
||||
input_value="message",
|
||||
session_id="", # provide a session id if you want to use session state
|
||||
${!activeTweaks ? `input_value="message",\n ` : ""}session_id="", # provide a session id if you want to use session state
|
||||
fallback_to_env_vars=True, # False by default
|
||||
tweaks=TWEAKS)`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ export const useTweaksStore = create<TweaksStoreType>((set, get) => ({
|
|||
isAuth: autoLogin,
|
||||
tweaksBuildedObject: tweak,
|
||||
endpointName: flow?.endpoint_name,
|
||||
activeTweaks: get().activeTweaks,
|
||||
};
|
||||
|
||||
if (getCodes) {
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@ export type GetCodeType = {
|
|||
isAuth: boolean;
|
||||
tweaksBuildedObject: {};
|
||||
endpointName?: string | null;
|
||||
activeTweaks: boolean;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue