chore: import upstream snapshot with attribution
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:39:52 +08:00
commit e768098d0e
4004 changed files with 2804145 additions and 0 deletions
@@ -0,0 +1,23 @@
# Basic flow with package tool using cascading inputs
This is a flow demonstrating the use of a tool with cascading inputs which frequently used in situations where the selection in one input field determines what subsequent inputs should be shown,
and it helps in creating a more efficient, user-friendly, and error-free input process.
Tools used in this flow
- `python` Tool
Connections used in this flow:
- None
## Prerequisites
Install promptflow sdk and other dependencies:
```bash
pip install -r requirements.txt
```
## Run flow
- Test flow
```bash
pf flow test --flow .
```
@@ -0,0 +1,17 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
environment:
python_requirements_txt: requirements.txt
inputs: {}
outputs:
user_id:
type: string
reference: ${Tool_with_Cascading_Inputs.output}
nodes:
- name: Tool_with_Cascading_Inputs
type: python
source:
type: package
tool: my_tool_package.tools.tool_with_cascading_inputs.my_tool
inputs:
user_type: student
student_id: "student_id"
@@ -0,0 +1,2 @@
promptflow
my-tools-package==0.0.7
@@ -0,0 +1,72 @@
# Basic flow with package tool using custom strong type connection
This is a flow demonstrating the use of a package tool with custom string type connection which provides a secure way to manage credentials for external APIs and data sources, and it offers an improved user-friendly and intellisense experience compared to custom connections.
Tools used in this flow
- custom package tool
Connections used in this flow:
- custom strong type connection
## Prerequisites
Install promptflow sdk and other dependencies:
```bash
pip install -r requirements.txt
```
## Setup connection
Create connection if you haven't done that.
```bash
# Override keys with --set to avoid yaml file changes
pf connection create -f my_custom_connection.yml --set secrets.api_key='<your_api_key>' configs.api_base='<your_api_base>'
```
Ensure you have created `my_custom_connection` connection.
```bash
pf connection show -n my_custom_connection
```
## Run flow
### Run with single line input
```bash
# test with default input value in flow.dag.yaml
pf flow test --flow .
# test with flow inputs
pf flow test --flow . --inputs text="Promptflow"
```
### Run with multiple lines data
- create run
```bash
pf run create --flow . --data ./data.jsonl --stream
```
- list and show run meta
```bash
# list created run
pf run list -r 3
# get a sample run name
name=$(pf run list -r 10 | jq '.[] | select(.name | contains("custom_strong_type")) | .name'| head -n 1 | tr -d '"')
# show specific run detail
pf run show --name $name
# show output
pf run show-details --name $name
# visualize run in browser
pf run visualize --name $name
```
### Run with connection override
Run flow with newly created connection.
```bash
pf run create --flow . --data ./data.jsonl --connections my_package_tool.connection=my_custom_connection --stream
```
@@ -0,0 +1,3 @@
{"text": "Python Hello World!"}
{"text": "C Hello World!"}
{"text": "C# Hello World!"}
@@ -0,0 +1,18 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
text:
type: string
default: Microsoft
outputs:
my_output:
type: string
reference: ${my_package_tool.output}
nodes:
- name: my_package_tool
type: python
source:
type: package
tool: my_tool_package.tools.tool_with_custom_strong_type_connection.my_tool
inputs:
connection: my_custom_connection
input_text: ${inputs.text}
@@ -0,0 +1,11 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CustomStrongTypeConnection.schema.json
name: "my_custom_connection"
type: custom
custom_type: MyCustomConnection
module: my_tool_package.tools.tool_with_custom_strong_type_connection
package: my-tools-package
package_version: 0.0.5
configs:
api_base: "This is a fake api base." # String type. The api base.
secrets: # must-have
api_key: "to_replace_with_api_key" # Secret type. The api key get from "https://xxx.com".
@@ -0,0 +1,2 @@
promptflow[azure]
my-tools-package==0.0.5
@@ -0,0 +1,72 @@
# Basic flow with script tool using custom strong type connection
This is a flow demonstrating the use of a script tool with custom string type connection which provides a secure way to manage credentials for external APIs and data sources, and it offers an improved user-friendly and intellisense experience compared to custom connections.
Tools used in this flow
- custom `python` tool
Connections used in this flow:
- custom strong type connection
## Prerequisites
Install promptflow sdk and other dependencies:
```bash
pip install -r requirements.txt
```
## Setup connection
Create connection if you haven't done that.
```bash
# Override keys with --set to avoid yaml file changes
pf connection create -f custom.yml --set secrets.api_key='<your_api_key>' configs.api_base='<your_api_base>'
```
Ensure you have created `normal_custom_connection` connection.
```bash
pf connection show -n normal_custom_connection
```
## Run flow
### Run with single line input
```bash
# test with default input value in flow.dag.yaml
pf flow test --flow .
# test with flow inputs
pf flow test --flow . --inputs text="Promptflow"
```
### Run with multiple lines data
- create run
```bash
pf run create --flow . --data ./data.jsonl --stream
```
- list and show run meta
```bash
# list created run
pf run list -r 3
# get a sample run name
name=$(pf run list -r 10 | jq '.[] | select(.name | contains("custom_strong_type")) | .name'| head -n 1 | tr -d '"')
# show specific run detail
pf run show --name $name
# show output
pf run show-details --name $name
# visualize run in browser
pf run visualize --name $name
```
### Run with connection override
Run flow with newly created connection.
```bash
pf run create --flow . --data ./data.jsonl --connections my_script_tool.connection=normal_custom_connection --stream
```
@@ -0,0 +1,7 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CustomConnection.schema.json
name: normal_custom_connection
type: custom
configs:
api_base: test
secrets: # must-have
api_key: <to-be-replaced>
@@ -0,0 +1,3 @@
{"text": "Python Hello World!"}
{"text": "C Hello World!"}
{"text": "C# Hello World!"}
@@ -0,0 +1,18 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
text:
type: string
default: Microsoft
outputs:
my_output:
type: string
reference: ${my_script_tool.output}
nodes:
- name: my_script_tool
type: python
source:
type: code
path: my_script_tool.py
inputs:
connection: normal_custom_connection
input_text: ${inputs.text}
@@ -0,0 +1,22 @@
from promptflow.core import tool
from promptflow.connections import CustomStrongTypeConnection
from promptflow.contracts.types import Secret
class MyCustomConnection(CustomStrongTypeConnection):
"""My custom strong type connection.
:param api_key: The api key.
:type api_key: Secret
:param api_base: The api base.
:type api_base: String
"""
api_key: Secret
api_base: str = "This is a fake api base."
@tool
def my_tool(connection: MyCustomConnection, input_text: str) -> str:
# Replace with your tool code.
# Use custom strong type connection like: connection.api_key, connection.api_base
return "Hello " + input_text
@@ -0,0 +1,34 @@
# Flow with custom_llm tool
This is a flow demonstrating how to use a `custom_llm` tool, which enables users to seamlessly connect to a large language model with prompt tuning experience using a `PromptTemplate`.
Tools used in this flow:
- `custom_llm` Tool
Connections used in this flow:
- custom connection
## Prerequisites
Install promptflow sdk and other dependencies:
```bash
pip install -r requirements.txt
```
## Setup connection
Create connection if you haven't done that.
```bash
# Override keys with --set to avoid yaml file changes
pf connection create -f custom_connection.yml --set secrets.api_key=<your_api_key> configs.api_base=<your_api_base>
```
Ensure you have created `basic_custom_connection` connection.
```bash
pf connection show -n basic_custom_connection
```
## Run flow
- Test flow
```bash
pf flow test --flow .
```
@@ -0,0 +1,7 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CustomConnection.schema.json
name: basic_custom_connection
type: custom
configs:
api_base: <to-be-replaced>
secrets: # must-have
api_key: <to-be-replaced>
@@ -0,0 +1,26 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
website_name:
type: string
default: Microsoft
user_name:
type: string
default: ""
outputs:
output:
type: string
reference: ${my_custom_llm_tool.output}
nodes:
- name: my_custom_llm_tool
type: custom_llm
source:
type: package_with_prompt
tool: my_tool_package.tools.tool_with_custom_llm_type.my_tool
path: prompt_template.jinja2
inputs:
connection: basic_custom_connection
api: ''
website_name: ${inputs.website_name}
user_name: ${inputs.user_name}
deployment_name: ''
temperature: 1
@@ -0,0 +1,6 @@
Welcome to {{ website_name }}!
{% if user_name %}
Hello, {{ user_name }}!
{% else %}
Hello there!
{% endif %}
@@ -0,0 +1,2 @@
promptflow
my-tools-package
@@ -0,0 +1,22 @@
# Basic flow with tool using a dynamic list input
This is a flow demonstrating how to use a tool with a dynamic list input.
Tools used in this flow:
- `python` Tool
Connections used in this flow:
- None
## Prerequisites
Install promptflow sdk and other dependencies:
```bash
pip install -r requirements.txt
```
## Run flow
- Test flow
```bash
pf flow test --flow .
```
@@ -0,0 +1,18 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs: {}
outputs:
output:
type: string
reference: ${My_Tool_with_Dynamic_List_Input_cywc.output}
nodes:
- name: My_Tool_with_Dynamic_List_Input_cywc
type: python
source:
type: package
tool: my_tool_package.tools.tool_with_dynamic_list_input.my_tool
inputs:
input_prefix: hi
input_text:
- grape3
- elderberry5
endpoint_name: my_endpoint
@@ -0,0 +1,2 @@
promptflow
my-tools-package
@@ -0,0 +1,18 @@
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
input:
type: string
default: Microsoft
outputs:
output:
type: string
reference: ${Tool_with_FilePath_Input.output}
nodes:
- name: Tool_with_FilePath_Input
type: python
source:
type: package
tool: my_tool_package.tools.tool_with_file_path_input.my_tool
inputs:
input_text: ${inputs.input}
input_file: hello_method.py
@@ -0,0 +1,3 @@
def hello(input_text: str) -> str:
# Replace with your own code.
return "Hello " + input_text
@@ -0,0 +1,3 @@
promptflow
promptflow-tools
my-tools-package