-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support default input index when collect package tools for …
…custom-llm tool (#1502) # Description ### Reason Previously, customers complained that the order of custom-llm tool inputs displayed in the UI was inconsistent with the order defined in tool interface or yaml file. This was because the UI received the inputs as a dict, which resulted in an alphabetical order display. In this PR, we will automatically add "ui_hints": {"index": XX} to every input based on the order in tool interface or yaml file for custom_llm tool. When UI received tool inputs, they can display the inputs according to this ui_hints["index"] field to make the order consistent. Both portal and extension have completed the code change to support ui_hints["index"]. ### Cases which will not be corrected by this pr: - Existing flow with flow.tools.json - All examples in promptflow gallery which also have flow.tools.json file ### Test For more test cases, please go to [this link](https://microsoft.sharepoint.com/:o:/r/teams/STCASharedDataTeam/_layouts/15/Doc.aspx?sourcedoc=%7Bde8c0032-8386-492d-af0e-104af9de317a%7D&action=edit&wd=target(Pipelines%2FDCM%2FDevs%2Fjiazeng.one%7C0FA273ED-FDCC-4644-82B0-C96606E278CB%2FTest%20default%20input%20index-3%7CDC170A9F-4572-4931-BFAD-CEECD018616B%2F)&share=IgEyAIzehoMtSa8OEEr53jF6AYDaZzIchXLytsUQwUbc29U) - custom-llm tool ![image](https://github.com/microsoft/promptflow/assets/95729303/942b03a2-ae12-44bb-ba03-ccad98df5c69) - in portal ![image](https://github.com/microsoft/promptflow/assets/95729303/2f5cd399-de70-4eb9-b26f-cc44fd9f45c5) - in extension ![image](https://github.com/microsoft/promptflow/assets/95729303/f22e2b6f-71df-4787-bab0-16645f9eb264) - built in custom-llm tool - in portal: ![image](https://github.com/microsoft/promptflow/assets/95729303/98faab67-e59a-4e48-b843-58f373638cd5) - in extension: ![image](https://github.com/microsoft/promptflow/assets/95729303/f5311e36-beb8-4be7-ba29-abec5148f2c7) - Test cases The behavior of the following test cases are as expected. Only custom_llm tool's inputs' order are corrected, other tool's inputs' order keep same as before. - Create a new flow - Clone a flow - Upload a flow without .promptflow folder # All Promptflow Contribution checklist: - [x] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [ ] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [ ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [x] Pull request includes test coverage for the included changes. --------- Co-authored-by: cs_lucky <si.chen@microsoft.com> Co-authored-by: jiazeng <jiazeng@microsoft.com>
- Loading branch information
1 parent
a2aec32
commit 500eee0
Showing
5 changed files
with
161 additions
and
1 deletion.
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
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
36 changes: 36 additions & 0 deletions
36
...ustom_llm_tool_multi_inputs_without_index/custom_llm_tool_multi_inputs_without_index.yaml
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,36 @@ | ||
custom_llm_tool.TestCustomLLMTool.call: | ||
name: Test Custom LLM Tool | ||
type: custom_llm | ||
function: call | ||
module: TestCustomLLMTool | ||
inputs: | ||
connection: | ||
type: | ||
- AzureOpenAIConnection | ||
deployment_name: | ||
type: | ||
- string | ||
api: | ||
type: | ||
- string | ||
temperature: | ||
type: | ||
- double | ||
top_p: | ||
type: | ||
- double | ||
max_tokens: | ||
type: | ||
- int | ||
stop: | ||
default: "" | ||
type: | ||
- list | ||
presence_penalty: | ||
default: 0 | ||
type: | ||
- double | ||
frequency_penalty: | ||
default: 0 | ||
type: | ||
- double |
19 changes: 19 additions & 0 deletions
19
...romptflow/tests/executor/package_tools/custom_llm_tool_multi_inputs_without_index/list.py
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,19 @@ | ||
from pathlib import Path | ||
from ruamel.yaml import YAML | ||
|
||
|
||
def collect_tools_from_directory(base_dir) -> dict: | ||
tools = {} | ||
yaml = YAML() | ||
for f in Path(base_dir).glob("**/*.yaml"): | ||
with open(f, "r") as f: | ||
tools_in_file = yaml.load(f) | ||
for identifier, tool in tools_in_file.items(): | ||
tools[identifier] = tool | ||
return tools | ||
|
||
|
||
def list_package_tools(): | ||
"""List package tools""" | ||
yaml_dir = Path(__file__).parent | ||
return collect_tools_from_directory(yaml_dir) |
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