update message format to put api-key as header
This commit is contained in:
parent
ac67fff000
commit
187724342f
1 changed files with 23 additions and 11 deletions
|
|
@ -326,7 +326,9 @@ TWEAKS = ${
|
|||
: JSON.stringify(tweaks, null, 2)
|
||||
}
|
||||
|
||||
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${
|
||||
!isAuth ? `, apiKey: str=""` : ""
|
||||
}) -> dict:
|
||||
"""
|
||||
Run a flow with a given message and optional tweaks.
|
||||
|
||||
|
|
@ -337,18 +339,20 @@ def run_flow(inputs: dict, flow_id: str, tweaks: Optional[dict] = None${!isAuth
|
|||
"""
|
||||
api_url = f"{BASE_API_URL}/{flow_id}"
|
||||
|
||||
payload = {"inputs": inputs${!isAuth ? `, "api_key": apiKey` : ""}}
|
||||
payload = {"inputs": inputs}
|
||||
|
||||
if tweaks:
|
||||
payload["tweaks"] = tweaks
|
||||
|
||||
response = requests.post(api_url, json=payload)
|
||||
${!isAuth ? 'headers = {"api-key": apiKey}' : ""}
|
||||
response = requests.post(api_url, json=payload,headers=headers)
|
||||
return response.json()
|
||||
|
||||
# Setup any tweaks you want to apply to the flow
|
||||
inputs = ${inputs}
|
||||
${!isAuth ? `api_key = "..."` : ""}
|
||||
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS${!isAuth ? `, api_key` : ""}))`;
|
||||
${!isAuth ? `api_key = "<your api key>"` : ""}
|
||||
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS${
|
||||
!isAuth ? `, apiKey=api_key` : ""
|
||||
}))`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -370,8 +374,9 @@ export function getCurlCode(
|
|||
${window.location.protocol}//${
|
||||
window.location.host
|
||||
}/api/v1/process/${flowId} \\
|
||||
-H 'Content-Type: application/json' \\
|
||||
-d '{"inputs": ${inputs},${!isAuth ? ` "api_key": "...", ` : " "}"tweaks": ${
|
||||
-H 'Content-Type: application/json'\\
|
||||
${!isAuth ? `-H 'api-key: <your api key>'\\` : ""}
|
||||
-d '{"inputs": ${inputs}, "tweaks": ${
|
||||
tweak && tweak.length > 0
|
||||
? buildTweakObject(tweak)
|
||||
: JSON.stringify(tweaks, null, 2)
|
||||
|
|
@ -408,7 +413,11 @@ flow(inputs)`;
|
|||
* @param {string} flow - The current flow.
|
||||
* @returns {string} - The widget code
|
||||
*/
|
||||
export function getWidgetCode(flow: FlowType, isAuth: boolean, tabsState?: TabsState): string {
|
||||
export function getWidgetCode(
|
||||
flow: FlowType,
|
||||
isAuth: boolean,
|
||||
tabsState?: TabsState
|
||||
): string {
|
||||
const flowId = flow.id;
|
||||
const flowName = flow.name;
|
||||
const inputs = buildInputs(tabsState!, flow.id);
|
||||
|
|
@ -428,9 +437,12 @@ chat_input_field: Input key that you want the chat to send the user message with
|
|||
chat_input_field="${chat_input_field}"
|
||||
`
|
||||
: ""
|
||||
}host_url="http://localhost:7860"${(!isAuth ? `
|
||||
}host_url="http://localhost:7860"${
|
||||
!isAuth
|
||||
? `
|
||||
api_key="..."`
|
||||
: "")}
|
||||
: ""
|
||||
}
|
||||
|
||||
></langflow-chat>`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue