-
Notifications
You must be signed in to change notification settings - Fork 895
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
Showing
1 changed file
with
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Example1: Load flow as a function with inputs" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "ImportError", | ||
"evalue": "cannot import name 'load_flow' from 'promptflow' (D:\\code\\PromptFlow\\src\\promptflow-sdk\\promptflow\\__init__.py)", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)", | ||
"\u001b[1;32md:\\code\\prompt-flow\\examples\\tutorials\\flow-as-a-function\\sample.ipynb Cell 2\u001b[0m line \u001b[0;36m1\n\u001b[1;32m----> <a href='vscode-notebook-cell:/d%3A/code/prompt-flow/examples/tutorials/flow-as-a-function/sample.ipynb#W1sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mpromptflow\u001b[39;00m \u001b[39mimport\u001b[39;00m load_flow\n\u001b[0;32m <a href='vscode-notebook-cell:/d%3A/code/prompt-flow/examples/tutorials/flow-as-a-function/sample.ipynb#W1sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m flow_path\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m../../flows/standard/web-classification\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m <a href='vscode-notebook-cell:/d%3A/code/prompt-flow/examples/tutorials/flow-as-a-function/sample.ipynb#W1sZmlsZQ%3D%3D?line=5'>6</a>\u001b[0m f \u001b[39m=\u001b[39m load_flow(source\u001b[39m=\u001b[39mflow_path)\n", | ||
"\u001b[1;31mImportError\u001b[0m: cannot import name 'load_flow' from 'promptflow' (D:\\code\\PromptFlow\\src\\promptflow-sdk\\promptflow\\__init__.py)" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from promptflow import load_flow\n", | ||
"\n", | ||
"\n", | ||
"flow_path=\"../../flows/standard/web-classification\"\n", | ||
"\n", | ||
"f = load_flow(source=flow_path)\n", | ||
"\n", | ||
"result = f(url=\"https://www.youtube.com/watch?v=o5ZQyXaAv1g\")\n", | ||
"\n", | ||
"print(result)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Example2: Load flow as a function with connection overwrite" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"flow_path=\"../../flows/standard/web-classification\"\n", | ||
"\n", | ||
"f = load_flow(\n", | ||
" source=flow_path,\n", | ||
" # need to create the connection\n", | ||
" connections={\"classify_with_llm\": {\"connection\": \"not_exist\"}},\n", | ||
")\n", | ||
"\n", | ||
"result = f(url=\"https://www.youtube.com/watch?v=o5ZQyXaAv1g\")\n", | ||
"\n", | ||
"print(result)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"f = load_flow(\n", | ||
" source=flow_path,\n", | ||
" variant=\"${summarize_text_content.variant_0}\",\n", | ||
")\n", | ||
"\n", | ||
"result = f(url=\"https://www.youtube.com/watch?v=o5ZQyXaAv1g\")\n", | ||
"\n", | ||
"print(result)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "github_v2", | ||
"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.8.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |