fix formatting
This commit is contained in:
parent
7ff3ce619e
commit
553bf51a7f
3 changed files with 39 additions and 55 deletions
|
|
@ -220,7 +220,8 @@ export function validateNode(
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
errors.push(
|
errors.push(
|
||||||
`${type} is missing ${template.display_name || toNormalCase(template[t].name)
|
`${type} is missing ${
|
||||||
|
template.display_name || toNormalCase(template[t].name)
|
||||||
}.`
|
}.`
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
|
|
@ -233,12 +234,14 @@ export function validateNode(
|
||||||
) {
|
) {
|
||||||
if (hasDuplicateKeys(template[t].value))
|
if (hasDuplicateKeys(template[t].value))
|
||||||
errors.push(
|
errors.push(
|
||||||
`${type} (${template.display_name || template[t].name
|
`${type} (${
|
||||||
|
template.display_name || template[t].name
|
||||||
}) contains duplicate keys with the same values.`
|
}) contains duplicate keys with the same values.`
|
||||||
);
|
);
|
||||||
if (hasEmptyKey(template[t].value))
|
if (hasEmptyKey(template[t].value))
|
||||||
errors.push(
|
errors.push(
|
||||||
`${type} (${template.display_name || template[t].name
|
`${type} (${
|
||||||
|
template.display_name || template[t].name
|
||||||
}) field must not be empty.`
|
}) field must not be empty.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +339,6 @@ export function convertArrayToObj(arrayOfObjects) {
|
||||||
return objConverted;
|
return objConverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function hasDuplicateKeys(array) {
|
export function hasDuplicateKeys(array) {
|
||||||
const keys = {};
|
const keys = {};
|
||||||
for (const obj of array) {
|
for (const obj of array) {
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ export function buildTweakObject(tweak: tweakType) {
|
||||||
for (let kp in el[key]) {
|
for (let kp in el[key]) {
|
||||||
try {
|
try {
|
||||||
el[key][kp] = JSON.parse(el[key][kp]);
|
el[key][kp] = JSON.parse(el[key][kp]);
|
||||||
} catch { }
|
} catch {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -314,24 +314,21 @@ export function getPythonApiCode(
|
||||||
return `import requests
|
return `import requests
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
BASE_API_URL = "${window.location.protocol}//${window.location.host
|
BASE_API_URL = "${window.location.protocol}//${
|
||||||
|
window.location.host
|
||||||
}/api/v1/process"
|
}/api/v1/process"
|
||||||
FLOW_ID = "${flowId}"
|
FLOW_ID = "${flowId}"
|
||||||
# You can tweak the flow by adding a tweaks dictionary
|
# You can tweak the flow by adding a tweaks dictionary
|
||||||
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
|
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
|
||||||
TWEAKS = ${tweak && tweak.length > 0
|
TWEAKS = ${
|
||||||
|
tweak && tweak.length > 0
|
||||||
? buildTweakObject(tweak)
|
? buildTweakObject(tweak)
|
||||||
: JSON.stringify(tweaks, null, 2)
|
: JSON.stringify(tweaks, null, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
def run_flow(inputs: dict, flow_id: str, tweaks: Optional[dict] = None${!isAuth ? `, apiKey: str=""` : ""
|
|
||||||
}) -> dict:
|
|
||||||
=======
|
|
||||||
def run_flow(inputs: dict, flow_id: str, tweaks: Optional[dict] = None${
|
def run_flow(inputs: dict, flow_id: str, tweaks: Optional[dict] = None${
|
||||||
!isAuth ? `, api_key: Optional[str] = None` : ""
|
!isAuth ? `, api_key: Optional[str] = None` : ""
|
||||||
}) -> dict:
|
}) -> dict:
|
||||||
>>>>>>> 1773f3fda830988438e7f3e3aa40959f1df692f5
|
|
||||||
"""
|
"""
|
||||||
Run a flow with a given message and optional tweaks.
|
Run a flow with a given message and optional tweaks.
|
||||||
|
|
||||||
|
|
@ -354,14 +351,9 @@ def run_flow(inputs: dict, flow_id: str, tweaks: Optional[dict] = None${
|
||||||
# Setup any tweaks you want to apply to the flow
|
# Setup any tweaks you want to apply to the flow
|
||||||
inputs = ${inputs}
|
inputs = ${inputs}
|
||||||
${!isAuth ? `api_key = "<your api key>"` : ""}
|
${!isAuth ? `api_key = "<your api key>"` : ""}
|
||||||
<<<<<<< HEAD
|
|
||||||
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS${!isAuth ? `, apiKey=api_key` : ""
|
|
||||||
}))`;
|
|
||||||
=======
|
|
||||||
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS${
|
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS${
|
||||||
!isAuth ? `, api_key=api_key` : ""
|
!isAuth ? `, api_key=api_key` : ""
|
||||||
}))`;
|
}))`;
|
||||||
>>>>>>> 1773f3fda830988438e7f3e3aa40959f1df692f5
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -380,13 +372,6 @@ export function getCurlCode(
|
||||||
const inputs = buildInputs(tabsState!, flow.id);
|
const inputs = buildInputs(tabsState!, flow.id);
|
||||||
|
|
||||||
return `curl -X POST \\
|
return `curl -X POST \\
|
||||||
<<<<<<< HEAD
|
|
||||||
${window.location.protocol}//${window.location.host
|
|
||||||
}/api/v1/process/${flowId} \\
|
|
||||||
-H 'Content-Type: application/json'\\
|
|
||||||
${!isAuth ? `-H 'api-key: <your api key>'\\` : ""}
|
|
||||||
-d '{"inputs": ${inputs}, "tweaks": ${tweak && tweak.length > 0
|
|
||||||
=======
|
|
||||||
${window.location.protocol}//${
|
${window.location.protocol}//${
|
||||||
window.location.host
|
window.location.host
|
||||||
}/api/v1/process/${flowId} \\
|
}/api/v1/process/${flowId} \\
|
||||||
|
|
@ -395,7 +380,6 @@ export function getCurlCode(
|
||||||
}
|
}
|
||||||
-d '{"inputs": ${inputs}, "tweaks": ${
|
-d '{"inputs": ${inputs}, "tweaks": ${
|
||||||
tweak && tweak.length > 0
|
tweak && tweak.length > 0
|
||||||
>>>>>>> 1773f3fda830988438e7f3e3aa40959f1df692f5
|
|
||||||
? buildTweakObject(tweak)
|
? buildTweakObject(tweak)
|
||||||
: JSON.stringify(tweaks, null, 2)
|
: JSON.stringify(tweaks, null, 2)
|
||||||
}}'`;
|
}}'`;
|
||||||
|
|
@ -415,7 +399,8 @@ export function getPythonCode(
|
||||||
const tweaks = buildTweaks(flow);
|
const tweaks = buildTweaks(flow);
|
||||||
const inputs = buildInputs(tabsState!, flow.id);
|
const inputs = buildInputs(tabsState!, flow.id);
|
||||||
return `from langflow import load_flow_from_json
|
return `from langflow import load_flow_from_json
|
||||||
TWEAKS = ${tweak && tweak.length > 0
|
TWEAKS = ${
|
||||||
|
tweak && tweak.length > 0
|
||||||
? buildTweakObject(tweak)
|
? buildTweakObject(tweak)
|
||||||
: JSON.stringify(tweaks, null, 2)
|
: JSON.stringify(tweaks, null, 2)
|
||||||
}
|
}
|
||||||
|
|
@ -448,22 +433,19 @@ chat_input_field: Input key that you want the chat to send the user message with
|
||||||
<langflow-chat
|
<langflow-chat
|
||||||
window_title="${flowName}"
|
window_title="${flowName}"
|
||||||
flow_id="${flowId}"
|
flow_id="${flowId}"
|
||||||
${tabsState![flow.id] && tabsState![flow.id].formKeysData
|
${
|
||||||
|
tabsState![flow.id] && tabsState![flow.id].formKeysData
|
||||||
? `chat_inputs='${inputs}'
|
? `chat_inputs='${inputs}'
|
||||||
chat_input_field="${chat_input_field}"
|
chat_input_field="${chat_input_field}"
|
||||||
`
|
`
|
||||||
: ""
|
: ""
|
||||||
}host_url="http://localhost:7860"${!isAuth
|
}host_url="http://localhost:7860"${
|
||||||
|
!isAuth
|
||||||
? `
|
? `
|
||||||
api_key="..."`
|
api_key="..."`
|
||||||
: ""
|
: ""
|
||||||
<<<<<<< HEAD
|
|
||||||
}
|
}
|
||||||
|
|
||||||
=======
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> 1773f3fda830988438e7f3e3aa40959f1df692f5
|
|
||||||
></langflow-chat>`;
|
></langflow-chat>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue