Skip to content

Commit

Permalink
delete flow and tool
Browse files Browse the repository at this point in the history
update
  • Loading branch information
jiazengcindy committed Oct 26, 2023
1 parent 6229342 commit 6ef4228
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 custom LLM tool](use-custom-llm-tool.md)
[Create Custom LLM Tool](create-custom-llm-tool.md)
17 changes: 8 additions & 9 deletions docs/how-to-guides/develop-a-tool/create-custom-llm-tool.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Create Custom LLM Tool
In this document, we will guide you through the process of developing a tool with `custom_llm` type which can connect to a customized large language model with prompt.

Custom LLM is a fine-tuned large language model by yourself. If you find it has good performance and is useful, then you can follow this guidance to make it a tool so that it can be shared with other people to have more impact.
Custom LLM is a large language model fine-tuned by yourself. If you find it has good performance and is useful, then you can follow this guidance to make it a tool so that it can be shared with other people to have more impact.

## Prerequisites
- Please ensure that your `Prompt flow` for VS Code is updated to version 1.2.0 or later.

## How to create a custom LLM tool
Here we use [an existing tool package](../../../examples/tools/tool-package-quickstart/my_tool_package) as an example. If you want to create your own tool, please refer to [create and use tool package](create-and-use-tool-package.md).

### Add a `PromptTemplate` input for your tool, like in [this example](../../../examples/tools/tool-package-quickstart/my_tool_package/tools/tool_with_custom_llm_type.py)
### Add a `PromptTemplate` input to your tool, like in [this example](../../../examples/tools/tool-package-quickstart/my_tool_package/tools/tool_with_custom_llm_type.py)

```python
from jinja2 import Template
Expand All @@ -22,7 +22,7 @@ from promptflow.contracts.types import PromptTemplate
# 2. Add a PromptTemplate input for your tool method.
@tool
def my_tool(connection: CustomConnection, prompt: PromptTemplate, **kwargs) -> str:
# 3. The prompt is used for your custom LLM to do inference, customise your own code to handle and use the prompt here.
# 3. The prompt is used for your custom LLM to do inference, customize your own code to handle and use the prompt here.
message = Template(prompt, trim_blocks=True, keep_trailing_newline=True).render(**kwargs)
return message
```
Expand All @@ -37,13 +37,13 @@ Here we use [an existing tool](../../../examples/tools/tool-package-quickstart/m
```
cd D:\proj\github\promptflow\examples\tools\tool-package-quickstart
python D:\proj\github\promptflow\scripts\tool\generate_package_tool_meta.py -m my_tool_package.tools.tool_with_custom_llm_type -o my_tool_package\yamls\tool_with_custom_llm_type.yaml -n "Custom LLM Tool" -d "This is a tool to demonstrate the custom_llm tool type" -t "custom_llm"
python D:\proj\github\promptflow\scripts\tool\generate_package_tool_meta.py -m my_tool_package.tools.tool_with_custom_llm_type -o my_tool_package\yamls\tool_with_custom_llm_type.yaml -n "My Custom LLM Tool" -d "This is a tool to demonstrate the custom_llm tool type" -t "custom_llm"
```
This command will generate YAML as follows:
This command will generate a YAML file as follows:

```yaml
my_tool_package.tools.tool_with_custom_llm_type.my_tool:
name: Custom LLM Tool
name: My Custom LLM Tool
description: This is a tool to demonstrate the custom_llm tool type
# The type is custom_llm.
type: custom_llm
Expand All @@ -59,6 +59,5 @@ inputs:
Follow the steps to [build and install your tool package](create-and-use-tool-package.md#build-and-share-the-tool-package) and [use your tool from VS Code extension](create-and-use-tool-package.md#use-your-tool-from-vscode-extension).
Here we use an existing flow to demonstrate the experience, open [this flow](../../../examples/flows/standard/custom_llm_tool_showcase/flow.dag.yaml) in VS Code extension.
- There is a node named "custom_llm_tool" with a prompt template file. You have the option to either use an existing file or create a new one as the prompt template file.
![use_custom_llm_tool](../../media/how-to-guides/develop-a-tool/use_custom_llm_tool.png)
- There is a node named "custom_llm_tool" with a prompt template file. You can either use an existing file or create a new one as the prompt template file.
![use_custom_llm_tool](../../media/how-to-guides/develop-a-tool/use_custom_llm_tool.png)
18 changes: 0 additions & 18 deletions examples/flows/standard/custom_llm_tool_showcase/flow.dag.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@pytest.fixture
def my_file_path_input() -> FilePath:
my_file_path_input = FilePath("tests.test_utils.hello_method.py")
my_file_path_input = FilePath(".\\test_utils\\hello_method.py")
return my_file_path_input


Expand Down

0 comments on commit 6ef4228

Please sign in to comment.