Skip to content

Commit

Permalink
[PICKME] Fix prompty with workspace connection (#3011)
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.

---------

Signed-off-by: Brynn Yin <[email protected]>
  • Loading branch information
brynn-code authored Apr 25, 2024
1 parent 5d24e12 commit 4c00cdb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@ def get(self, name: str, **kwargs) -> _Connection:
:param name: Name of the connection.
:type name: str
:return: connection object retrieved from the database.
:return: connection object retrieved from Azure.
:rtype: ~promptflow.sdk.entities._connection._Connection
"""
return self._get(name, **kwargs)

def _get(self, name: str, **kwargs) -> _Connection:
"""Get a connection entity.
:param name: Name of the connection.
:type name: str
:return: connection object retrieved from Azure.
:rtype: ~promptflow.sdk.entities._connection._Connection
"""
with_secrets = kwargs.get("with_secrets", False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

from promptflow._sdk._load_functions import load_flow
from promptflow._sdk.entities._flows._flow_context_resolver import FlowContextResolver
from promptflow.core import Prompty
from promptflow.core._connection_provider._workspace_connection_provider import WorkspaceConnectionProvider

FLOWS_DIR = PROMPTFLOW_ROOT / "tests" / "test_configs" / "flows"
DATAS_DIR = PROMPTFLOW_ROOT / "tests" / "test_configs" / "datas"
TEST_CONFIG_DIR = PROMPTFLOW_ROOT / "tests" / "test_configs"
FLOWS_DIR = TEST_CONFIG_DIR / "flows"
DATAS_DIR = TEST_CONFIG_DIR / "datas"
PROMPTY_DIR = TEST_CONFIG_DIR / "prompty"


@pytest.mark.usefixtures("global_config")
Expand Down Expand Up @@ -45,3 +48,9 @@ def assert_client(mock_self, provider, **kwargs):
flow = load_flow(source=f"{FLOWS_DIR}/web_classification")
with mock.patch("promptflow.core._serving.flow_invoker.FlowInvoker.resolve_connections", assert_client):
FlowContextResolver.resolve(flow=flow)

def test_prompty_callable(self, pf):
# Test prompty callable with global config ws connection
prompty = Prompty.load(source=f"{PROMPTY_DIR}/prompty_example.prompty")
result = prompty(question="what is the result of 1+1?")
assert "2" in result

0 comments on commit 4c00cdb

Please sign in to comment.