Add fallback_to_env_vars reference to code example
This commit is contained in:
parent
0fd6660cf6
commit
09cfe156cc
1 changed files with 15 additions and 14 deletions
|
|
@ -60,7 +60,7 @@ export function normalCaseToSnakeCase(str: string): string {
|
||||||
|
|
||||||
export function toTitleCase(
|
export function toTitleCase(
|
||||||
str: string | undefined,
|
str: string | undefined,
|
||||||
isNodeField?: boolean,
|
isNodeField?: boolean
|
||||||
): string {
|
): string {
|
||||||
if (!str) return "";
|
if (!str) return "";
|
||||||
let result = str
|
let result = str
|
||||||
|
|
@ -69,7 +69,7 @@ export function toTitleCase(
|
||||||
if (isNodeField) return word;
|
if (isNodeField) return word;
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return checkUpperWords(
|
return checkUpperWords(
|
||||||
word[0].toUpperCase() + word.slice(1).toLowerCase(),
|
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return checkUpperWords(word.toLowerCase());
|
return checkUpperWords(word.toLowerCase());
|
||||||
|
|
@ -82,7 +82,7 @@ export function toTitleCase(
|
||||||
if (isNodeField) return word;
|
if (isNodeField) return word;
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return checkUpperWords(
|
return checkUpperWords(
|
||||||
word[0].toUpperCase() + word.slice(1).toLowerCase(),
|
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return checkUpperWords(word.toLowerCase());
|
return checkUpperWords(word.toLowerCase());
|
||||||
|
|
@ -122,7 +122,7 @@ export function groupByFamily(
|
||||||
data: APIDataType,
|
data: APIDataType,
|
||||||
baseClasses: string,
|
baseClasses: string,
|
||||||
left: boolean,
|
left: boolean,
|
||||||
flow?: NodeType[],
|
flow?: NodeType[]
|
||||||
): groupedObjType[] {
|
): groupedObjType[] {
|
||||||
const baseClassesSet = new Set(baseClasses.split("\n"));
|
const baseClassesSet = new Set(baseClasses.split("\n"));
|
||||||
let arrOfPossibleInputs: Array<{
|
let arrOfPossibleInputs: Array<{
|
||||||
|
|
@ -148,7 +148,7 @@ export function groupByFamily(
|
||||||
baseClassesSet.has(template.type)) ||
|
baseClassesSet.has(template.type)) ||
|
||||||
(template.input_types &&
|
(template.input_types &&
|
||||||
template.input_types.some((inputType) =>
|
template.input_types.some((inputType) =>
|
||||||
baseClassesSet.has(inputType),
|
baseClassesSet.has(inputType)
|
||||||
)))
|
)))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -168,7 +168,7 @@ export function groupByFamily(
|
||||||
hasBaseClassInBaseClasses:
|
hasBaseClassInBaseClasses:
|
||||||
foundNode?.hasBaseClassInBaseClasses ||
|
foundNode?.hasBaseClassInBaseClasses ||
|
||||||
nodeData.node!.base_classes.some((baseClass) =>
|
nodeData.node!.base_classes.some((baseClass) =>
|
||||||
baseClassesSet.has(baseClass),
|
baseClassesSet.has(baseClass)
|
||||||
), //seta como anterior ou verifica se o node tem base class
|
), //seta como anterior ou verifica se o node tem base class
|
||||||
displayName: nodeData.node?.display_name,
|
displayName: nodeData.node?.display_name,
|
||||||
});
|
});
|
||||||
|
|
@ -185,10 +185,10 @@ export function groupByFamily(
|
||||||
if (!foundNode) {
|
if (!foundNode) {
|
||||||
foundNode = {
|
foundNode = {
|
||||||
hasBaseClassInTemplate: Object.values(node!.template).some(
|
hasBaseClassInTemplate: Object.values(node!.template).some(
|
||||||
checkBaseClass,
|
checkBaseClass
|
||||||
),
|
),
|
||||||
hasBaseClassInBaseClasses: node!.base_classes.some((baseClass) =>
|
hasBaseClassInBaseClasses: node!.base_classes.some((baseClass) =>
|
||||||
baseClassesSet.has(baseClass),
|
baseClassesSet.has(baseClass)
|
||||||
),
|
),
|
||||||
displayName: node?.display_name,
|
displayName: node?.display_name,
|
||||||
};
|
};
|
||||||
|
|
@ -245,7 +245,7 @@ export function getRandomDescription(): string {
|
||||||
export function getRandomName(
|
export function getRandomName(
|
||||||
retry: number = 0,
|
retry: number = 0,
|
||||||
noSpace: boolean = false,
|
noSpace: boolean = false,
|
||||||
maxRetries: number = 3,
|
maxRetries: number = 3
|
||||||
): string {
|
): string {
|
||||||
const left: string[] = ADJECTIVES;
|
const left: string[] = ADJECTIVES;
|
||||||
const right: string[] = NOUNS;
|
const right: string[] = NOUNS;
|
||||||
|
|
@ -324,7 +324,7 @@ export function getChatInputField(flowState?: FlowState) {
|
||||||
export function getPythonApiCode(
|
export function getPythonApiCode(
|
||||||
flowId: string,
|
flowId: string,
|
||||||
isAuth: boolean,
|
isAuth: boolean,
|
||||||
tweaksBuildedObject,
|
tweaksBuildedObject
|
||||||
): string {
|
): string {
|
||||||
return `import requests
|
return `import requests
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
@ -381,7 +381,7 @@ print(run_flow(message=message, flow_id=FLOW_ID, tweaks=TWEAKS${
|
||||||
export function getCurlCode(
|
export function getCurlCode(
|
||||||
flowId: string,
|
flowId: string,
|
||||||
isAuth: boolean,
|
isAuth: boolean,
|
||||||
tweaksBuildedObject,
|
tweaksBuildedObject
|
||||||
): string {
|
): string {
|
||||||
return `curl -X POST \\
|
return `curl -X POST \\
|
||||||
${window.location.protocol}//${
|
${window.location.protocol}//${
|
||||||
|
|
@ -426,6 +426,7 @@ TWEAKS = ${JSON.stringify(tweaksBuildedObject, null, 2)}
|
||||||
|
|
||||||
result = run_flow_from_json(flow="${flowName}.json",
|
result = run_flow_from_json(flow="${flowName}.json",
|
||||||
input_value="message",
|
input_value="message",
|
||||||
|
fallback_to_env_vars=True, # False by default
|
||||||
tweaks=TWEAKS)`;
|
tweaks=TWEAKS)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -437,7 +438,7 @@ result = run_flow_from_json(flow="${flowName}.json",
|
||||||
export function getWidgetCode(
|
export function getWidgetCode(
|
||||||
flowId: string,
|
flowId: string,
|
||||||
flowName: string,
|
flowName: string,
|
||||||
isAuth: boolean,
|
isAuth: boolean
|
||||||
): string {
|
): string {
|
||||||
return `<script src="https://cdn.jsdelivr.net/gh/langflow-ai/langflow-embedded-chat@1.0_alpha/dist/build/static/js/bundle.min.js"></script>
|
return `<script src="https://cdn.jsdelivr.net/gh/langflow-ai/langflow-embedded-chat@1.0_alpha/dist/build/static/js/bundle.min.js"></script>
|
||||||
|
|
||||||
|
|
@ -562,7 +563,7 @@ export function checkLocalStorageKey(key: string): boolean {
|
||||||
|
|
||||||
export function IncrementObjectKey(
|
export function IncrementObjectKey(
|
||||||
object: object,
|
object: object,
|
||||||
key: string,
|
key: string
|
||||||
): { newKey: string; increment: number } {
|
): { newKey: string; increment: number } {
|
||||||
let count = 1;
|
let count = 1;
|
||||||
const type = removeCountFromString(key);
|
const type = removeCountFromString(key);
|
||||||
|
|
@ -634,7 +635,7 @@ export function getSetFromObject(obj: object, key?: string): Set<string> {
|
||||||
|
|
||||||
export function getFieldTitle(
|
export function getFieldTitle(
|
||||||
template: APITemplateType,
|
template: APITemplateType,
|
||||||
templateField: string,
|
templateField: string
|
||||||
): string {
|
): string {
|
||||||
return template[templateField].display_name
|
return template[templateField].display_name
|
||||||
? template[templateField].display_name!
|
? template[templateField].display_name!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue