Skip to content

Commit

Permalink
Alignement with new promptflow packages (#2642)
Browse files Browse the repository at this point in the history
# Description

Please add an informative description that covers that changes made by
the pull request and link all relevant issues.

# All Promptflow Contribution checklist:
- [ ] **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
- [ ] 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
- [ ] Pull request includes test coverage for the included changes.

---------

Co-authored-by: Nagkumar Arkalgud <nagkumar91@users.noreply.github.com>
  • Loading branch information
singankit and nagkumar91 authored Apr 4, 2024
1 parent 4275976 commit 1ef733c
Show file tree
Hide file tree
Showing 32 changed files with 46 additions and 37 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/promptflow-evals-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ jobs:
with:
name: promptflow-evals
path: ${{ env.WORKING_DIRECTORY }}
- name: install promptflow packages in editable mode
run: |
poetry run pip install -e ../promptflow-core
poetry run pip install -e ../promptflow-devkit
poetry run pip install -e ../promptflow-tools
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: install promptflow-evals from wheel
# wildcard expansion (*) does not work in Windows, so leverage python to find and install
run: poetry run pip install $(python -c "import glob; print(glob.glob('promptflow_evals-*.whl')[0])")
run: poetry run pip install --pre $(python -c "import glob; print(glob.glob('promptflow_evals-*.whl')[0])")
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: install test dependency group
run: poetry install --only test
Expand Down
1 change: 1 addition & 0 deletions scripts/dev-setup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"promptflow-azure",
"promptflow[azure]",
"promptflow-tools",
"promptflow-evals",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Optional, Dict, Callable
import pandas as pd
from ._flow_run_wrapper import FlowRunWrapper
from promptflow import PFClient
from promptflow.client import PFClient


def _calculate_mean(df) -> Dict[str, float]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import time
from promptflow import PFClient
from promptflow.client import PFClient


class FlowRunWrapper(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

from promptflow.entities import AzureOpenAIConnection
from promptflow.connections import AzureOpenAIConnection
from promptflow.evals.evaluators import GroundednessEvaluator, RelevanceEvaluator, CoherenceEvaluator, FluencyEvaluator
from typing import List, Dict
from concurrent.futures import ThreadPoolExecutor, as_completed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

from promptflow import load_flow
from promptflow.entities import AzureOpenAIConnection
from promptflow.client import load_flow
from promptflow.connections import AzureOpenAIConnection
from pathlib import Path


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
import numpy as np
import re

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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import tool
from promptflow.core import tool
import time
from constants import RAIService, Tasks
from typing import List
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import load_flow
from promptflow.client import load_flow
from pathlib import Path
from azure.core.credentials import TokenCredential
from promptflow.evals._constants import EvaluationMetrics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import load_flow
from promptflow.client import load_flow
from pathlib import Path
from azure.core.credentials import TokenCredential
from promptflow.evals._constants import EvaluationMetrics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import load_flow
from promptflow.client import load_flow
from pathlib import Path
from azure.core.credentials import TokenCredential
from promptflow.evals._constants import EvaluationMetrics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from promptflow import load_flow
from promptflow.client import load_flow
from pathlib import Path
from azure.core.credentials import TokenCredential
from promptflow.evals._constants import EvaluationMetrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

from promptflow import load_flow
from promptflow.client import load_flow
from pathlib import Path


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
from collections import Counter


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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

from promptflow import load_flow
from promptflow.client import load_flow
from promptflow.entities import AzureOpenAIConnection
from pathlib import Path

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
import numpy as np
import re

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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

from promptflow import load_flow
from promptflow.client import load_flow
from promptflow.entities import AzureOpenAIConnection
from pathlib import Path

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
import numpy as np
import re

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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

from promptflow import load_flow
from promptflow.client import load_flow
from promptflow.entities import AzureOpenAIConnection
from pathlib import Path

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
import numpy as np
import re

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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

from promptflow import load_flow
from promptflow.client import load_flow
from promptflow.entities import AzureOpenAIConnection
from pathlib import Path

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
import numpy as np
import re

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
3 changes: 2 additions & 1 deletion src/promptflow-evals/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ packages = [
[tool.poetry.dependencies]
python = "<4.0,>=3.8"
azure-ai-ml = ">=1.14.0"
promptflow = "<2.0.0"
promptflow-devkit = "<2.0.0"
promptflow-core = "<2.0.0"
promptflow-tools = "<2.0.0"

[tool.poetry.group.dev.dependencies]
Expand Down
13 changes: 7 additions & 6 deletions src/promptflow-evals/samples/built_in_evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
api_type="azure",
)

deployment_name = "gpt-4"
deployment_name = "GPT-4-Prod"

project_scope = {
"subscription_id": "2d385bf4-0756-4a76-aa95-28bf9ed3b625",
"resource_group_name": "rg-name",
"project_name": "project-name",
"subscription_id": "e0fd569c-e34a-4249-8c24-e8d723c7f054",
"resource_group_name": "resource-group",
"project_name": "project-name"

}


Expand Down Expand Up @@ -114,7 +115,7 @@ def run_safety_evaluators():


def run_qa_evaluator():
qa_eval = QAEvaluator(model_config=model_config, deployment_name="gpt-4")
qa_eval = QAEvaluator(model_config=model_config, deployment_name=deployment_name)

score = qa_eval(
question="Tokyo is the capital of which country?",
Expand All @@ -128,7 +129,7 @@ def run_qa_evaluator():


def run_chat_evaluator():
chat_eval = ChatEvaluator(model_config=model_config, deployment_name="gpt-4")
chat_eval = ChatEvaluator(model_config=model_config, deployment_name=deployment_name)

conversation = [
{"role": "user", "content": "What is the value of 2 + 2?"},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from promptflow.evals.evaluators import ChatEvaluator
from promptflow.entities import AzureOpenAIConnection
from promptflow.connections import AzureOpenAIConnection


@pytest.mark.unittest
Expand Down

0 comments on commit 1ef733c

Please sign in to comment.