Skip to content

Commit

Permalink
[tools] refine wording, fix doc link and remove redundant codes (micr…
Browse files Browse the repository at this point in the history
…osoft#159)

In this PR, there are 3 improvements:
- refine tools related workflow names.
- remove redundant codes.
- improve wording and fix doc link of READMEs.
  • Loading branch information
chjinche authored Aug 25, 2023
1 parent d5f8d3a commit a0e23db
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Promptflow Tools Release
name: tools_continuous_delivery

on:
pull_request:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:

deploy_runtime_with_updated_tools_package:
needs: continuous_delivery_release
uses: ./.github/workflows/deploy_runtime.yml
uses: ./.github/workflows/tools_deploy_runtime.yml
name: Deploy runtime
with:
ToolsPackageVersion: ${{ needs.continuous_delivery_release.outputs.PackageVersion }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy runtime
name: tools_deploy_runtime

on:
workflow_call:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools_release_tag.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Promptflow Tools Release Tag
name: create_tools_release_tag
on:
workflow_dispatch:
inputs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools_secret_upload.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Promptflow Tools Secrets Upload
name: tools_secret_upload
# Triggers the workflow manually
on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Promptflow Tools Test
name: tools_tests
on:
# Triggers the workflow pull request events but only for the main branch
pull_request:
Expand Down
8 changes: 4 additions & 4 deletions src/promptflow-tools/README.dev.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Development Guide for Promptflow builtin tools
# Development Guide

## Prerequisites

Expand All @@ -10,10 +10,10 @@ pip install pytest pytest-mock
## Run tests locally

- Create connection config file by `cp connections.json.example connections.json`.
- Fill in the keys and secrets manually in `connections.json`.
- Fill in fields manually in `connections.json`.
- `cd tests` and run `pytest -s -v` to run all tests.

## Run tests in CI

Use this [workflow](https://github.com/microsoft/promptflow/actions/workflows/tools_secret_upload.yml) to upload secrets in key vault. The secrets you uploaded would be used in [Promptflow Tools Test CI](https://github.com/microsoft/promptflow/actions/workflows/tools_tests.yml). Note that you only need to upload the SECRETS.
> [!NOTE] After triggering the flow, kindly request approval from Promptflow Support before proceeding further.
Use this [workflow](https://github.com/microsoft/promptflow/actions/workflows/tools_secret_upload.yml) to upload secrets in key vault. The secrets you uploaded would be used in [tools tests](https://github.com/microsoft/promptflow/actions/workflows/tools_tests.yml). Note that you only need to upload the SECRETS.
> [!NOTE] After triggering the workflow, kindly request approval from Promptflow Support before proceeding further.
8 changes: 4 additions & 4 deletions src/promptflow-tools/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Promptflow tools
# Prompt Flow Tools

[![Python package](https://img.shields.io/pypi/v/promptflow-tools)](https://pypi.org/project/promptflow-tools/)
[![license: MIT](https://img.shields.io/badge/License-MIT-purple.svg)](../LICENSE)
[![License: MIT](https://img.shields.io/github/license/microsoft/promptflow)](https://github.com/microsoft/promptflow/blob/main/LICENSE)

## Introduction

Tools are the fundamental building blocks of a flow in Azure Machine Learning Prompt flow. Each tool is a simple, executable unit with a specific function, allowing users to perform various tasks. By combining different tools, users can create a flow that accomplishes a wide range of goals. One of the key benefit of prompt flow tools is their seamless integration with third-party APIs and python open source packages. This not only improves the functionality of large language models but also makes the development process more efficient for developers.
Tools are the fundamental building blocks of a flow in Azure Machine Learning prompt flow. Each tool is a simple, executable unit with a specific function, allowing users to perform various tasks. By combining different tools, users can create a flow that accomplishes a wide range of goals. One of the key benefit of prompt flow tools is their seamless integration with third-party APIs and python open source packages. This not only improves the functionality of large language models but also makes the development process more efficient.

In this package, we provide a set of builtin tools of prompt flow, which are the most commonly used tools in the development of AI applications. We also support users to create their own tools and share them with others. See [Custom tool package creation and usage](https://github.com/Azure/promptflow/blob/main/docs/how-to-guides/how-to-create-and-use-your-own-tool-package.md) for more details.
In this package, we provide a set of builtin tools of prompt flow, which are the most commonly used tools in the development of AI applications. We also provide a flexible way for users to create their own tools and share them with others. See [Custom tool package creation and usage](https://github.com/microsoft/promptflow/blob/main/docs/how-to-guides/how-to-create-and-use-your-own-tool-package.md) for more details.
21 changes: 0 additions & 21 deletions src/promptflow-tools/promptflow/tools/common.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import functools
import http
import json
import re
import socket
import sys
import time

import requests
import urllib3
from jinja2 import Template
from openai.error import APIError, OpenAIError, RateLimitError, ServiceUnavailableError, Timeout, APIConnectionError
from promptflow.exceptions import SystemErrorException, UserErrorException
Expand Down Expand Up @@ -121,23 +117,6 @@ def parse_chat(chat_str):
return chat_list


# Define the retriable exceptions
retriable_exceptions = (
urllib3.exceptions.HTTPError, # this is a parent class, we might not list its sub-class
urllib3.exceptions.MaxRetryError,
urllib3.exceptions.TimeoutError,
urllib3.exceptions.ConnectionError,
socket.timeout,
http.client.RemoteDisconnected,
http.client.HTTPException,
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
requests.exceptions.RetryError,
requests.exceptions.TooManyRedirects,
requests.exceptions.HTTPError,
)


def handle_openai_error(tries: int = 10, delay: float = 8.0):
"""
A decorator function that used to handle OpenAI error.
Expand Down
2 changes: 1 addition & 1 deletion src/promptflow-tools/promptflow/tools/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def to_openai_error_message(e: Exception) -> str:


class WrappedOpenAIError(UserErrorException):
"""Base exception raised when call openai api."""
"""Refine error messages on top of native openai errors."""

def __init__(self, ex: OpenAIError, **kwargs):
super().__init__(target=ErrorTarget.TOOL, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion src/promptflow-tools/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
setup(
name=PACKAGE_NAME,
version=version,
description="Prompt Flow Tools",
description="Builtin tools of prompt flow",
author="Microsoft Corporation",
classifiers=[
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit a0e23db

Please sign in to comment.