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
+1
View File
@@ -0,0 +1 @@
include {{ package_name }}/yamls/*.yaml
+14
View File
@@ -0,0 +1,14 @@
from setuptools import find_packages, setup
PACKAGE_NAME = "{{ package_name }}"
setup(
name=PACKAGE_NAME,
version="0.0.1",
description="This is my tools package",
packages=find_packages(),
entry_points={
"package_tools": ["{{ tool_name }} = {{ package_name }}.tools.utils:list_package_tools"],
},
include_package_data=True, # This line tells setuptools to include files from MANIFEST.in
)
+28
View File
@@ -0,0 +1,28 @@
import pytest
import unittest
from promptflow.connections import CustomConnection
from {{ package_name }}.tools.{{ tool_name }} import {{ function_name }}
@pytest.fixture
def my_custom_connection() -> CustomConnection:
my_custom_connection = CustomConnection(
{
"api-key" : "my-api-key",
"api-secret" : "my-api-secret",
"api-url" : "my-api-url"
}
)
return my_custom_connection
class TestTool:
def test_{{ function_name }}(self, my_custom_connection):
result = {{ function_name }}(my_custom_connection, input_text="Microsoft")
assert result == "Hello Microsoft"
# Run the unit tests
if __name__ == "__main__":
unittest.main()
+27
View File
@@ -0,0 +1,27 @@
import pytest
import unittest
from {{ package_name }}.tools.{{ tool_name }} import {{ class_name }}
@pytest.fixture
def my_url() -> str:
my_url = "https://www.bing.com"
return my_url
@pytest.fixture
def my_tool_provider(my_url) -> {{ class_name }}:
my_tool_provider = {{ class_name }}(my_url)
return my_tool_provider
class TestTool:
def test_{{ tool_name }}(self, my_tool_provider):
result = my_tool_provider.{{ function_name }}(query="Microsoft")
assert result == "Hello Microsoft"
# Run the unit tests
if __name__ == "__main__":
unittest.main()
+11
View File
@@ -0,0 +1,11 @@
from promptflow import tool
from promptflow.connections import CustomConnection
@tool
def {{ function_name }}(connection: CustomConnection, input_text: str) -> str:
# Replace with your tool code.
# Usually connection contains configs to connect to an API.
# Use CustomConnection is a dict. You can use it like: connection.api_key, connection.api_base
# Not all tools need a connection. You can remove it if you don't need it.
return "Hello " + input_text
+13
View File
@@ -0,0 +1,13 @@
{{ package_name }}.tools.{{ tool_name }}.{{ function_name }}:
function: {{ function_name }}
inputs:
connection:
type:
- CustomConnection
input_text:
type:
- string
module: {{ package_name }}.tools.{{ tool_name }}
name: Hello World Tool
description: This is hello world tool
type: python
+15
View File
@@ -0,0 +1,15 @@
from promptflow import ToolProvider, tool
import urllib.request
class {{ class_name }}(ToolProvider):
def __init__(self, url: str):
super().__init__()
# Load content from url might be slow, so we do it in __init__ method to make sure it is loaded only once.
self.content = urllib.request.urlopen(url).read()
@tool
def {{ function_name }}(self, query: str) -> str:
# Replace with your tool code.
return "Hello " + query
+14
View File
@@ -0,0 +1,14 @@
{{ package_name }}.tools.{{ tool_name }}.{{ class_name }}.{{ function_name }}:
class_name: {{ class_name }}
function: {{ function_name }}
inputs:
url:
type:
- string
query:
type:
- string
module: {{ package_name }}.tools.{{ tool_name }}
name: Hello World Tool
description: This is hello world tool
type: python
+19
View File
@@ -0,0 +1,19 @@
from ruamel.yaml import YAML
from pathlib import Path
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__).parents[1] / "yamls"
return collect_tools_from_directory(yaml_dir)