Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PICKME] Fix prompty with workspace connection #3011

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading