Skip to content

Commit

Permalink
Merge branch 'main' into yigao/fix_upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
crazygao committed Mar 29, 2024
2 parents 696c1cf + e70d0e5 commit efe4e18
Show file tree
Hide file tree
Showing 129 changed files with 183 additions and 168 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/tools_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ jobs:
pip install azure-identity azure-keyvault-secrets
# "DEPENDENCY_SOURCE_MODE" is "main" or "package", means the dependency source of code
if [ "$DEPENDENCY_SOURCE_MODE" = "main" ]; then
python ./scripts/building/dev_setup.py --promptflow-extra-deps azure
pip install ${{ github.workspace }}/src/promptflow-tracing
pip install ${{ github.workspace }}/src/promptflow-core
pip install ${{ github.workspace }}/src/promptflow-devkit
pip install ${{ github.workspace }}/src/promptflow-azure
pip install ${{ github.workspace }}/src/promptflow
pip install google-search-results==2.4.1
pip install openai>=1.0.0
pip install azure-mgmt-cognitiveservices==13.5.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pfazure run create --file run.yml
:sync: SDK

```python
from promptflow import load_run
from promptflow.client import load_run

run = load_run(source="run.yml")
pf = PFClient(
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/documentation_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ First please read through [Sphinx style](https://sphinx-rtd-tutorial.readthedocs
Let's start with a class example:
```python
from typing import Dict, Optional, Union
from promptflow import PFClient
from promptflow.client import PFClient

class MyClass:
"""One-line summary of the class.
Expand Down
6 changes: 3 additions & 3 deletions docs/how-to-guides/develop-a-flow/develop-evaluation-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Before introducing the aggregation node, let's see what a regular node looks lik
It takes both `groundtruth` and `prediction` from the flow inputs, compare them in the source code to see if they match:

```python
from promptflow import tool
from promptflow.core import tool
@tool
def grade(groundtruth: str, prediction: str):
Expand All @@ -86,7 +86,7 @@ When it comes to an `aggregation node`, there are two key distinctions that set

```python
from typing import List
from promptflow import log_metric, tool
from promptflow.core import log_metric, tool
@tool
def calculate_accuracy(grades: List[str]):
Expand Down Expand Up @@ -157,7 +157,7 @@ Promptflow supports logging and tracking experiments using `log_metric` function

```python
from typing import List
from promptflow import log_metric, tool
from promptflow.core import log_metric, tool
@tool
def example_log_metrics(grades: List[str]):
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-guides/develop-a-flow/develop-standard-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ By selecting the tool card on the very top, you'll add a new tool node to flow.
You can edit the tool by simply opening the source file and making edits. For example, we provide a simple Python tool code below.
```python
from promptflow import tool
from promptflow.core import tool

# The inputs section will change based on the arguments of the tool function, after you save the code
# Adding type to arguments and return value will help the system show the types properly
Expand Down Expand Up @@ -144,7 +144,7 @@ For example:

```python
import json
from promptflow import tool
from promptflow.core import tool
@tool
def convert_to_dict(input_str: str, input_str2: str) -> dict:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We'll build out an example tool to show how cascading inputs work. The `student_
```python
from enum import Enum

from promptflow import tool
from promptflow.core import tool


class UserType(str, Enum):
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-guides/develop-a-tool/customize_an_llm_tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Here we use [an existing tool package](https://github.com/microsoft/promptflow/t

```python
from jinja2 import Template
from promptflow import tool
from promptflow.core import tool
from promptflow.connections import CustomConnection
from promptflow.contracts.types import PromptTemplate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Here we use [an existing tool package](https://github.com/microsoft/promptflow/t
```python
import importlib
from pathlib import Path
from promptflow import tool
from promptflow.core import tool
# 1. import the FilePath type
from promptflow.contracts.types import FilePath

Expand Down Expand Up @@ -78,7 +78,7 @@ We can also utilize the `FilePath` input type directly in a script tool, elimina
```python
import importlib
from pathlib import Path
from promptflow import tool
from promptflow.core import tool
# 1. import the FilePath type
from promptflow.contracts.types import FilePath

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-guides/enable-streaming-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If you want to use the streaming mode, you need to create a flow that has a node
```
- Python tools node: This node allows you to write custom Python code that can yield string outputs. You can use this node to call external APIs or libraries that support streaming. For example, you can use this code to echo the input word by word:
```python
from promptflow import tool
from promptflow.core import tool

# Sample code echo input by yield in Python tool node

Expand Down
6 changes: 3 additions & 3 deletions docs/how-to-guides/init-and-test-a-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Promptflow CLI will generate test logs and outputs in `.promptflow`:
The return value of `test` function is the flow outputs.

```python
from promptflow import PFClient
from promptflow.client import PFClient

pf_client = PFClient()

Expand Down Expand Up @@ -188,7 +188,7 @@ The log and result of flow node test will be displayed in the terminal. And the
Customer can execute this command to test the flow. The return value of `test` function is the node outputs.

```python
from promptflow import PFClient
from promptflow.client import PFClient

pf_client = PFClient()

Expand Down Expand Up @@ -266,7 +266,7 @@ The flow result will be streamed in the terminal as shown below.
The LLM node return value of `test` function is a generator, you can consume the result by this way:

```python
from promptflow import PFClient
from promptflow.client import PFClient

pf_client = PFClient()

Expand Down
6 changes: 3 additions & 3 deletions docs/how-to-guides/manage-connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The expected result is as follows if the connection created successfully.
Using SDK, each connection type has a corresponding class to create a connection. The following code snippet shows how to import the required class and create the connection:

```python
from promptflow import PFClient
from promptflow.client import PFClient
from promptflow.entities import AzureOpenAIConnection, CustomConnection

# Get a pf client to manage connections
Expand Down Expand Up @@ -162,7 +162,7 @@ pf connection list
:sync: SDK
List connection command will return the connections object list, note that all secrets and api keys will be scrubbed:
```python
from promptflow import PFClient
from promptflow.client import PFClient
# Get a pf client to manage connections
pf = PFClient()
# List and print connections
Expand Down Expand Up @@ -193,7 +193,7 @@ pf connection delete -n <connection_name>
:sync: SDK
Delete a connection with the following code snippet:
```python
from promptflow import PFClient
from promptflow.client import PFClient

# Get a pf client to manage connections
pf = PFClient()
Expand Down
20 changes: 10 additions & 10 deletions docs/how-to-guides/manage-runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The expected result is as follows if the run is created successfully.
Using SDK, create `Run` object and submit it with `PFClient`. The following code snippet shows how to import the required class and create the run:

```python
from promptflow import PFClient
from promptflow.client import PFClient
from promptflow.entities import Run

# Get a pf client to manage runs
Expand Down Expand Up @@ -130,7 +130,7 @@ pf run show --name <run-name>
:sync: SDK
Show run with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient
# Get a pf client to manage runs
pf = PFClient()
# Get and print the run
Expand Down Expand Up @@ -166,7 +166,7 @@ pf run show-details --name <run-name>
:sync: SDK
Show run details with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient
from tabulate import tabulate

# Get a pf client to manage runs
Expand Down Expand Up @@ -204,7 +204,7 @@ pf run show-metrics --name <run-name>
:sync: SDK
Show run metrics with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient
import json

# Get a pf client to manage runs
Expand Down Expand Up @@ -240,7 +240,7 @@ A browser will open and display run outputs.
:sync: SDK
Visualize run with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient

# Get a pf client to manage runs
pf = PFClient()
Expand Down Expand Up @@ -280,7 +280,7 @@ pf run list
:sync: SDK
List with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient

# Get a pf client to manage runs
pf = PFClient()
Expand Down Expand Up @@ -317,7 +317,7 @@ pf run update --name <run-name> --set display_name=new_display_name
:sync: SDK
Update run with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient

# Get a pf client to manage runs
pf = PFClient()
Expand Down Expand Up @@ -346,7 +346,7 @@ pf run archive --name <run-name>
:sync: SDK
Archive with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient

# Get a pf client to manage runs
pf = PFClient()
Expand Down Expand Up @@ -379,7 +379,7 @@ pf run restore --name <run-name>
:sync: SDK
Restore with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient

# Get a pf client to manage runs
pf = PFClient()
Expand Down Expand Up @@ -409,7 +409,7 @@ pf run delete --name <run-name>
:sync: SDK
Delete with `PFClient`
```python
from promptflow import PFClient
from promptflow.client import PFClient

# Get a pf client to manage runs
pf = PFClient()
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-guides/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ More command details can be found in [CLI reference](../reference/pf-command-ref
In SDK, connections can be created and managed with `PFClient`.

```python
from promptflow import PFClient
from promptflow.client import PFClient
from promptflow.entities import AzureOpenAIConnection

# PFClient can help manage your runs and connections.
Expand Down Expand Up @@ -254,7 +254,7 @@ pf flow test --flow web-classification # "web-classification" is the directory
The return value of `test` function is the flow/node outputs.

```python
from promptflow import PFClient
from promptflow.client import PFClient

pf = PFClient()

Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-guides/run-and-evaluate-a-flow/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ More details can be found with `pf run --help`
:sync: SDK

```python
from promptflow import PFClient
from promptflow.client import PFClient

# Please protect the entry point by using `if __name__ == '__main__':`,
# otherwise it would cause unintended side effect when promptflow spawn worker processes.
Expand Down Expand Up @@ -180,7 +180,7 @@ After the run is finished, you can evaluate the run with below command, compared
More details can be found in [Use column mapping](https://aka.ms/pf/column-mapping).

```python
from promptflow import PFClient
from promptflow.client import PFClient

# PFClient can help manage your runs and connections.
pf = PFClient()
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-guides/tune-prompts-with-variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pf run create --flow web-classification --data web-classification/data.jsonl --v
:sync: SDK

```python
from promptflow import PFClient
from promptflow.client import PFClient
pf = PFClient() # get a promptflow client
flow = "web-classification"
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/tools-reference/python-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The snippet below shows the basic structure of a tool function. Promptflow will
from function parameters and type annotations.

```python
from promptflow import tool
from promptflow.core import tool
from promptflow.connections import CustomConnection

# The inputs section will change based on the arguments of the tool function, after you save the code
Expand Down Expand Up @@ -97,7 +97,7 @@ we have introduced support for keyword arguments (kwargs) in the Python tool.


```python
from promptflow import tool
from promptflow.core import tool


@tool
Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-math-variant/extract_result.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool
import json
import re

Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-with-pdf/build_index_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool
from chat_with_pdf.build_index import create_faiss_index


Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-with-pdf/chat_with_pdf_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool
from chat_with_pdf.main import chat_with_pdf


Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-with-pdf/download_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool
from chat_with_pdf.download import download


Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-with-pdf/find_context_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool
from chat_with_pdf.find_context import find_context


Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-with-pdf/qna_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool
from chat_with_pdf.qna import qna


Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-with-pdf/rewrite_question_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool
from chat_with_pdf.rewrite_question import rewrite_question


Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-with-pdf/setup_env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import Union

from promptflow import tool
from promptflow.core import tool
from promptflow.connections import AzureOpenAIConnection, OpenAIConnection

from chat_with_pdf.utils.lock import acquire_lock
Expand Down
2 changes: 1 addition & 1 deletion examples/flows/chat/chat-with-wikipedia/get_wiki_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import bs4
import requests

from promptflow import tool
from promptflow.core import tool


def decode_str(string):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool


@tool
Expand Down
Loading

0 comments on commit efe4e18

Please sign in to comment.