From 5484f2dec8a4d27692f44e0bf4c1af9a2a9d99d7 Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Wed, 18 Oct 2023 14:50:50 +0800 Subject: [PATCH 01/10] add enable by doc --- .../create-and-use-tool-package.md | 3 +- .../develop-a-tool/how-to-use-enabled-by.md | 106 ++++++++++++++++++ docs/how-to-guides/develop-a-tool/index.md | 1 + 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md diff --git a/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md b/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md index 2c1ae207d8e..c6ebe7252a4 100644 --- a/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md +++ b/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md @@ -162,4 +162,5 @@ Alternatively, you can test your tool package using the script below to ensure t * If you encounter a `403 Forbidden Error`, it's likely due to a naming conflict with an existing package. You will need to choose a different name. Package names must be unique on PyPI to avoid confusion and conflicts among users. Before creating a new package, it's recommended to search PyPI (https://pypi.org/) to verify that your chosen name is not already taken. If the name you want is unavailable, consider selecting an alternative name or a variation that clearly differentiates your package from the existing one. ## Advanced features -[Customize your tool icon](add-a-tool-icon.md) \ No newline at end of file +[Customize your tool icon](add-a-tool-icon.md) +[How to use enabled by in the tool](how-to-use-enabled-by.md) \ No newline at end of file diff --git a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md new file mode 100644 index 00000000000..78c899a494d --- /dev/null +++ b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md @@ -0,0 +1,106 @@ +# How to use enabled by in the tool +## Introduction +This guide will instruct you on how to use the "enabled by" feature in the tool. The "enabled by" feature is designed to display which inputs are enabled when a customer uses a specific input type or input value. This feature is particularly beneficial if you wish to vary your inputs in response to different demands. + +We introduce parameter "enabled_by" in the tool yaml to determine which input is enabled by which other input. +Concurrently, we support enabling an input by another input type or input value, Hence, we introduce two other parameters: "enabled_by_type" and "enabled_by_value". + +> Note: We don't recommend you to use the "enabled_by_type" and "enabled_by_value" at the same time. if you use them at the same time, the "enabled_by_type" will be ignored. + +## Prerequisites +To proceed, it's crucial for you to understand the process of developing a tool and generating a tool yaml. For thorough insights and instructions, please refer to [Create and Use Tool Package](create-and-use-tool-package.md). + +## How to support enabled by +Assume you want to develop a tool with four inputs: "connection", "input", "deployment_name", and "model". The "deployment_name" and "model" are enabled by "connection" type. When the "connection" type is AzureOpenAIConnection, the "deployment_name" input is enabled and displayed. When the "connection" type is OpenAIConnection, the "model" input is enabled and displayed. Here is an example of how you can support the "enabled by" feature in your tool and tool yaml: + + +### Step 1: Support "enabled by" in the tool package +All inputs will be passed to the tool, allowing you to define your own set of rules to determine which input to use. Here is an example of how you can support the "enabled by" feature in your tool package: + + +```python +from enum import Enum +from typing import Union + +import openai + +from promptflow.connections import AzureOpenAIConnection, OpenAIConnection +from promptflow._internal import tool +from promptflow.tools.exception import InvalidConnectionType + + +class EmbeddingModel(str, Enum): + TEXT_EMBEDDING_ADA_002 = "text-embedding-ada-002" + TEXT_SEARCH_ADA_DOC_001 = "text-search-ada-doc-001" + TEXT_SEARCH_ADA_QUERY_001 = "text-search-ada-query-001" + + +@tool +def embedding(connection: Union[AzureOpenAIConnection, OpenAIConnection], input: str, deployment_name: str = "", model: EmbeddingModel = EmbeddingModel.TEXT_EMBEDDING_ADA_002): + connection_dict = dict(connection) + # if the connection type is AzureOpenAIConnection, use the deployment_name input. + if isinstance(connection, AzureOpenAIConnection): + return openai.Embedding.create( + input=input, + engine=deployment_name, + **connection_dict, + )["data"][0]["embedding"] + # if the connection type is OpenAIConnection, use the model input. + elif isinstance(connection, OpenAIConnection): + return openai.Embedding.create( + input=input, + model=model, + **connection_dict, + )["data"][0]["embedding"] + else: + error_message = f"Not Support connection type '{type(connection).__name__}' for embedding api. " \ + f"Connection type should be in [AzureOpenAIConnection, OpenAIConnection]." + raise InvalidConnectionType(message=error_message) +``` + +### Step 2: Support "enabled by" in the tool yaml +Once you have generated a tool yaml, you can incorporate the 'enabled by' feature into it. Here is an example showcasing the use of 'enabled_by_type' in the tool yaml: + +```yaml +promptflow.tools.embedding.embedding: + name: Embedding + description: Use Open AI's embedding model to create an embedding vector representing the input text. + type: python + module: promptflow.tools.embedding + function: embedding + inputs: + connection: + type: [AzureOpenAIConnection, OpenAIConnection] + deployment_name: + type: + - string + # The input deployment_name is enabled by connection + enabled_by: connection + # When the connection type is AzureOpenAIConnection, deployment_name is enabled and displayed. + enabled_by_type: [AzureOpenAIConnection] + capabilities: + completion: false + chat_completion: false + embeddings: true + model_list: + - text-embedding-ada-002 + - text-search-ada-doc-001 + - text-search-ada-query-001 + model: + type: + - string + # the input model is enabled by connection + enabled_by: connection + # When the connection type is OpenAIConnection, model is enabled and displayed. + enabled_by_type: [OpenAIConnection] + enum: + - text-embedding-ada-002 + - text-search-ada-doc-001 + - text-search-ada-query-001 + input: + type: + - string +``` + +> Note: Both "enabled_by_type" and "enabled_by_value" are list types, which means you can use multiple inputs to enable a single input. For instance, if "enabled_by_type" is [AzureOpenAIConnection, OpenAIConnection], the input will be enabled when the connection type is either AzureOpenAIConnection or OpenAIConnection. + diff --git a/docs/how-to-guides/develop-a-tool/index.md b/docs/how-to-guides/develop-a-tool/index.md index 87c8525639d..71d22c503b8 100644 --- a/docs/how-to-guides/develop-a-tool/index.md +++ b/docs/how-to-guides/develop-a-tool/index.md @@ -7,4 +7,5 @@ We provide guides on how to develop a tool and use it. create-and-use-tool-package add-a-tool-icon +how-to-use-enabled-by ``` \ No newline at end of file From de338b3c3df49c117dee7a411f15af19823ea3f4 Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Wed, 18 Oct 2023 15:37:50 +0800 Subject: [PATCH 02/10] add pic --- .../develop-a-tool/how-to-use-enabled-by.md | 23 ++++++++++-------- .../develop-a-tool/enabled_by_type.png | Bin 0 -> 16095 bytes 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 docs/media/how-to-guides/develop-a-tool/enabled_by_type.png diff --git a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md index 78c899a494d..6e460aa8a3a 100644 --- a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md +++ b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md @@ -1,21 +1,21 @@ -# How to use enabled by in the tool +# How to use enabled by in the tool package ## Introduction -This guide will instruct you on how to use the "enabled by" feature in the tool. The "enabled by" feature is designed to display which inputs are enabled when a customer uses a specific input type or input value. This feature is particularly beneficial if you wish to vary your inputs in response to different demands. +This guide will instruct you on how to use the "enabled by" feature in the tool package. The "enabled by" feature is designed to display which inputs are enabled when a customer uses a specific input type or input value. This feature is particularly useful if you need to adapt your inputs based on varying requirements. We introduce parameter "enabled_by" in the tool yaml to determine which input is enabled by which other input. -Concurrently, we support enabling an input by another input type or input value, Hence, we introduce two other parameters: "enabled_by_type" and "enabled_by_value". +Concurrently, we support enabling an input by another input type or input value, Hence, we introduce two additional parameters: "enabled_by_type" and "enabled_by_value". -> Note: We don't recommend you to use the "enabled_by_type" and "enabled_by_value" at the same time. if you use them at the same time, the "enabled_by_type" will be ignored. +> Note: We do not recommend using 'enabled_by_type' and 'enabled_by_value' simultaneously. If both are used, 'enabled_by_type' will be ignored. ## Prerequisites To proceed, it's crucial for you to understand the process of developing a tool and generating a tool yaml. For thorough insights and instructions, please refer to [Create and Use Tool Package](create-and-use-tool-package.md). ## How to support enabled by -Assume you want to develop a tool with four inputs: "connection", "input", "deployment_name", and "model". The "deployment_name" and "model" are enabled by "connection" type. When the "connection" type is AzureOpenAIConnection, the "deployment_name" input is enabled and displayed. When the "connection" type is OpenAIConnection, the "model" input is enabled and displayed. Here is an example of how you can support the "enabled by" feature in your tool and tool yaml: +Assume you want to develop a tool with four inputs: "connection", "input", "deployment_name", and "model". The "deployment_name" and "model" are enabled by "connection" type. When the "connection" type is AzureOpenAIConnection, the "deployment_name" input is enabled and displayed. When the "connection" type is OpenAIConnection, the "model" input is enabled and displayed. You need to support enable by in two part: tool and tool yaml. Here is an example of how you can support the "enabled by" feature in your tool and tool yaml. -### Step 1: Support "enabled by" in the tool package -All inputs will be passed to the tool, allowing you to define your own set of rules to determine which input to use. Here is an example of how you can support the "enabled by" feature in your tool package: +### Step 1: Support "enabled by" in the tool +All inputs will be passed to the tool, allowing you to define your own set of rules to determine which input to use. Here is an example of how you can support the "enabled by" feature in your tool: ```python @@ -38,14 +38,14 @@ class EmbeddingModel(str, Enum): @tool def embedding(connection: Union[AzureOpenAIConnection, OpenAIConnection], input: str, deployment_name: str = "", model: EmbeddingModel = EmbeddingModel.TEXT_EMBEDDING_ADA_002): connection_dict = dict(connection) - # if the connection type is AzureOpenAIConnection, use the deployment_name input. + # If the connection type is AzureOpenAIConnection, use the deployment_name input. if isinstance(connection, AzureOpenAIConnection): return openai.Embedding.create( input=input, engine=deployment_name, **connection_dict, )["data"][0]["embedding"] - # if the connection type is OpenAIConnection, use the model input. + # If the connection type is OpenAIConnection, use the model input. elif isinstance(connection, OpenAIConnection): return openai.Embedding.create( input=input, @@ -89,7 +89,7 @@ promptflow.tools.embedding.embedding: model: type: - string - # the input model is enabled by connection + # The input model is enabled by connection enabled_by: connection # When the connection type is OpenAIConnection, model is enabled and displayed. enabled_by_type: [OpenAIConnection] @@ -104,3 +104,6 @@ promptflow.tools.embedding.embedding: > Note: Both "enabled_by_type" and "enabled_by_value" are list types, which means you can use multiple inputs to enable a single input. For instance, if "enabled_by_type" is [AzureOpenAIConnection, OpenAIConnection], the input will be enabled when the connection type is either AzureOpenAIConnection or OpenAIConnection. +After you build and share the tool package generated with the above steps, you can use your tool from VSCode Extension. When you select a connection with azure openai type, only deployment_name input is enabled and displayed. + +![enabled_by_type.png](../../media/how-to-guides/develop-a-tool/enabled_by_type.png) diff --git a/docs/media/how-to-guides/develop-a-tool/enabled_by_type.png b/docs/media/how-to-guides/develop-a-tool/enabled_by_type.png new file mode 100644 index 0000000000000000000000000000000000000000..955b3311adb5412423410c1f1d803ae429f801bc GIT binary patch literal 16095 zcmdVBc~p{H*f&faJEaXa9MjUY!E#K~${`hwP1Z5Rav*b{4w9#EjBo~Qw2o7yY3A6m zGDRgZafVKwz;LP@P*JH!Nf2=Y6uj}fspmZ3^Q`r~-?QGe-hW=#awb`WgI&DHp_oAIq?3TnDt-0hg%#kldc+A|ECjNyMfJao8U7*&0)bvVdDPh}CQvjC)S_bp4CWWr|8m^@ zy7@~Ybyev4ko6i{UhTGibp1(hpW26iqEg!q2lwpTn(M8R(QCa`WVOk};2UL!&%V+P zdvE;WcIIf?yUY`Bec%04b8+`Y#y=ZUkFUM>#jx7vVi(?E#sn&G*Z zS1c3Oc%f2X)kxZ*|DU%bm`zi+Eb{`DGuiMG_x!=^xs%*_t7Vg!yEbLwC(R5Vjm*s( zSV$f&wUFIpldp1wtHI%X$S4xh6qC77@hmjFs@Y&XgEmm0tNY2_&f0lENaKq;e+~+G zL#d|?#mYwF#dDr8iD$P&$PS<051ZZJO$wBh4G^MRvJ>8ApE8(#z4Cc_!q;8hjU$rE zx99kS;EbaY1sV<~PWXJZMYX4{Wu7efYq7piQJ*_mLsasKgws%V0X#-RLOMA~`%&GN z$}g7g2EaELZAw0+r$aK(aeozSGJe<=9=>=Nc6L78LYb?}89oAANJ?f~E)I(Gx7~0M zw&(2ce&(8eap^vR5uCud+T|o0IzzDaI+2w)(FN4QZ1LZY7(6CSFbN@X%Gp8~2Q+3~ z{FSAB+KHm1qC^YL;|U$?gpN5mn@*6Icgf2KY=l>9#~kqTxvL8^qi=;n$_Bi=geaeT zhLk_+MlL23BjY+Sfz|zmnA&yfP272gtwkVTpt;ljpIzyW*1$(g;Nu(*rsQ=O0@Xz6 z@c^o4R>P~4oRMf-mz~B6!7QEFQoAT3?gui`fuwP|;@f;UQBgyrHb`pZ?UnK+{sio=G?W#BQ^@H`V)N7pa-sOGFdX=sPOk!bSTmq8! ze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rsMEdxhChe1+C4uf`q;C~l0M!~!$Lqg@V|kaM`a@wb2cx9Qz( zY1*^NdhXLtQq&qSBL!J^qi7;=#?X^!y?Pxd3@#f!sou&kN<0r!G0WGWyv!-SsR@{6 z@(|xX?dxSbi2DxO6K+)!-89!7RuM|Q72lcl|3nb~57zQl-FF@UD@&fYWn03*aHp^` zu=$Xx^p-jtsH%;#>ICoQT@=~|z!0&361;Dv%PGwjf@&2cVk21L7NrWpz%sSu*G8&n zjT4sn>)yZ5Y2NMA%6zs&=(|$eGyNkhGm*rw%(YG6&=@lIehoti@qzF*C}z2 z&6#e|A)uiQ)>u z-GQzElh<{n%I*3IQ-6=&H7Z!2rII6c(O^&0r7zVEsYjWf{nOM8+_IM^G)Cn9syi%h zPY_STEPnOtgKqpo!nOm6SyJX2mY^@gHJ zn7YyJ$CdZ}$4oA&NcBV0h%!JU%GCeQ5E;#BzN~~|YW!QG7aZZujjXJc<#LeJN@(<4 zNoQGjsTD?f*-uD%Z-#d2Cjrwj*2g99`cVpKaD^hO3B2|72s(95b5)zlOsOwHM_vI_ zzj7RP_Q20)tPqI5-|Iw-9>i%`dvl?|;@XhB50s+vByY4H);u|+1eDp&g7cF|$I zZlSr70PaCQuz(a2;RWI-)x6wPJ+{nEGl`)D^F)_3UY6F1M5c)XfDy?sVr7*^kYsxg zj)lQ9d-YbXWtHIzv9&m{_jOA71xK6jt9G&YItBgN^Ol2_aWA2?=*9IXrtlcgP_x$Y z9cOzU9hAM0OYFO0^ngCTDfZfjq5ey@mEcY(apQ8sJ#6$b2-Ha0&7g&Rit2t#wFGPu z;_{B6hIZ;HohtL1&yc@z_0_D5^XO^oCQGXWc-|4c3hz}9XXdsjBp#$bEA6Y2*aj Date: Wed, 18 Oct 2023 16:27:54 +0800 Subject: [PATCH 03/10] add more details --- docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md index 6e460aa8a3a..97f4ad42c26 100644 --- a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md +++ b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md @@ -104,6 +104,8 @@ promptflow.tools.embedding.embedding: > Note: Both "enabled_by_type" and "enabled_by_value" are list types, which means you can use multiple inputs to enable a single input. For instance, if "enabled_by_type" is [AzureOpenAIConnection, OpenAIConnection], the input will be enabled when the connection type is either AzureOpenAIConnection or OpenAIConnection. -After you build and share the tool package generated with the above steps, you can use your tool from VSCode Extension. When you select a connection with azure openai type, only deployment_name input is enabled and displayed. +After you build and share the tool package with "enabled_by" feature, you can use your tool from VSCode Extension. When you select a connection with "AzureOpenAIConnection" type, only "deployment_name" input is enabled and displayed. ![enabled_by_type.png](../../media/how-to-guides/develop-a-tool/enabled_by_type.png) + +> Note: "enabled_by_value" is similar to "enabled_by_type", but it enables an input by a specific input value. For instance, if "enabled_by_value" is ["azure-openai-connection", "openai-connection"], the input will be enabled when the connection value is either "azure-openai-connection" or "openai-connection". From c24a9ed72598369a69e70a5418435e8deea71636 Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Fri, 20 Oct 2023 14:32:23 +0800 Subject: [PATCH 04/10] fix conflict --- docs/how-to-guides/develop-a-tool/index.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/how-to-guides/develop-a-tool/index.md b/docs/how-to-guides/develop-a-tool/index.md index 2ce25b44c90..ffd7b77da60 100644 --- a/docs/how-to-guides/develop-a-tool/index.md +++ b/docs/how-to-guides/develop-a-tool/index.md @@ -7,9 +7,6 @@ We provide guides on how to develop a tool and use it. create-and-use-tool-package add-a-tool-icon -<<<<<<< HEAD -how-to-use-enabled-by -======= add-category-and-tags-for-tool ->>>>>>> main +how-to-use-enabled-by ``` \ No newline at end of file From 9e0d421bd28ff17546365ad9f7eb9e803ef3419d Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Fri, 20 Oct 2023 14:35:26 +0800 Subject: [PATCH 05/10] fix conflict --- .../develop-a-tool/create-and-use-tool-package.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md b/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md index 3a427e8205c..047fa4f5aee 100644 --- a/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md +++ b/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md @@ -162,10 +162,6 @@ Alternatively, you can test your tool package using the script below to ensure t * If you encounter a `403 Forbidden Error`, it's likely due to a naming conflict with an existing package. You will need to choose a different name. Package names must be unique on PyPI to avoid confusion and conflicts among users. Before creating a new package, it's recommended to search PyPI (https://pypi.org/) to verify that your chosen name is not already taken. If the name you want is unavailable, consider selecting an alternative name or a variation that clearly differentiates your package from the existing one. ## Advanced features -<<<<<<< HEAD -[Customize your tool icon](add-a-tool-icon.md) -[How to use enabled by in the tool](how-to-use-enabled-by.md) -======= -[Customize your tool icon](add-a-tool-icon.md) +[Customize your tool icon](add-a-tool-icon.md) [Add category and tags for tool](add-category-and-tags-for-tool.md) ->>>>>>> main +[How to use enabled by in the tool package](how-to-use-enabled-by.md) From 94f7113397f5adc6f92b53ff9b7d648e1d10c1f3 Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Fri, 20 Oct 2023 14:41:51 +0800 Subject: [PATCH 06/10] fix comments --- .../develop-a-tool/how-to-use-enabled-by.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md index 382b63c3d77..62e610be058 100644 --- a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md +++ b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md @@ -10,7 +10,7 @@ Concurrently, we support enabling an input by another input type or input value, ## Prerequisites To proceed, it's crucial for you to understand the process of developing a tool and generating a tool yaml. For thorough insights and instructions, please refer to [Create and Use Tool Package](create-and-use-tool-package.md). -## How to use 'enabled_by_type' +## How to use "enabled_by_type" Assume you want to develop a tool with four inputs: "connection", "input", "deployment_name", and "model". The "deployment_name" and "model" are enabled by "connection" type. When the "connection" type is AzureOpenAIConnection, the "deployment_name" input is enabled and displayed. When the "connection" type is OpenAIConnection, the "model" input is enabled and displayed. You need to support enable by in two part: tool and tool yaml. Here is an example of how you can support the "enabled by" feature in your tool and tool yaml. @@ -63,7 +63,7 @@ def embedding(connection: Union[AzureOpenAIConnection, OpenAIConnection], input: ``` ### Step 2: Support "enabled_by_type" in the tool yaml -Once you have generated a tool yaml, you can incorporate the 'enabled by' feature into it. Here is an example showcasing the use of 'enabled_by_type' in the tool yaml: +Once you have generated a tool yaml, you can incorporate the "enabled_by_type" into it. Here is an example showcasing the use of 'enabled_by_type' in the tool yaml: ```yaml promptflow.tools.embedding.embedding: @@ -108,7 +108,7 @@ promptflow.tools.embedding.embedding: -## How to use 'enabled_by_value' +## How to use "enabled_by_value" Assume you want to develop a tool with four inputs: "connection", "input", "deployment_name", and "model". The "deployment_name" and "model" are enabled by "connection" value. When the "connection" value is "azure-open-ai-connection", the "deployment_name" input is enabled and displayed. When the "connection" value is "open-ai-connection", the "model" input is enabled and displayed. You need to support enable by in two part: tool and tool yaml. Here is an example of how you can support the "enabled by" feature in your tool and tool yaml. @@ -140,14 +140,14 @@ class ConnectionName(str, Enum): @tool def embedding(connection: Enum, input: str, deployment_name: str = "", model: EmbeddingModel = EmbeddingModel.TEXT_EMBEDDING_ADA_002): connection_dict = dict(connection) - # If the connection type is AzureOpenAIConnection, use the deployment_name input. + # If the connection value is azure-open-ai-connection, use the deployment_name input. if connection == ConnectionName.Azure_Open_AI_CONNECTION: return openai.Embedding.create( input=input, engine=deployment_name, **connection_dict, )["data"][0]["embedding"] - # If the connection type is OpenAIConnection, use the model input. + # If the connection type is open-ai-connection, use the model input. elif connection == ConnectionName.OPEN_AI_CONNECTION: return openai.Embedding.create( input=input, @@ -182,7 +182,7 @@ promptflow.tools.embedding.embedding: - string # The input deployment_name is enabled by connection enabled_by: connection - # When the connection type is AzureOpenAIConnection, deployment_name is enabled and displayed. + # When the connection value is azure-open-ai-connection, deployment_name is enabled and displayed. enabled_by_value: [azure-open-ai-connection] capabilities: completion: false @@ -197,7 +197,7 @@ promptflow.tools.embedding.embedding: - string # The input model is enabled by connection enabled_by: connection - # When the connection type is OpenAIConnection, model is enabled and displayed. + # When the connection value is open-ai-connection, model is enabled and displayed. enabled_by_value: [open-ai-connection] enum: - text-embedding-ada-002 From 974364ed27a9ca0008112cb8c7c49999125422b3 Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Fri, 20 Oct 2023 14:44:41 +0800 Subject: [PATCH 07/10] refine the doc --- .../how-to-guides/develop-a-tool/how-to-use-enabled-by.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md index 62e610be058..e51b69baeab 100644 --- a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md +++ b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md @@ -5,7 +5,9 @@ This guide will instruct you on how to use the "enabled by" feature in the tool We introduce parameter "enabled_by" in the tool yaml to determine which input is enabled by which other input. Concurrently, we support enabling an input by another input type or input value, Hence, we introduce two additional parameters: "enabled_by_type" and "enabled_by_value". -> Note: We do not recommend using "enabled_by_type" and "enabled_by_value" simultaneously. If both are used, "enabled_by_type" will be ignored. +> Note 1: We do not recommend using "enabled_by_type" and "enabled_by_value" simultaneously. If both are used, "enabled_by_type" will be ignored. + +> Note 2: Both "enabled_by_type" and "enabled_by_value" in tool yaml are list types, which means you can use multiple inputs to enable a single input. For instance, if "enabled_by_type" is [AzureOpenAIConnection, OpenAIConnection], the input will be enabled when the connection type is either AzureOpenAIConnection or OpenAIConnection. ## Prerequisites To proceed, it's crucial for you to understand the process of developing a tool and generating a tool yaml. For thorough insights and instructions, please refer to [Create and Use Tool Package](create-and-use-tool-package.md). @@ -63,7 +65,7 @@ def embedding(connection: Union[AzureOpenAIConnection, OpenAIConnection], input: ``` ### Step 2: Support "enabled_by_type" in the tool yaml -Once you have generated a tool yaml, you can incorporate the "enabled_by_type" into it. Here is an example showcasing the use of 'enabled_by_type' in the tool yaml: +Once you have generated a tool yaml, you can incorporate the "enabled_by_type" into it. Here is an example showcasing the use of "enabled_by_type" in the tool yaml: ```yaml promptflow.tools.embedding.embedding: @@ -208,8 +210,6 @@ promptflow.tools.embedding.embedding: - string ``` -> Note: Both "enabled_by_type" and "enabled_by_value" in tool yaml are list types, which means you can use multiple inputs to enable a single input. For instance, if "enabled_by_type" is [AzureOpenAIConnection, OpenAIConnection], the input will be enabled when the connection type is either AzureOpenAIConnection or OpenAIConnection. - ## Use the tool from VSCode Extension After you build and share the tool package with "enabled_by" feature, you can use your tool from VSCode Extension according to [Create and Use Tool Package](create-and-use-tool-package.md). For instance, when you select a connection with "AzureOpenAIConnection" type, only "deployment_name" input is enabled and displayed for "enabled_by_type" example. From ed8dccfb567174a8c20b1c1d8b5857133f14a0c8 Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Mon, 23 Oct 2023 15:06:30 +0800 Subject: [PATCH 08/10] fix comments --- .../create-and-use-tool-package.md | 2 +- .../develop-a-tool/how-to-use-enabled-by.md | 25 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md b/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md index 047fa4f5aee..dce803d9226 100644 --- a/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md +++ b/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md @@ -164,4 +164,4 @@ Alternatively, you can test your tool package using the script below to ensure t ## Advanced features [Customize your tool icon](add-a-tool-icon.md) [Add category and tags for tool](add-category-and-tags-for-tool.md) -[How to use enabled by in the tool package](how-to-use-enabled-by.md) +[Use Enabled_By to Support Cascading Settings between Inputs for Tool](how-to-use-enabled-by.md) diff --git a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md index e51b69baeab..daca68a2564 100644 --- a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md +++ b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md @@ -1,20 +1,19 @@ -# How to use enabled by in the tool package +# Use Enabled_By to Support Cascading Settings between Inputs for Tool -This guide will instruct you on how to use the "enabled by" feature in the tool package. The "enabled by" feature is designed to display which inputs are enabled when a customer uses a specific input type or input value. This feature is particularly useful if you need to adapt your inputs based on varying requirements. - -We introduce parameter "enabled_by" in the tool yaml to determine which input is enabled by which other input. -Concurrently, we support enabling an input by another input type or input value, Hence, we introduce two additional parameters: "enabled_by_type" and "enabled_by_value". - -> Note 1: We do not recommend using "enabled_by_type" and "enabled_by_value" simultaneously. If both are used, "enabled_by_type" will be ignored. - -> Note 2: Both "enabled_by_type" and "enabled_by_value" in tool yaml are list types, which means you can use multiple inputs to enable a single input. For instance, if "enabled_by_type" is [AzureOpenAIConnection, OpenAIConnection], the input will be enabled when the connection type is either AzureOpenAIConnection or OpenAIConnection. +This guide will instruct you on how to use the "enabled by" feature in the tool package. The "enabled by" feature is designed to support cascading settings between inputs for tool. +Cascading settings between inputs are frequently used in situations where the selection in one input field determines what sebsequent inputs should be shown. +This approach help in creating a more efficient, user-friendly, and error-free input process. To support cascading settings between tool inputs, we've introduced following two configurations: +* "enabled_by + enabled_by_type": This setting enabled the current input based on the value type of the input shown in "enabled_by" field. +* "enabled_by + enabled_by_value": This setting enabled the current input based on the actual value of the input shown in "enabled_by" field. +> Note: The "enabled_by_type" and "enabled_by_value" configurations should not be used simultaneously for the same input. Both enabled_by_type and enabled_by_value in the tool yaml are of list type, implying that a single input can be enabled by multiple values from the dependent input. ## Prerequisites To proceed, it's crucial for you to understand the process of developing a tool and generating a tool yaml. For thorough insights and instructions, please refer to [Create and Use Tool Package](create-and-use-tool-package.md). -## How to use "enabled_by_type" -Assume you want to develop a tool with four inputs: "connection", "input", "deployment_name", and "model". The "deployment_name" and "model" are enabled by "connection" type. When the "connection" type is AzureOpenAIConnection, the "deployment_name" input is enabled and displayed. When the "connection" type is OpenAIConnection, the "model" input is enabled and displayed. You need to support enable by in two part: tool and tool yaml. Here is an example of how you can support the "enabled by" feature in your tool and tool yaml. - +## Use "enabled_by + enabled_by_type" in tool +Here we take [this existing tool](https://github.com/microsoft/promptflow/blob/eeb1df65e55d93e1a6fe30f58adda1e9d241db61/src/promptflow-tools/promptflow/tools/embedding.py) as example, this tool has four inputs: "connection", "input", "deployment_name", and "model". +The "deployment_name" and "model" are enabled by the type of input "connection". When the type of "connection" input is AzureOpenAIConnection, the "deployment_name" input is enabled and displayed. When the type of "connection" input is OpenAIConnection, the "model" input is enabled and displayed. +Below shows how to support this cascading setting in both tool code and tool yaml. ### Step 1: How to define the rules in the tool All inputs will be passed to the tool, allowing you to define your own set of rules to determine which input to use. You need to pay attention to some key points: @@ -110,7 +109,7 @@ promptflow.tools.embedding.embedding: -## How to use "enabled_by_value" +## Use "enabled_by + enabled_by_value" in tool Assume you want to develop a tool with four inputs: "connection", "input", "deployment_name", and "model". The "deployment_name" and "model" are enabled by "connection" value. When the "connection" value is "azure-open-ai-connection", the "deployment_name" input is enabled and displayed. When the "connection" value is "open-ai-connection", the "model" input is enabled and displayed. You need to support enable by in two part: tool and tool yaml. Here is an example of how you can support the "enabled by" feature in your tool and tool yaml. From 24db4e1427b1819e2631f64e2ca3ff4afcd5f942 Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Mon, 23 Oct 2023 15:11:03 +0800 Subject: [PATCH 09/10] fix typos --- docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md index daca68a2564..758224e8049 100644 --- a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md +++ b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md @@ -1,7 +1,7 @@ # Use Enabled_By to Support Cascading Settings between Inputs for Tool This guide will instruct you on how to use the "enabled by" feature in the tool package. The "enabled by" feature is designed to support cascading settings between inputs for tool. -Cascading settings between inputs are frequently used in situations where the selection in one input field determines what sebsequent inputs should be shown. +Cascading settings between inputs are frequently used in situations where the selection in one input field determines what subsequent inputs should be shown. This approach help in creating a more efficient, user-friendly, and error-free input process. To support cascading settings between tool inputs, we've introduced following two configurations: * "enabled_by + enabled_by_type": This setting enabled the current input based on the value type of the input shown in "enabled_by" field. * "enabled_by + enabled_by_value": This setting enabled the current input based on the actual value of the input shown in "enabled_by" field. From db3de835ddc8a464fa7a1ec0821d53e35b64b9e2 Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Mon, 23 Oct 2023 15:13:03 +0800 Subject: [PATCH 10/10] fix typos --- .../how-to-guides/develop-a-tool/create-and-use-tool-package.md | 2 +- docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md b/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md index dce803d9226..13999926918 100644 --- a/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md +++ b/docs/how-to-guides/develop-a-tool/create-and-use-tool-package.md @@ -164,4 +164,4 @@ Alternatively, you can test your tool package using the script below to ensure t ## Advanced features [Customize your tool icon](add-a-tool-icon.md) [Add category and tags for tool](add-category-and-tags-for-tool.md) -[Use Enabled_By to Support Cascading Settings between Inputs for Tool](how-to-use-enabled-by.md) +[Use Enabled By to Support Cascading Settings between Inputs for Tool](how-to-use-enabled-by.md) diff --git a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md index 758224e8049..c18c4dd12f7 100644 --- a/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md +++ b/docs/how-to-guides/develop-a-tool/how-to-use-enabled-by.md @@ -1,4 +1,4 @@ -# Use Enabled_By to Support Cascading Settings between Inputs for Tool +# Use Enabled By to Support Cascading Settings between Inputs for Tool This guide will instruct you on how to use the "enabled by" feature in the tool package. The "enabled by" feature is designed to support cascading settings between inputs for tool. Cascading settings between inputs are frequently used in situations where the selection in one input field determines what subsequent inputs should be shown.