From 0219a197ce0600703b16e78db1266fe966813174 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 14 Jun 2023 13:04:51 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat(constants.tsx):=20add=20ver?= =?UTF-8?q?sioning=20to=20API=20endpoints=20The=20API=20endpoints=20have?= =?UTF-8?q?=20been=20updated=20to=20include=20a=20version=20number=20to=20?= =?UTF-8?q?improve=20the=20maintainability=20of=20the=20codebase.=20The=20?= =?UTF-8?q?version=20number=20is=20now=20included=20in=20the=20URL=20path?= =?UTF-8?q?=20for=20both=20the=20Python=20API=20and=20the=20curl=20code.?= =?UTF-8?q?=20This=20change=20allows=20for=20future=20updates=20to=20the?= =?UTF-8?q?=20API=20without=20breaking=20existing=20code=20that=20relies?= =?UTF-8?q?=20on=20the=20previous=20version.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/constants.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/frontend/src/constants.tsx b/src/frontend/src/constants.tsx index d5ee010a7..d08aa75e7 100644 --- a/src/frontend/src/constants.tsx +++ b/src/frontend/src/constants.tsx @@ -52,7 +52,8 @@ export const TEXT_DIALOG_SUBTITLE = "Edit you text."; export const getPythonApiCode = (flowId: string): string => { return `import requests -BASE_API_URL = "${window.location.protocol}//${window.location.host}/predict" +BASE_API_URL = "${window.location.protocol}//${window.location.host}/ap1/v1/predict" +FLOW_ID = "${flowId}" def run_flow(message: str, flow_id: str, tweaks: dict = None) -> dict: """ @@ -76,11 +77,9 @@ def run_flow(message: str, flow_id: str, tweaks: dict = None) -> dict: # Setup any tweaks you want to apply to the flow tweaks = {} # {"nodeId": {"key": "value"}, "nodeId2": {"key": "value"}} -FLOW_ID = "${flowId}" print(run_flow("Your message", flow_id=FLOW_ID, tweaks=tweaks))`; }; - /** * Function to get the curl code for the API * @param {string} flowId - The id of the flow @@ -88,12 +87,10 @@ print(run_flow("Your message", flow_id=FLOW_ID, tweaks=tweaks))`; */ export const getCurlCode = (flowId: string): string => { return `curl -X POST \\ - -H "Content-Type: application/json" \\ - -H "Authorization: Bearer ${flowId}" \\ - -d '{"message": "Your message"}' \\ - ${window.location.protocol}//${window.location.host}/predict`; + ${window.location.protocol}//${window.location.host}/api/v1/predict/${flowId} \\ + -H 'Content-Type: application/json' \\ + -d '{"message": "Your message"}'`; }; - /** * Function to get the python code for the API * @param {string} flowName - The name of the flow