text
stringlengths
8
1.72M
id
stringlengths
22
143
metadata
dict
__index_level_0__
int64
0
104
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from enum import Enum from typing import Any, Dict, Union import requests from azure.ai.ml._restclient.v2023_06_01_preview.models import Wo...
promptflow/src/promptflow/promptflow/azure/operations/_arm_connection_operations.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/operations/_arm_connection_operations.py", "repo_id": "promptflow", "token_count": 5724 }
46
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from dataclasses import dataclass, is_dataclass from promptflow._core.tools_manager import register_connections from promptflow._sdk.entiti...
promptflow/src/promptflow/promptflow/connections/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/connections/__init__.py", "repo_id": "promptflow", "token_count": 399 }
47
import inspect from typing import Any, Callable, Dict, List, Mapping from promptflow._utils.logger_utils import flow_logger from promptflow.contracts.flow import InputAssignment, InputValueType, Node from promptflow.executor import _input_assignment_parser class DAGManager: def __init__(self, nodes: List[Node], ...
promptflow/src/promptflow/promptflow/executor/_dag_manager.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/executor/_dag_manager.py", "repo_id": "promptflow", "token_count": 3269 }
48
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from ._cache_storage import AbstractCacheStorage # noqa: F401 from ._run_storage import AbstractRunStorage # noqa: F401 __all__ = ["Abst...
promptflow/src/promptflow/promptflow/storage/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/storage/__init__.py", "repo_id": "promptflow", "token_count": 74 }
49
import re from pathlib import Path from tempfile import mkdtemp import pytest from promptflow._utils.exception_utils import ErrorResponse from promptflow._utils.logger_utils import LogContext from promptflow.contracts.run_info import Status from promptflow.contracts.run_mode import RunMode from promptflow.executor._f...
promptflow/src/promptflow/tests/executor/e2etests/test_concurent_execution.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/e2etests/test_concurent_execution.py", "repo_id": "promptflow", "token_count": 1258 }
50
{# Please replace the template with your own prompt. #} Write a simple program that displays the greeting message: "{{text}}" when executed.
promptflow/src/promptflow/tests/executor/package_tools/custom_llm_tool/my_prompt.jinja2/0
{ "file_path": "promptflow/src/promptflow/tests/executor/package_tools/custom_llm_tool/my_prompt.jinja2", "repo_id": "promptflow", "token_count": 33 }
51
import pytest from promptflow._core.generator_proxy import GeneratorProxy, generate_from_proxy def generator(): for i in range(3): yield i def iterator(): return iter([0, 1, 2]) @pytest.mark.unittest def test_generator_proxy_next(): proxy = GeneratorProxy(generator()) assert proxy.items =...
promptflow/src/promptflow/tests/executor/unittests/_core/test_generator_proxy.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/_core/test_generator_proxy.py", "repo_id": "promptflow", "token_count": 666 }
52
import io import logging import time from multiprocessing.pool import ThreadPool from pathlib import Path from tempfile import mkdtemp from unittest.mock import Mock from uuid import uuid4 import pytest from promptflow._utils.credential_scrubber import CredentialScrubber from promptflow._utils.logger_utils import ( ...
promptflow/src/promptflow/tests/executor/unittests/_utils/test_logger_utils.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/_utils/test_logger_utils.py", "repo_id": "promptflow", "token_count": 4473 }
53
import json import pytest from promptflow._sdk._constants import VIS_JS_BUNDLE_FILENAME from promptflow.contracts._run_management import VisualizationRender @pytest.mark.unittest def test_visualization_render(): data = {"key": "value"} viz = VisualizationRender(data) assert viz.data == json.dumps(json...
promptflow/src/promptflow/tests/executor/unittests/contracts/test_run_management.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/contracts/test_run_management.py", "repo_id": "promptflow", "token_count": 135 }
54
import multiprocessing import os import sys import uuid from multiprocessing import Queue from pathlib import Path from tempfile import mkdtemp from unittest.mock import patch import pytest from pytest_mock import MockFixture from promptflow._utils.logger_utils import LogContext from promptflow.contracts.run_info imp...
promptflow/src/promptflow/tests/executor/unittests/processpool/test_line_execution_process_pool.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/processpool/test_line_execution_process_pool.py", "repo_id": "promptflow", "token_count": 10244 }
55
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import json from pathlib import Path import pytest from promptflow.azure._entities._flow import Flow from .._azure_utils import DEFAULT_T...
promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_flow_operations.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_flow_operations.py", "repo_id": "promptflow", "token_count": 751 }
56
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from pathlib import Path from unittest.mock import patch import pytest from promptflow._sdk._errors import FlowOperationError from promptf...
promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_flow_operations.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_flow_operations.py", "repo_id": "promptflow", "token_count": 1471 }
57
import uuid from pathlib import Path import pydash import pytest from promptflow._sdk._constants import SCRUBBED_VALUE from promptflow._sdk._pf_client import PFClient from promptflow._sdk.entities import AzureOpenAIConnection, CustomConnection _client = PFClient() TEST_ROOT = Path(__file__).parent.parent.parent CON...
promptflow/src/promptflow/tests/sdk_cli_test/e2etests/test_connection.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/e2etests/test_connection.py", "repo_id": "promptflow", "token_count": 2245 }
58
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CustomConnection.schema.json name: my_custom_connection type: custom configs: key1: "test1" secrets: # must-have key2: "test2"
promptflow/src/promptflow/tests/test_configs/connections/custom_connection.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/connections/custom_connection.yaml", "repo_id": "promptflow", "token_count": 76 }
59
{"input_val": "input1"}
promptflow/src/promptflow/tests/test_configs/datas/simple_eager_flow_data.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/datas/simple_eager_flow_data.jsonl", "repo_id": "promptflow", "token_count": 10 }
60
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Experiment.schema.json description: Basic experiment without script node data: - name: my_data path: ../../flows/web_classification/data.jsonl inputs: - name: my_input type: int default: 1 nodes: - name: main type: flow path: ...
promptflow/src/promptflow/tests/test_configs/experiments/basic-no-script-template/basic.exp.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/experiments/basic-no-script-template/basic.exp.yaml", "repo_id": "promptflow", "token_count": 301 }
61
{"groundtruth": "Tomorrow's weather will be sunny.","prediction": "The weather will be sunny tomorrow."} {"groundtruth": "Hello,","prediction": "World."} {"groundtruth": "Promptflow is a super easy-to-use tool, right?","prediction": "Yes!"}
promptflow/src/promptflow/tests/test_configs/flows/aggregation_node_failed/data.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/aggregation_node_failed/data.jsonl", "repo_id": "promptflow", "token_count": 70 }
62
[{"text": "Hello World!"}]
promptflow/src/promptflow/tests/test_configs/flows/basic-with-connection/samples.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/basic-with-connection/samples.json", "repo_id": "promptflow", "token_count": 11 }
63
from promptflow import tool @tool def show_answer(chat_answer: str): print("print:", chat_answer) return chat_answer
promptflow/src/promptflow/tests/test_configs/flows/chat_flow/show_answer.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/chat_flow/show_answer.py", "repo_id": "promptflow", "token_count": 43 }
64
inputs: chat_history: type: list is_chat_history: true question: type: string is_chat_input: true outputs: answer: type: string reference: ${stream.output.answer} is_chat_output: true nodes: - name: stream type: python source: type: code path: stream.py inputs: chat_h...
promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_python_node_streaming_output/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_python_node_streaming_output/flow.dag.yaml", "repo_id": "promptflow", "token_count": 154 }
65
{ "input1": "False", "input2": "False", "input3": "False", "input4": "False" }
promptflow/src/promptflow/tests/test_configs/flows/concurrent_execution_flow/inputs.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/concurrent_execution_flow/inputs.json", "repo_id": "promptflow", "token_count": 39 }
66
from promptflow import tool from promptflow import log_metric @tool def average(input: list): avg, cnt = 0, 0 for num in input: if num!=None: avg += num cnt += 1 if len(input) > 0: avg = avg/cnt log_metric("average", avg) return avg
promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_aggregate_bypassed/aggregation_node.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_aggregate_bypassed/aggregation_node.py", "repo_id": "promptflow", "token_count": 108 }
67
#! /bin/bash CONDA_ENV_PATH="$(conda info --base)/envs/promptflow-serve" export PATH="$CONDA_ENV_PATH/bin:$PATH" ls ls /connections pf connection create --file /connections/custom_connection.yaml echo "start promptflow serving with worker_num: 8, worker_threads: 1" cd /flow gunicorn -w 8 --threads 1 -b "0.0.0.0:8080"...
promptflow/src/promptflow/tests/test_configs/flows/export/linux/runit/promptflow-serve/run/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/export/linux/runit/promptflow-serve/run", "repo_id": "promptflow", "token_count": 147 }
68
from promptflow import tool @tool def get_dict_val(key): # get from env var print(key) if not isinstance(key, dict): raise TypeError(f"key must be a dict, got {type(key)}") return {"value": f"{key}: {type(key)}", "origin_value": key}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_dict_input/get_dict_val.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_dict_input/get_dict_val.py", "repo_id": "promptflow", "token_count": 103 }
69
inputs: text: type: string outputs: output_prompt: type: string reference: ${echo_my_prompt.output} nodes: - inputs: text: ${inputs.text} name: echo_my_prompt type: python source: type: code path: hello.py node_variants: {}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_invalid_import/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_invalid_import/flow.dag.yaml", "repo_id": "promptflow", "token_count": 111 }
70
inputs: text: type: string default: Hello! outputs: out: type: string reference: ${My_First_Tool_00f8.output} nodes: - name: My_Second_Tool_usi3 type: python source: type: package tool: my_tool_package.tools.my_tool_2.MyTool.my_tool inputs: connection: custom_strong_type_connection...
promptflow/src/promptflow/tests/test_configs/flows/flow_with_package_tool_with_custom_strong_type_connection/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_package_tool_with_custom_strong_type_connection/flow.dag.yaml", "repo_id": "promptflow", "token_count": 237 }
71
import asyncio from time import sleep from promptflow import tool, trace @trace async def is_valid_name(name): await asyncio.sleep(0.5) return len(name) > 0 @trace async def get_user_name(user_id): await asyncio.sleep(0.5) user_name = f"User {user_id}" if not await is_valid_name(user_name): ...
promptflow/src/promptflow/tests/test_configs/flows/flow_with_trace_async/greetings.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_trace_async/greetings.py", "repo_id": "promptflow", "token_count": 276 }
72
import time from promptflow import tool def f1(): time.sleep(61) return 0 def f2(): return f1() @tool def long_run_func(): return f2()
promptflow/src/promptflow/tests/test_configs/flows/long_run/long_run.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/long_run/long_run.py", "repo_id": "promptflow", "token_count": 65 }
73
from promptflow import tool import random @tool def my_python_tool(idx: int) -> int: return idx
promptflow/src/promptflow/tests/test_configs/flows/one_line_of_bulktest_timeout/my_python_tool.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/one_line_of_bulktest_timeout/my_python_tool.py", "repo_id": "promptflow", "token_count": 35 }
74
{ "text": "Hello World!" }
promptflow/src/promptflow/tests/test_configs/flows/python_stream_tools/inputs.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_stream_tools/inputs.json", "repo_id": "promptflow", "token_count": 14 }
75
inputs: image: type: image default: "" outputs: output: type: image reference: ${python_node_2.output} nodes: - name: python_node type: python source: type: code path: pick_an_image.py inputs: image_1: ${inputs.image} image_2: logo_2.png - name: python_node_2 type: python s...
promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_invalid_default_value/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_invalid_default_value/flow.dag.yaml", "repo_id": "promptflow", "token_count": 193 }
76
from pathlib import Path from promptflow import tool print(f"The script is {__file__}") assert Path(__file__).is_absolute(), f"__file__ should be absolute path, got {__file__}" @tool def my_python_tool(input1: str) -> str: from pathlib import Path assert Path(__file__).name == "script_with___file__.py" ...
promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/script_with___file__.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/script_with___file__.py", "repo_id": "promptflow", "token_count": 165 }
77
{"num": "hello"}
promptflow/src/promptflow/tests/test_configs/flows/simple_flow_with_python_tool/inputs.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/simple_flow_with_python_tool/inputs.jsonl", "repo_id": "promptflow", "token_count": 6 }
78
from promptflow import tool from promptflow.contracts.types import AssistantDefinition @tool def test_assistant_definition(message: str, assistant_definition: AssistantDefinition): assert assistant_definition.model == "mock_model" assert assistant_definition.instructions == "mock_instructions" invoker = a...
promptflow/src/promptflow/tests/test_configs/flows/tool_with_assistant_definition/test_assistant_definition.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/tool_with_assistant_definition/test_assistant_definition.py", "repo_id": "promptflow", "token_count": 283 }
79
{"url": "https://www.youtube.com/watch?v=o5ZQyXaAv1g", "answer": "Channel", "evidence": "Url"} {"url": "https://www.youtube.com/watch?v=o5ZQyXaAv1g", "answer": "Channel", "evidence": "Url"} {"url": "https://www.youtube.com/watch?v=o5ZQyXaAv1g", "answer": "Channel", "evidence": "Url"}
promptflow/src/promptflow/tests/test_configs/flows/web_classification_input_dir/details.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/web_classification_input_dir/details.jsonl", "repo_id": "promptflow", "token_count": 120 }
80
interactions: - request: body: null headers: Accept: - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive User-Agent: - promptflow-sdk/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.10.13 (Windows-...
promptflow/src/promptflow/tests/test_configs/recordings/test_flow_operations_TestFlow_test_list_flows.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_flow_operations_TestFlow_test_list_flows.yaml", "repo_id": "promptflow", "token_count": 5582 }
81
interactions: - request: body: null headers: Accept: - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive User-Agent: - promptflow-sdk/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.10.13 (Windows-...
promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_get_details_against_partial_completed_run.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_get_details_against_partial_completed_run.yaml", "repo_id": "promptflow", "token_count": 175043 }
82
name: flow_run_20230629_101205 description: sample bulk run # invalid remote flow format should not be supported. flow: invalid_remote_flow data: ../datas/webClassification1.jsonl column_mapping: url: "${data.url}" variant: ${summarize_text_content.variant_0} # run config: env related environment_variables: env_fil...
promptflow/src/promptflow/tests/test_configs/runs/bulk_run_invalid_remote_flow_str.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/runs/bulk_run_invalid_remote_flow_str.yaml", "repo_id": "promptflow", "token_count": 105 }
83
{ "test_tool.tool_with_generated_by_input.my_tool": { "name": "Tool with Generated By Input", "type": "python", "inputs": { "index_json": { "type": [ "string" ], "generated_by": { "func_path": "test_tool.tool_with_generated_by_input.generate_index_json", ...
promptflow/src/promptflow/tests/test_configs/tools/expected_generated_by_meta.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/tools/expected_generated_by_meta.json", "repo_id": "promptflow", "token_count": 3786 }
84
inputs: num: type: int outputs: content: type: string reference: ${divide_num.output} nodes: - name: divide_num type: python source: type: code path: divide_num.py inputs: num: ${inputs.num} - name: divide_num_1 type: python source: type: code path: divide_num.py inputs: ...
promptflow/src/promptflow/tests/test_configs/wrong_flows/node_reference_not_found/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/wrong_flows/node_reference_not_found/flow.dag.yaml", "repo_id": "promptflow", "token_count": 209 }
85
# Run prompt flow in Azure AI :::{admonition} Experimental feature This is an experimental feature, and may change at any time. Learn [more](../../how-to-guides/faq.md#stable-vs-experimental). ::: Assuming you have learned how to create and run a flow following [Quick start](../../how-to-guides/quick-start.md). This ...
promptflow/docs/cloud/azureai/quick-start.md/0
{ "file_path": "promptflow/docs/cloud/azureai/quick-start.md", "repo_id": "promptflow", "token_count": 2002 }
0
# Deploy a flow using Kubernetes :::{admonition} Experimental feature This is an experimental feature, and may change at any time. Learn [more](../faq.md#stable-vs-experimental). ::: There are four steps to deploy a flow using Kubernetes: 1. Build the flow as docker format. 2. Build the docker image. 3. Create Kuberne...
promptflow/docs/how-to-guides/deploy-a-flow/deploy-using-kubernetes.md/0
{ "file_path": "promptflow/docs/how-to-guides/deploy-a-flow/deploy-using-kubernetes.md", "repo_id": "promptflow", "token_count": 2398 }
1
# Using File Path as Tool Input Users sometimes need to reference local files within a tool to implement specific logic. To simplify this, we've introduced the `FilePath` input type. This input type enables users to either select an existing file or create a new one, then pass it to a tool, allowing the tool to access...
promptflow/docs/how-to-guides/develop-a-tool/use-file-path-as-tool-input.md/0
{ "file_path": "promptflow/docs/how-to-guides/develop-a-tool/use-file-path-as-tool-input.md", "repo_id": "promptflow", "token_count": 1804 }
2
# Alternative LLMs This section provides tutorials on incorporating alternative large language models into prompt flow. ```{toctree} :maxdepth: 1 :hidden: ```
promptflow/docs/integrations/llms/index.md/0
{ "file_path": "promptflow/docs/integrations/llms/index.md", "repo_id": "promptflow", "token_count": 43 }
3
# Python ## Introduction Users are empowered by the Python Tool to offer customized code snippets as self-contained executable nodes in PromptFlow. Users can effortlessly create Python tools, edit code, and verify results with ease. ## Inputs | Name | Type | Description |...
promptflow/docs/reference/tools-reference/python-tool.md/0
{ "file_path": "promptflow/docs/reference/tools-reference/python-tool.md", "repo_id": "promptflow", "token_count": 1821 }
4
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/SerpConnection.schema.json name: serp_connection type: serp api_key: "<to-be-replaced>"
promptflow/examples/connections/serp.yml/0
{ "file_path": "promptflow/examples/connections/serp.yml", "repo_id": "promptflow", "token_count": 59 }
5
import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) PDF_DIR = os.path.join(BASE_DIR, ".pdfs") INDEX_DIR = os.path.join(BASE_DIR, ".index/.pdfs/")
promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/constants.py/0
{ "file_path": "promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/constants.py", "repo_id": "promptflow", "token_count": 73 }
6
import unittest import os import time import traceback class BaseTest(unittest.TestCase): def setUp(self): root = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../") self.flow_path = os.path.join(root, "chat-with-pdf") self.data_path = os.path.join( self.flow_pat...
promptflow/examples/flows/chat/chat-with-pdf/tests/base_test.py/0
{ "file_path": "promptflow/examples/flows/chat/chat-with-pdf/tests/base_test.py", "repo_id": "promptflow", "token_count": 3126 }
7
from typing import List from promptflow import tool @tool def aggregate(groundedness_scores: List[float]): """ This tool aggregates the processed result of all lines to the variant level and log metric for each variant. :param processed_results: List of the output of line_process node. :param variant...
promptflow/examples/flows/evaluation/eval-groundedness/aggregate.py/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-groundedness/aggregate.py", "repo_id": "promptflow", "token_count": 350 }
8
from promptflow import tool import numpy as np import re @tool def concat_results(gpt_coherence_score: str = None, gpt_similarity_score: str = None, gpt_fluency_score: str = None, gpt_relevance_score: str = None, gpt_groundedness_score: str =...
promptflow/examples/flows/evaluation/eval-qna-non-rag/concat_scores.py/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-qna-non-rag/concat_scores.py", "repo_id": "promptflow", "token_count": 1177 }
9
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json inputs: metrics: type: string default: gpt_groundedness,gpt_relevance,gpt_retrieval_score is_chat_input: false answer: type: string default: Of the tents mentioned in the retrieved documents, the Alpine Explorer ...
promptflow/examples/flows/evaluation/eval-qna-rag-metrics/flow.dag.yaml/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-qna-rag-metrics/flow.dag.yaml", "repo_id": "promptflow", "token_count": 11138 }
10
from promptflow import tool @tool def parse_translation(translation_results: dict, language: str) -> str: return translation_results[language]
promptflow/examples/flows/integrations/azure-ai-language/analyze_documents/parse_translation.py/0
{ "file_path": "promptflow/examples/flows/integrations/azure-ai-language/analyze_documents/parse_translation.py", "repo_id": "promptflow", "token_count": 40 }
11
from promptflow import tool @tool def generate_goal(items: list = []) -> str: """ Generate a numbered list from given items based on the item_type. Args: items (list): A list of items to be numbered. Returns: str: The formatted numbered list. """ return "\n".join(f"{i + 1}. {...
promptflow/examples/flows/standard/autonomous-agent/generate_goal.py/0
{ "file_path": "promptflow/examples/flows/standard/autonomous-agent/generate_goal.py", "repo_id": "promptflow", "token_count": 132 }
12
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json inputs: text: type: string default: Hello World! outputs: output: type: string reference: ${llm.output} nodes: - name: hello_prompt type: prompt source: type: code path: hello.jinja2 inputs: text: ${in...
promptflow/examples/flows/standard/basic-with-connection/flow.dag.yaml/0
{ "file_path": "promptflow/examples/flows/standard/basic-with-connection/flow.dag.yaml", "repo_id": "promptflow", "token_count": 243 }
13
{"question": "What is Prompt flow?"} {"question": "What is ChatGPT?"}
promptflow/examples/flows/standard/conditional-flow-for-if-else/data.jsonl/0
{ "file_path": "promptflow/examples/flows/standard/conditional-flow-for-if-else/data.jsonl", "repo_id": "promptflow", "token_count": 22 }
14
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json inputs: question: type: string default: Please describe this image. input_image: type: image default: https://developer.microsoft.com/_devcom/images/logo-ms-social.png outputs: answer: type: string reference: ...
promptflow/examples/flows/standard/describe-image/flow.dag.yaml/0
{ "file_path": "promptflow/examples/flows/standard/describe-image/flow.dag.yaml", "repo_id": "promptflow", "token_count": 359 }
15
import asyncio import logging import time import uuid from typing import List from openai.version import VERSION as OPENAI_VERSION import os from abc import ABC, abstractmethod import tiktoken from dotenv import load_dotenv from prompt import PromptLimitException class AOAI(ABC): def __init__(self, **kwargs): ...
promptflow/examples/flows/standard/gen-docstring/azure_open_ai.py/0
{ "file_path": "promptflow/examples/flows/standard/gen-docstring/azure_open_ai.py", "repo_id": "promptflow", "token_count": 5578 }
16
# Math to Code Math to Code is a project that utilizes the power of the chatGPT model to generate code that models math questions and then executes the generated code to obtain the final numerical answer. > [!NOTE] > > Building a system that generates executable code from user input with LLM is [a complex problem with...
promptflow/examples/flows/standard/maths-to-code/README.md/0
{ "file_path": "promptflow/examples/flows/standard/maths-to-code/README.md", "repo_id": "promptflow", "token_count": 1060 }
17
import unittest import traceback import os import promptflow.azure as azure from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential import promptflow class BaseTest(unittest.TestCase): def setUp(self) -> None: root = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../") ...
promptflow/examples/flows/standard/named-entity-recognition/eval_test.py/0
{ "file_path": "promptflow/examples/flows/standard/named-entity-recognition/eval_test.py", "repo_id": "promptflow", "token_count": 1876 }
18
from pathlib import Path from ruamel.yaml import YAML def collect_tools_from_directory(base_dir) -> dict: tools = {} yaml = YAML() for f in Path(base_dir).glob("**/*.yaml"): with open(f, "r") as f: tools_in_file = yaml.load(f) for identifier, tool in tools_in_file.items():...
promptflow/examples/tools/tool-package-quickstart/my_tool_package/tools/utils.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/my_tool_package/tools/utils.py", "repo_id": "promptflow", "token_count": 236 }
19
from my_tool_package.tools.tool_with_dynamic_list_input import my_tool, my_list_func def test_my_tool(): result = my_tool(input_text=["apple", "banana"], input_prefix="My") assert result == 'Hello My apple,banana' def test_my_list_func(): result = my_list_func(prefix="My") assert len(result) == 10 ...
promptflow/examples/tools/tool-package-quickstart/tests/test_tool_with_dynamic_input.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/tests/test_tool_with_dynamic_input.py", "repo_id": "promptflow", "token_count": 132 }
20
--- resources: examples/connections/azure_openai.yml, examples/flows/standard/web-classification --- # Deploy flow using Azure App Service This example demos how to deploy a flow using Azure App Service. [Azure App Service](https://learn.microsoft.com/azure/app-service/) is an HTTP-based service for hosting web appl...
promptflow/examples/tutorials/flow-deploy/azure-app-service/README.md/0
{ "file_path": "promptflow/examples/tutorials/flow-deploy/azure-app-service/README.md", "repo_id": "promptflow", "token_count": 872 }
21
--- kind: Namespace apiVersion: v1 metadata: name: web-classification --- apiVersion: v1 kind: Secret metadata: name: open-ai-connection-api-key namespace: web-classification type: Opaque data: open-ai-connection-api-key: <encoded_secret> --- apiVersion: v1 kind: Service metadata: name: web-classification-ser...
promptflow/examples/tutorials/flow-deploy/kubernetes/deployment.yaml/0
{ "file_path": "promptflow/examples/tutorials/flow-deploy/kubernetes/deployment.yaml", "repo_id": "promptflow", "token_count": 487 }
22
import argparse import os import sys from pathlib import Path from utils import Color, run_command, print_red if __name__ == "__main__": parser = argparse.ArgumentParser(description=Color.RED + "Test Coverage for Promptflow!" + Color.END + "\n") parser.add_argument("-p", required=True, nargs="+", help="The p...
promptflow/scripts/building/run_coverage_tests.py/0
{ "file_path": "promptflow/scripts/building/run_coverage_tests.py", "repo_id": "promptflow", "token_count": 1969 }
23
# Curl Install Script Information The scripts in this directory are used for installing through curl and they point to the packages on PyPI. ## Install or update promptflow curl https://promptflowartifact.blob.core.windows.net/linux-install-scripts/install | bash The script can also be downloaded and run locally. Y...
promptflow/scripts/installer/curl_install_pypi/README.md/0
{ "file_path": "promptflow/scripts/installer/curl_install_pypi/README.md", "repo_id": "promptflow", "token_count": 305 }
24
DIM objshell set objshell = wscript.createobject("wscript.shell") iReturn = objshell.run("pfs.bat start --force", 0, true)
promptflow/scripts/installer/windows/scripts/promptflow_service.vbs/0
{ "file_path": "promptflow/scripts/installer/windows/scripts/promptflow_service.vbs", "repo_id": "promptflow", "token_count": 41 }
25
- name: {{ step_name }} uses: azure/login@v1 with: creds: ${{ '{{' }} secrets.AZURE_CREDENTIALS }}
promptflow/scripts/readme/ghactions_driver/workflow_steps/step_azure_login.yml.jinja2/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/workflow_steps/step_azure_login.yml.jinja2", "repo_id": "promptflow", "token_count": 47 }
26
# This code is autogenerated. # Code is generated by running custom script: python3 readme.py # Any manual changes to this file may cause incorrect behavior. # Any manual changes will be overwritten if the code is regenerated. name: {{ workflow_name }} on: schedule: - cron: "{{ crontab }}" # {{ crontab_comment }...
promptflow/scripts/readme/ghactions_driver/workflow_templates/workflow_skeleton.yml.jinja2/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/workflow_templates/workflow_skeleton.yml.jinja2", "repo_id": "promptflow", "token_count": 195 }
27
import argparse import os import re from jinja2 import Environment, FileSystemLoader def make_pythonic_variable_name(input_string): variable_name = input_string.strip() variable_name = re.sub(r'\W|^(?=\d)', '_', variable_name) if not variable_name[0].isalpha() and variable_name[0] != '_': variable...
promptflow/scripts/tool/generate_tool_package_template.py/0
{ "file_path": "promptflow/scripts/tool/generate_tool_package_template.py", "repo_id": "promptflow", "token_count": 2385 }
28
import re from azure.core.exceptions import HttpResponseError, ResourceExistsError from azure.identity import ClientSecretCredential from azure.keyvault.secrets import SecretClient from exceptions import ( SecretNameAlreadyExistsException, SecretNameInvalidException, SecretNoSetPermissionException, ) key_...
promptflow/scripts/tool/utils/secret_manager.py/0
{ "file_path": "promptflow/scripts/tool/utils/secret_manager.py", "repo_id": "promptflow", "token_count": 894 }
29
from openai import OpenAIError from promptflow.exceptions import ErrorTarget, SystemErrorException, UserErrorException openai_error_code_ref_message = "Error reference: https://platform.openai.com/docs/guides/error-codes/api-errors" def to_openai_error_message(e: Exception) -> str: ex_type = type(e).__name__ ...
promptflow/src/promptflow-tools/promptflow/tools/exception.py/0
{ "file_path": "promptflow/src/promptflow-tools/promptflow/tools/exception.py", "repo_id": "promptflow", "token_count": 3068 }
30
import pytest import json from promptflow.tools.openai import chat, completion, OpenAI from promptflow.tools.exception import WrappedOpenAIError @pytest.fixture def openai_provider(open_ai_connection) -> OpenAI: return OpenAI(open_ai_connection) @pytest.mark.usefixtures("use_secrets_config_file") @pytest.mark....
promptflow/src/promptflow-tools/tests/test_openai.py/0
{ "file_path": "promptflow/src/promptflow-tools/tests/test_openai.py", "repo_id": "promptflow", "token_count": 3123 }
31
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- # pylint: disable=wrong-import-position import json import time from promptflow._cli._pf.help import show_privacy_statement, show_welcome_m...
promptflow/src/promptflow/promptflow/_cli/_pf_azure/entry.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/_pf_azure/entry.py", "repo_id": "promptflow", "token_count": 2094 }
32
{"groundtruth": "App", "prediction": "App"}
promptflow/src/promptflow/promptflow/_cli/data/evaluation_flow/data.jsonl/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/data/evaluation_flow/data.jsonl", "repo_id": "promptflow", "token_count": 15 }
33
from traceback import TracebackException from promptflow._utils.exception_utils import ( ADDITIONAL_INFO_USER_EXECUTION_ERROR, is_pf_core_frame, last_frame_info, remove_suffix, ) from promptflow.exceptions import ErrorTarget, SystemErrorException, UserErrorException, ValidationException class Unexpec...
promptflow/src/promptflow/promptflow/_core/_errors.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_core/_errors.py", "repo_id": "promptflow", "token_count": 1699 }
34
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore # flake8: noqa """Put some imports here for internal pack...
promptflow/src/promptflow/promptflow/_internal/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_internal/__init__.py", "repo_id": "promptflow", "token_count": 1306 }
35
# Prompt Flow Service This document will describe the usage of pfs(prompt flow service) CLI. ### Start prompt flow service (optional) If you don't install pfs as a service, you need to start pfs manually. pfs CLI provides **start** command to start service. You can also use this command to specify the service port. `...
promptflow/src/promptflow/promptflow/_sdk/_service/README.md/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_service/README.md", "repo_id": "promptflow", "token_count": 387 }
36
# --------------------------------------------------------- # Copyright (c) 2013-2022 Caleb P. Burns credits dahlia <https://github.com/dahlia> # Licensed under the MPLv2 License. See License.txt in the project root for # license information. # --------------------------------------------------------- """ This file cod...
promptflow/src/promptflow/promptflow/_sdk/_vendor/_pathspec.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_vendor/_pathspec.py", "repo_id": "promptflow", "token_count": 10455 }
37
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import abc from typing import Dict, Optional from promptflow._sdk._constants import BASE_PATH_CONTEXT_KEY, CommonYamlFields from promptflow...
promptflow/src/promptflow/promptflow/_sdk/entities/_yaml_translatable.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/entities/_yaml_translatable.py", "repo_id": "promptflow", "token_count": 744 }
38
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import os.path from dotenv import dotenv_values from marshmallow import fields, post_load, pre_load from promptflow._sdk._utils import is_...
promptflow/src/promptflow/promptflow/_sdk/schemas/_run.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/schemas/_run.py", "repo_id": "promptflow", "token_count": 1523 }
39
import tiktoken from importlib.metadata import version from promptflow.exceptions import UserErrorException IS_LEGACY_OPENAI = version("openai").startswith("0.") class OpenAIMetricsCalculator: def __init__(self, logger=None) -> None: self._logger = logger def get_openai_metrics_from_api_call(self, ...
promptflow/src/promptflow/promptflow/_utils/openai_metrics_calculator.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_utils/openai_metrics_calculator.py", "repo_id": "promptflow", "token_count": 4184 }
40
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- """ This file stores functions and objects that will be used in prompt-flow sdk. DO NOT change the module names in "all" list, add new modu...
promptflow/src/promptflow/promptflow/azure/_ml/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_ml/__init__.py", "repo_id": "promptflow", "token_count": 593 }
41
# coding=utf-8 # -------------------------------------------------------------------------- # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.0, generator: @autorest/python@5.12.2) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # ------------------------------...
promptflow/src/promptflow/promptflow/azure/_restclient/flow/aio/operations/_connections_operations.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/aio/operations/_connections_operations.py", "repo_id": "promptflow", "token_count": 9090 }
42
# coding=utf-8 # -------------------------------------------------------------------------- # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.0, generator: @autorest/python@5.12.2) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # ------------------------------...
promptflow/src/promptflow/promptflow/azure/_restclient/flow/operations/_connections_operations.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/operations/_connections_operations.py", "repo_id": "promptflow", "token_count": 13181 }
43
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import re class BulkRunURL: """Parser for a flow run URL.""" REGEX_PATTERN = ".*prompts/flow/([^/]+)/([^/]+)/bulktest/([^/]+).*" ...
promptflow/src/promptflow/promptflow/azure/_utils/_url_utils.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_utils/_url_utils.py", "repo_id": "promptflow", "token_count": 1057 }
44
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from promptflow.exceptions import ErrorTarget, SystemErrorException, UserErrorException, ValidationException class InputMappingError(Vali...
promptflow/src/promptflow/promptflow/batch/_errors.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/batch/_errors.py", "repo_id": "promptflow", "token_count": 143 }
45
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- # flake8: noqa from .flow_executor import FlowExecutor from .flow_validator import FlowValidator
promptflow/src/promptflow/promptflow/executor/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/executor/__init__.py", "repo_id": "promptflow", "token_count": 54 }
46
import os import pytest from promptflow.executor import FlowExecutor from ..utils import get_flow_folder, get_yaml_file @pytest.mark.e2etest class TestAsync: @pytest.mark.parametrize( "folder_name, concurrency_levels, expected_concurrency", [ ("async_tools", [1, 2, 3], [1, 2, 2]), ...
promptflow/src/promptflow/tests/executor/e2etests/test_async.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/e2etests/test_async.py", "repo_id": "promptflow", "token_count": 809 }
47
from jinja2 import Template from promptflow import ToolProvider, tool from promptflow.connections import AzureOpenAIConnection from promptflow.contracts.types import PromptTemplate class TestCustomLLMTool(ToolProvider): def __init__(self, connection: AzureOpenAIConnection): super().__init__() sel...
promptflow/src/promptflow/tests/executor/package_tools/custom_llm_tool.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/package_tools/custom_llm_tool.py", "repo_id": "promptflow", "token_count": 257 }
48
import pytest from promptflow._utils.execution_utils import apply_default_value_for_input from promptflow.contracts.flow import FlowInputDefinition from promptflow.contracts.tool import ValueType @pytest.mark.unittest class TestFlowExecutor: @pytest.mark.parametrize( "flow_inputs, inputs, expected_inputs...
promptflow/src/promptflow/tests/executor/unittests/_utils/test_execution_utils.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/_utils/test_execution_utils.py", "repo_id": "promptflow", "token_count": 1270 }
49
from pathlib import Path import pytest from promptflow._sdk.entities._connection import AzureContentSafetyConnection from promptflow.contracts._errors import FailedToImportModule from promptflow.contracts.flow import ( Flow, FlowInputAssignment, FlowInputDefinition, FlowOutputDefinition, InputAssi...
promptflow/src/promptflow/tests/executor/unittests/contracts/test_flow.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/contracts/test_flow.py", "repo_id": "promptflow", "token_count": 15418 }
50
import re import sys from pathlib import Path from typing import List from unittest.mock import mock_open import pytest from jinja2 import TemplateSyntaxError from promptflow._core._errors import InvalidSource from promptflow._core.tools_manager import ToolLoader from promptflow._internal import tool from promptflow....
promptflow/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py", "repo_id": "promptflow", "token_count": 10851 }
51
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import contextlib import os import sys import uuid from typing import Callable import pytest from mock.mock import patch from promptflow._...
promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_cli_with_azure.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_cli_with_azure.py", "repo_id": "promptflow", "token_count": 3368 }
52
import contextlib import os import sys from pathlib import Path from typing import List from unittest.mock import MagicMock, patch import pandas as pd import pytest from pytest_mock import MockFixture from promptflow._sdk._constants import VIS_PORTAL_URL_TMPL tests_root_dir = Path(__file__).parent.parent.parent flow...
promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_cli.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_cli.py", "repo_id": "promptflow", "token_count": 5953 }
53
ENVIRON_TEST_MODE = "PROMPT_FLOW_TEST_MODE" class RecordMode: LIVE = "live" RECORD = "record" REPLAY = "replay"
promptflow/src/promptflow/tests/sdk_cli_test/recording_utilities/constants.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/recording_utilities/constants.py", "repo_id": "promptflow", "token_count": 60 }
54
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import importlib.util from pathlib import Path import pytest TOOL_DIR = Path("./tests/test_configs/tools") @pytest.mark.unittest class T...
promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_tool.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_tool.py", "repo_id": "promptflow", "token_count": 1585 }
55
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/AzureContentSafetyConnection.schema.json name: my_azure_content_safety_connection type: azure_content_safety # snake case api_key: "<to-be-replaced>" endpoint: "endpoint" api_version: "2023-04-30-preview" api_type: Content Safety
promptflow/src/promptflow/tests/test_configs/connections/azure_content_safety_connection.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/connections/azure_content_safety_connection.yaml", "repo_id": "promptflow", "token_count": 106 }
56
{"key": {"key": "value in data"}}
promptflow/src/promptflow/tests/test_configs/datas/dictInput1.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/datas/dictInput1.jsonl", "repo_id": "promptflow", "token_count": 13 }
57
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- def my_flow(): """Simple flow without yaml.""" print("Hello world!")
promptflow/src/promptflow/tests/test_configs/eager_flows/flow_with_environment/entry.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/flow_with_environment/entry.py", "repo_id": "promptflow", "token_count": 52 }
58
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- def my_flow(input_val: str = "gpt") -> str: """Simple flow without yaml.""" return f"Hello world! {input_val}"
promptflow/src/promptflow/tests/test_configs/eager_flows/simple_with_yaml/entry.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/simple_with_yaml/entry.py", "repo_id": "promptflow", "token_count": 70 }
59