MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / getConfigCode

Function getConfigCode

packages/ui/src/views/chatflows/APICodeDialog.jsx:580–627  ·  view source on GitHub ↗
(codeLang, configData)

Source from the content-addressed store, hash-verified

578 // ----------------------------CONFIG JSON--------------------------//
579
580 const getConfigCode = (codeLang, configData) => {
581 if (codeLang === 'Python') {
582 return `import requests
583
584API_URL = "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}"
585
586def query(payload):
587 response = requests.post(API_URL, json=payload)
588 return response.json()
589
590output = query({
591 "question": "Hey, how are you?",
592 "overrideConfig": {${getConfigExamplesForPython(configData, 'json')}
593 }
594})
595`
596 } else if (codeLang === 'JavaScript') {
597 return `async function query(data) {
598 const response = await fetch(
599 "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}",
600 {
601 method: "POST",
602 headers: {
603 "Content-Type": "application/json"
604 },
605 body: JSON.stringify(data)
606 }
607 );
608 const result = await response.json();
609 return result;
610}
611
612query({
613 "question": "Hey, how are you?",
614 "overrideConfig": {${getConfigExamplesForJS(configData, 'json')}
615 }
616}).then((response) => {
617 console.log(response);
618});
619`
620 } else if (codeLang === 'cURL') {
621 return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\
622 -X POST \\
623 -d '{"question": "Hey, how are you?", "overrideConfig": {${getConfigExamplesForCurl(configData, 'json')}}' \\
624 -H "Content-Type: application/json"`
625 }
626 return ''
627 }
628
629 // ----------------------------CONFIG JSON with AUTH--------------------------//
630

Callers 1

APICodeDialogFunction · 0.85

Calls 3

getConfigExamplesForJSFunction · 0.90
getConfigExamplesForCurlFunction · 0.90

Tested by

no test coverage detected