From 3eb22e83ed91a1cfe06da98298070e0796912391 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Wed, 24 Apr 2024 21:32:46 +0800 Subject: [PATCH 1/4] Update docs/how-to-guides/develop-a-flex-flow/index.md Co-authored-by: Zhengfei Wang <38847871+zhengfeiwang@users.noreply.github.com> --- docs/how-to-guides/develop-a-flex-flow/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/how-to-guides/develop-a-flex-flow/index.md b/docs/how-to-guides/develop-a-flex-flow/index.md index 812ba7d659e..4eebbf5c08b 100644 --- a/docs/how-to-guides/develop-a-flex-flow/index.md +++ b/docs/how-to-guides/develop-a-flex-flow/index.md @@ -4,7 +4,7 @@ This is an experimental feature, and may change at any time. Learn [more](../faq.md#stable-vs-experimental). ::: -Flex flow is short cut for flexible flow. Which means it works for most scenarios with little adjustment. +Flex flow is short cut for flexible flow, which means it works for most scenarios with little adjustment. We provide guides on how to develop a flow by writing a flow yaml from scratch in this section. From 0b85dc9f550f29498bb3d76e5320ebe6fd02ca76 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Wed, 24 Apr 2024 21:44:14 +0800 Subject: [PATCH 2/4] update comment --- .../develop-a-flex-flow/class-based-flow.md | 41 +++++++++++++++++++ .../function-based-flow.md | 29 +++++++++++++ 2 files changed, 70 insertions(+) diff --git a/docs/how-to-guides/develop-a-flex-flow/class-based-flow.md b/docs/how-to-guides/develop-a-flex-flow/class-based-flow.md index 270b131d493..ca1c0f1cc37 100644 --- a/docs/how-to-guides/develop-a-flex-flow/class-based-flow.md +++ b/docs/how-to-guides/develop-a-flex-flow/class-based-flow.md @@ -73,11 +73,25 @@ Check [here](../chat-with-a-flow/index.md) for more information. User can also batch run a flex flow without YAML. Instead of calling `pf.save` to create flow YAML first. +::::{tab-set} +:::{tab-item} CLI +:sync: CLI + +```bash +pf run create --flow "path.to.module:ClassName" --data "./data.jsonl" +``` + +::: + +:::{tab-item} SDK +:sync: SDK ```python # user can also directly use entry in `flow` param for batch run pf.run(flow="path.to.module:ClassName", data="./data.jsonl") ``` +::: + Or directly run the imported flow class or flow instance. **Note**: this only works in local. @@ -94,6 +108,32 @@ pf.run(flow=flow_obj, data="./data.jsonl") User can batch run a flex flow. Flow init function's param is supported by `init` parameter. +::::{tab-set} +:::{tab-item} CLI +:sync: CLI + +User need to write an JSON file as init's value since it's hard to write model config in command line. + +```json +{ + "model_config": { + "azure_endpoint": "my_endpoint", + "azure_deployment": "my_deployment", + "api_key": "actual_api_key" + }, + "flow_config": {} +} +``` + +```bash +pf run create --flow "./flow.flex.yaml" --data "./data.jsonl" --init init.json +``` + +::: + +:::{tab-item} SDK +:sync: SDK + ```python pf = PFClient() @@ -113,6 +153,7 @@ config = AzureOpenAIModelConfiguration( pfazure.run(flow="./flow.flex.yaml", init={"model_config": config, "flow_config": {}}, data="./data.jsonl") ``` +::: ## Serve diff --git a/docs/how-to-guides/develop-a-flex-flow/function-based-flow.md b/docs/how-to-guides/develop-a-flex-flow/function-based-flow.md index 87f0351f327..9e729543715 100644 --- a/docs/how-to-guides/develop-a-flex-flow/function-based-flow.md +++ b/docs/how-to-guides/develop-a-flex-flow/function-based-flow.md @@ -61,20 +61,49 @@ Check [here](../chat-with-a-flow/index.md) for more information. User can also batch run a flex flow without YAML. Instead of calling `pf.save` to create flow YAML first. +::::{tab-set} +:::{tab-item} CLI +:sync: CLI + +```bash +pf run create --flow "path.to.module:function_name" --data "./data.jsonl" +``` + +::: + +:::{tab-item} SDK +:sync: SDK ```python # user can also directly use entry in `flow` param for batch run pf.run(flow="path.to.module:function_name", data="./data.jsonl") ``` +::: + ## Batch run with YAML User can batch run a flex flow with YAML. +::::{tab-set} +:::{tab-item} CLI +:sync: CLI + +```bash +pf run create --flow "./flow.flex.yaml" --data "./data.jsonl" +``` + +::: + +:::{tab-item} SDK +:sync: SDK + ```python pf = PFClient() pf.run(flow="./flow.flex.yaml", data="./data.jsonl") ``` +::: + Or directly run the imported function. **Note**: this only works in local. From 5572d5fa8e3bb3fc0d4558199f7f476f8a0c7c8d Mon Sep 17 00:00:00 2001 From: Han Wang Date: Wed, 24 Apr 2024 21:59:27 +0800 Subject: [PATCH 3/4] fix --- docs/how-to-guides/develop-a-flex-flow/class-based-flow.md | 2 ++ docs/how-to-guides/develop-a-flex-flow/function-based-flow.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/how-to-guides/develop-a-flex-flow/class-based-flow.md b/docs/how-to-guides/develop-a-flex-flow/class-based-flow.md index ca1c0f1cc37..702cce0706a 100644 --- a/docs/how-to-guides/develop-a-flex-flow/class-based-flow.md +++ b/docs/how-to-guides/develop-a-flex-flow/class-based-flow.md @@ -91,6 +91,7 @@ pf.run(flow="path.to.module:ClassName", data="./data.jsonl") ``` ::: +:::: Or directly run the imported flow class or flow instance. **Note**: this only works in local. @@ -154,6 +155,7 @@ pfazure.run(flow="./flow.flex.yaml", init={"model_config": config, "flow_config" ``` ::: +:::: ## Serve diff --git a/docs/how-to-guides/develop-a-flex-flow/function-based-flow.md b/docs/how-to-guides/develop-a-flex-flow/function-based-flow.md index 9e729543715..9cc4c6108d1 100644 --- a/docs/how-to-guides/develop-a-flex-flow/function-based-flow.md +++ b/docs/how-to-guides/develop-a-flex-flow/function-based-flow.md @@ -79,6 +79,7 @@ pf.run(flow="path.to.module:function_name", data="./data.jsonl") ``` ::: +:::: ## Batch run with YAML @@ -103,6 +104,7 @@ pf.run(flow="./flow.flex.yaml", data="./data.jsonl") ``` ::: +:::: Or directly run the imported function. **Note**: this only works in local. From 768b5b2bf4f448af8564652676521f66800af7f9 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Wed, 24 Apr 2024 22:16:05 +0800 Subject: [PATCH 4/4] update --- docs/how-to-guides/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/how-to-guides/index.md b/docs/how-to-guides/index.md index 2ef3019f381..7e8e4947517 100644 --- a/docs/how-to-guides/index.md +++ b/docs/how-to-guides/index.md @@ -8,6 +8,12 @@ Simple and short articles grouped by topics, each introduces a core feature of p tracing/index ``` +```{toctree} +:caption: FlexFlow +:maxdepth: 1 +develop-a-flex-flow/index +``` + ```{toctree} :caption: Flow :maxdepth: 1