-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dee5d56
commit 5269cd9
Showing
18 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Call your Deployed Flows\n", | ||
"\n", | ||
"This is a notebook to show how to call your deployed flows using the `requests` library in raw python.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import requests\n", | ||
"from typing import Optional\n", | ||
"\n", | ||
"# Update this to the base URL of your endpoint, available in the Kalavai dashboard\n", | ||
"BASE_API_URL = \"https://adam.playground.test.k8s.mvp.kalavai.net/api/v1/process\"\n", | ||
"\n", | ||
"# Update this to the flow ID you want to run\n", | ||
"FLOW_ID = \"24073dfd-c66a-441c-8951-78588f0bd2d7\"\n", | ||
"\n", | ||
"# You can tweak the flow by adding a tweaks dictionary\n", | ||
"# e.g {\"OpenAI-XXXXX\": {\"model_name\": \"gpt-4\"}}\n", | ||
"TWEAKS = {\n", | ||
" \"KalavaiLlm-UTSYC\": {},\n", | ||
" \"RetrievalQA-JFfxD\": {},\n", | ||
" \"CombineDocsChain-RoWar\": {},\n", | ||
" \"VectorStoreRetriever-HhAfJ\": {},\n", | ||
" \"KalavaiDB-yi2jj\": {},\n", | ||
" \"KalavaiEmbedding-u7wya\": {},\n", | ||
" \"CharacterTextSplitter-o2vyX\": {},\n", | ||
" \"TextLoader-QZBao\": {}\n", | ||
"}\n", | ||
"\n", | ||
"def run_flow(inputs: dict, flow_id: str, tweaks: Optional[dict] = None, api_key: Optional[str] = None) -> dict:\n", | ||
" \"\"\"\n", | ||
" Run a flow with a given message and optional tweaks.\n", | ||
"\n", | ||
" :param message: The message to send to the flow\n", | ||
" :param flow_id: The ID of the flow to run\n", | ||
" :param tweaks: Optional tweaks to customize the flow\n", | ||
" :return: The JSON response from the flow\n", | ||
" \"\"\"\n", | ||
" api_url = f\"{BASE_API_URL}/{flow_id}\"\n", | ||
"\n", | ||
" payload = {\"inputs\": inputs}\n", | ||
" headers = None\n", | ||
" if tweaks:\n", | ||
" payload[\"tweaks\"] = tweaks\n", | ||
" if api_key:\n", | ||
" headers = {\"x-api-key\": api_key}\n", | ||
" response = requests.post(api_url, json=payload, headers=headers)\n", | ||
" return response.json()\n", | ||
"\n", | ||
"# Setup any tweaks you want to apply to the flow\n", | ||
"inputs = {\"query\":\"Hello\"}\n", | ||
"\n", | ||
"# Get this from the LANGFLOW repository, as shown in the Documentatuin\n", | ||
"api_key = \"sk-...\"\n", | ||
"r = run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS, api_key=api_key)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "agent", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |