Skip to content

Commit

Permalink
Adding user agent to prompt based evaluators (microsoft#3487)
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.
  • Loading branch information
singankit authored Jul 1, 2024
1 parent 31b9a44 commit 4450ec4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

from promptflow.client import load_flow
from promptflow.core import AzureOpenAIModelConfiguration
try:
from ..._user_agent import USER_AGENT
except ImportError:
USER_AGENT = None


class CoherenceEvaluator:
Expand Down Expand Up @@ -43,6 +47,9 @@ def __init__(self, model_config: AzureOpenAIModelConfiguration):
model_config.api_version = "2024-02-15-preview"

prompty_model_config = {"configuration": model_config}
prompty_model_config.update({"parameters": {"extra_headers": {"x-ms-user-agent": USER_AGENT}}}) \
if USER_AGENT and isinstance(model_config, AzureOpenAIModelConfiguration) else None

current_dir = os.path.dirname(__file__)
prompty_path = os.path.join(current_dir, "coherence.prompty")
self._flow = load_flow(source=prompty_path, model=prompty_model_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

from promptflow.client import load_flow
from promptflow.core import AzureOpenAIModelConfiguration
try:
from ..._user_agent import USER_AGENT
except ImportError:
USER_AGENT = None


class FluencyEvaluator:
Expand Down Expand Up @@ -43,6 +47,8 @@ def __init__(self, model_config: AzureOpenAIModelConfiguration):
model_config.api_version = "2024-02-15-preview"

prompty_model_config = {"configuration": model_config}
prompty_model_config.update({"parameters": {"extra_headers": {"x-ms-user-agent": USER_AGENT}}}) \
if USER_AGENT and isinstance(model_config, AzureOpenAIModelConfiguration) else None
current_dir = os.path.dirname(__file__)
prompty_path = os.path.join(current_dir, "fluency.prompty")
self._flow = load_flow(source=prompty_path, model=prompty_model_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

from promptflow.client import load_flow
from promptflow.core import AzureOpenAIModelConfiguration
try:
from ..._user_agent import USER_AGENT
except ImportError:
USER_AGENT = None


class GroundednessEvaluator:
Expand Down Expand Up @@ -44,6 +48,10 @@ def __init__(self, model_config: AzureOpenAIModelConfiguration):
model_config.api_version = "2024-02-15-preview"

prompty_model_config = {"configuration": model_config}

prompty_model_config.update({"parameters": {"extra_headers": {"x-ms-user-agent": USER_AGENT}}}) \
if USER_AGENT and isinstance(model_config, AzureOpenAIModelConfiguration) else None

current_dir = os.path.dirname(__file__)
prompty_path = os.path.join(current_dir, "groundedness.prompty")
self._flow = load_flow(source=prompty_path, model=prompty_model_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

from promptflow.client import load_flow
from promptflow.core import AzureOpenAIModelConfiguration
try:
from ..._user_agent import USER_AGENT
except ImportError:
USER_AGENT = None


class SimilarityEvaluator:
Expand Down Expand Up @@ -44,6 +48,8 @@ def __init__(self, model_config: AzureOpenAIModelConfiguration):
model_config.api_version = "2024-02-15-preview"

prompty_model_config = {"configuration": model_config}
prompty_model_config.update({"parameters": {"extra_headers": {"x-ms-user-agent": USER_AGENT}}}) \
if USER_AGENT and isinstance(model_config, AzureOpenAIModelConfiguration) else None
current_dir = os.path.dirname(__file__)
prompty_path = os.path.join(current_dir, "similarity.prompty")
self._flow = load_flow(source=prompty_path, model=prompty_model_config)
Expand Down

0 comments on commit 4450ec4

Please sign in to comment.