(codeLang, configData)
| 578 | // ----------------------------CONFIG JSON--------------------------// |
| 579 | |
| 580 | const getConfigCode = (codeLang, configData) => { |
| 581 | if (codeLang === 'Python') { |
| 582 | return `import requests |
| 583 | |
| 584 | API_URL = "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}" |
| 585 | |
| 586 | def query(payload): |
| 587 | response = requests.post(API_URL, json=payload) |
| 588 | return response.json() |
| 589 | |
| 590 | output = 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 | |
| 612 | query({ |
| 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 |
no test coverage detected