text
stringlengths
8
1.72M
id
stringlengths
22
143
metadata
dict
__index_level_0__
int64
0
104
from enum import Enum from typing import Union from openai import AzureOpenAI as AzureOpenAIClient, OpenAI as OpenAIClient from promptflow.tools.common import handle_openai_error, normalize_connection_config from promptflow.tools.exception import InvalidConnectionType # Avoid circular dependencies: Use import 'from p...
promptflow/src/promptflow-tools/promptflow/tools/embedding.py/0
{ "file_path": "promptflow/src/promptflow-tools/promptflow/tools/embedding.py", "repo_id": "promptflow", "token_count": 684 }
29
import os import re from io import open from typing import Any, List, Match, cast from setuptools import find_namespace_packages, setup PACKAGE_NAME = "promptflow-tools" PACKAGE_FOLDER_PATH = "promptflow" def parse_requirements(file_name: str) -> List[str]: with open(file_name) as f: return [ ...
promptflow/src/promptflow-tools/setup.py/0
{ "file_path": "promptflow/src/promptflow-tools/setup.py", "repo_id": "promptflow", "token_count": 854 }
30
import copy import os import pytest import re from azure.identity import DefaultAzureCredential from typing import List, Dict from promptflow.tools.exception import ( OpenModelLLMUserError, OpenModelLLMKeyValidationError ) from promptflow.tools.open_model_llm import ( OpenModelLLM, API, ContentForm...
promptflow/src/promptflow-tools/tests/test_open_model_llm.py/0
{ "file_path": "promptflow/src/promptflow-tools/tests/test_open_model_llm.py", "repo_id": "promptflow", "token_count": 11345 }
31
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import argparse from promptflow._sdk._constants import PROMPT_FLOW_DIR_NAME, PROMPT_FLOW_RUNS_DIR_NAME, CLIListOutputFormat, FlowType # T...
promptflow/src/promptflow/promptflow/_cli/_params.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/_params.py", "repo_id": "promptflow", "token_count": 4120 }
32
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from promptflow._cli._utils import get_client_for_cli from promptflow.azure import PFClient def _get_azure_pf_client(subscription_id, reso...
promptflow/src/promptflow/promptflow/_cli/_pf_azure/_utils.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/_pf_azure/_utils.py", "repo_id": "promptflow", "token_count": 165 }
33
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from typing import List from promptflow import log_metric, tool @tool def aggregate(processed_results: List[str]): """ This tool...
promptflow/src/promptflow/promptflow/_cli/data/evaluation_flow/aggregate.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/data/evaluation_flow/aggregate.py", "repo_id": "promptflow", "token_count": 212 }
34
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # ---------------------------------------------------------
promptflow/src/promptflow/promptflow/_core/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_core/__init__.py", "repo_id": "promptflow", "token_count": 23 }
35
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import functools import inspect import json import logging import uuid from collections.abc import Iterator from contextvars import Context...
promptflow/src/promptflow/promptflow/_core/tracer.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_core/tracer.py", "repo_id": "promptflow", "token_count": 3869 }
36
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import json import logging import mimetypes import os from pathlib import Path from typing import Dict from flask import Flask, g, jsonify...
promptflow/src/promptflow/promptflow/_sdk/_serving/app.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_serving/app.py", "repo_id": "promptflow", "token_count": 3515 }
37
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Local Server Test App</title> <style> html, body { height: 100%; width: 100%; box-sizing: border-box; padding: 0;...
promptflow/src/promptflow/promptflow/_sdk/_serving/static/index.html/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_serving/static/index.html", "repo_id": "promptflow", "token_count": 357 }
38
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- """ This file code has been vendored from azure-ai-ml repo. Please do not edit it, unless really necessary """ # region Diff-imports import...
promptflow/src/promptflow/promptflow/_sdk/_vendor/_asset_utils.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_vendor/_asset_utils.py", "repo_id": "promptflow", "token_count": 2954 }
39
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- # pylint: disable=protected-access import json import typing from marshmallow import Schema, ValidationError from promptflow._utils.logg...
promptflow/src/promptflow/promptflow/_sdk/entities/_validation/schema.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/entities/_validation/schema.py", "repo_id": "promptflow", "token_count": 2108 }
40
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from marshmallow import fields, validate from promptflow._sdk._constants import FlowType from promptflow._sdk.schemas._base import Patched...
promptflow/src/promptflow/promptflow/_sdk/schemas/_flow.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/schemas/_flow.py", "repo_id": "promptflow", "token_count": 667 }
41
import base64 import os import re import uuid from functools import partial from pathlib import Path from typing import Any, Callable, Dict from urllib.parse import urlparse import requests from promptflow._utils._errors import InvalidImageInput, LoadMultimediaDataError from promptflow.contracts.flow import FlowInput...
promptflow/src/promptflow/promptflow/_utils/multimedia_utils.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_utils/multimedia_utils.py", "repo_id": "promptflow", "token_count": 4333 }
42
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from os import PathLike from pathlib import Path from typing import IO, AnyStr, Optional, Union from ._utils import is_arm_id def load_fl...
promptflow/src/promptflow/promptflow/azure/_load_functions.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_load_functions.py", "repo_id": "promptflow", "token_count": 531 }
43
# 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/_connection_operations.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/aio/operations/_connection_operations.py", "repo_id": "promptflow", "token_count": 6949 }
44
# 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/_connection_operations.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/operations/_connection_operations.py", "repo_id": "promptflow", "token_count": 10177 }
45
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore from .gerneral import is_arm_id __all__ = ["is_arm_id"]
promptflow/src/promptflow/promptflow/azure/_utils/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_utils/__init__.py", "repo_id": "promptflow", "token_count": 80 }
46
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import json import socket import subprocess import uuid from pathlib import Path from typing import Any, Mapping, Optional from promptflow....
promptflow/src/promptflow/promptflow/batch/_csharp_executor_proxy.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/batch/_csharp_executor_proxy.py", "repo_id": "promptflow", "token_count": 1889 }
47
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import inspect import string import traceback from enum import Enum from functools import cached_property class ErrorCategory(str, Enum): ...
promptflow/src/promptflow/promptflow/exceptions.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/exceptions.py", "repo_id": "promptflow", "token_count": 4554 }
48
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import copy from json import JSONDecodeError from typing import Any, List, Mapping, Optional from promptflow._utils.logger_utils import lo...
promptflow/src/promptflow/promptflow/executor/flow_validator.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/executor/flow_validator.py", "repo_id": "promptflow", "token_count": 9197 }
49
from pathlib import Path from tempfile import mkdtemp from typing import Dict import pytest from promptflow._utils.logger_utils import LogContext from promptflow.batch._batch_engine import OUTPUT_FILE_NAME, BatchEngine from promptflow.batch._result import BatchResult from promptflow.contracts._errors import FlowDefin...
promptflow/src/promptflow/tests/executor/e2etests/test_activate.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/e2etests/test_activate.py", "repo_id": "promptflow", "token_count": 3116 }
50
import json from functools import partial from aiohttp import web from promptflow.exceptions import ValidationException def run_executor_server(port, has_error=False, init_error_file=None): app = web.Application() app.router.add_get("/health", _handle_health) handle_execution_with_customization = parti...
promptflow/src/promptflow/tests/executor/mock_execution_server.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/mock_execution_server.py", "repo_id": "promptflow", "token_count": 2534 }
51
import json import re from traceback import TracebackException import pytest from promptflow._core._errors import ToolExecutionError from promptflow._core.operation_context import OperationContext from promptflow._utils.exception_utils import ( ErrorResponse, ExceptionPresenter, JsonSerializedPromptflowEx...
promptflow/src/promptflow/tests/executor/unittests/_utils/test_exception_utils.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/_utils/test_exception_utils.py", "repo_id": "promptflow", "token_count": 13949 }
52
from typing import Any import pytest from promptflow._core._errors import NotSupported from promptflow.contracts.flow import InputAssignment from promptflow.executor._errors import ( InputNotFound, InputNotFoundFromAncestorNodeOutput, InvalidReferenceProperty, UnsupportedReference, ) from promptflow.e...
promptflow/src/promptflow/tests/executor/unittests/executor/test_input_assignment_parser.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/executor/test_input_assignment_parser.py", "repo_id": "promptflow", "token_count": 2719 }
53
import os import os.path import sys from pathlib import Path import pytest from promptflow._cli._pf.entry import main from ..recording_utilities import is_live FLOWS_DIR = "./tests/test_configs/flows" RUNS_DIR = "./tests/test_configs/runs" CONNECTIONS_DIR = "./tests/test_configs/connections" DATAS_DIR = "./tests/te...
promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_cli.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_cli.py", "repo_id": "promptflow", "token_count": 1213 }
54
import pytest from promptflow._cli._pf_azure.entry import get_parser_args from promptflow._cli._utils import _get_cli_activity_name def get_cli_activity_name(cmd): prog, args = get_parser_args(list(cmd)[1:]) return _get_cli_activity_name(cli=prog, args=args) @pytest.mark.unittest class TestAzureCliTimeCons...
promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_azure_cli_activity_name.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_azure_cli_activity_name.py", "repo_id": "promptflow", "token_count": 716 }
55
import base64 import json import multiprocessing import os from pathlib import Path from unittest.mock import patch import pytest from mock import mock from pytest_mock import MockerFixture from sqlalchemy import create_engine from promptflow import PFClient from promptflow._sdk._configuration import Configuration fr...
promptflow/src/promptflow/tests/sdk_cli_test/conftest.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/conftest.py", "repo_id": "promptflow", "token_count": 3670 }
56
from .constants import ENVIRON_TEST_MODE, RecordMode from .mock_tool import mock_tool, recording_array_extend, recording_array_reset from .record_storage import RecordFileMissingException, RecordItemMissingException, RecordStorage __all__ = [ "RecordStorage", "RecordMode", "ENVIRON_TEST_MODE", "RecordF...
promptflow/src/promptflow/tests/sdk_cli_test/recording_utilities/__init__.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/recording_utilities/__init__.py", "repo_id": "promptflow", "token_count": 156 }
57
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import copy import uuid from pathlib import Path from unittest.mock import patch import pytest from marshmallow import ValidationError fro...
promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_run.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_run.py", "repo_id": "promptflow", "token_count": 4503 }
58
aaa=bbb ccc=ddd
promptflow/src/promptflow/tests/test_configs/connections/.env/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/connections/.env", "repo_id": "promptflow", "token_count": 11 }
59
path: ./entry.py entry: my_flow environment: python_requirements_txt: requirements.txt
promptflow/src/promptflow/tests/test_configs/eager_flows/simple_with_req/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/simple_with_req/flow.dag.yaml", "repo_id": "promptflow", "token_count": 29 }
60
{ "text": "world" }
promptflow/src/promptflow/tests/test_configs/flows/activate_with_no_inputs/inputs.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/activate_with_no_inputs/inputs.json", "repo_id": "promptflow", "token_count": 13 }
61
# Stock EOD Price Analyzer This sample demonstrates how the PromptFlow Assistant tool help with time series data (stock EOD price) retrieval, plot and consolidation. Tools used in this flow: - `get_or_create_thread` tool, python tool, used to provide assistant thread information if absent - `add_message_and_run` tool...
promptflow/src/promptflow/tests/test_configs/flows/assistant-with-file/README.md/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/assistant-with-file/README.md", "repo_id": "promptflow", "token_count": 569 }
62
inputs: text: type: string outputs: output_prompt: type: string reference: ${echo_my_prompt.output} nodes: - inputs: text: ${inputs.text} name: hello_prompt type: prompt source: type: code path: hello.jinja2 - inputs: prompt: ${hello_prompt.output} deployment_name: gpt-35-turbo...
promptflow/src/promptflow/tests/test_configs/flows/basic-with-connection/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/basic-with-connection/flow.dag.yaml", "repo_id": "promptflow", "token_count": 206 }
63
import random import time from promptflow import tool @tool def get_temperature(city: str, unit: str = "c"): """Estimate the current temperature of a given city. :param city: city to get the estimated temperature for. :type city: str :param unit: the unit of the temperature, either 'c' for Celsius o...
promptflow/src/promptflow/tests/test_configs/flows/chat-with-assistant-no-file/get_temperature.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/chat-with-assistant-no-file/get_temperature.py", "repo_id": "promptflow", "token_count": 193 }
64
inputs: variant_id: type: string groundtruth: type: string description: Please specify the groundtruth column, which contains the true label to the outputs that your flow produces. prediction: type: string description: Please specify the prediction column, which contains the predicted ...
promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/flow.dag.yaml", "repo_id": "promptflow", "token_count": 384 }
65
from promptflow import tool @tool def extract_job_info(incident_content: str) -> str: print(f"Incident: {incident_content}") return "Execute job info extractor"
promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/job_info_extractor.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/job_info_extractor.py", "repo_id": "promptflow", "token_count": 59 }
66
{ "package": {}, "code": { "print_env.py": { "type": "python", "inputs": { "key": { "type": [ "string" ] } }, "function": "get_env_var" } } }
promptflow/src/promptflow/tests/test_configs/flows/custom_connection_flow/.promptflow/flow.tools.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/custom_connection_flow/.promptflow/flow.tools.json", "repo_id": "promptflow", "token_count": 144 }
67
from promptflow import tool from promptflow.contracts.multimedia import Image @tool def passthrough_list(image_list: list, image_dict: dict): assert all(isinstance(item, Image) for item in image_list) return image_list
promptflow/src/promptflow/tests/test_configs/flows/eval_flow_with_composite_image/passthrough_list.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/eval_flow_with_composite_image/passthrough_list.py", "repo_id": "promptflow", "token_count": 71 }
68
echo Hello Promptflow!
promptflow/src/promptflow/tests/test_configs/flows/export/linux/flow/setup.sh/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/export/linux/flow/setup.sh", "repo_id": "promptflow", "token_count": 6 }
69
inputs: text: type: string outputs: output: type: object reference: ${hello_node.output} nodes: - inputs: text: ${inputs.text} connection: basic_custom_connection name: hello_node type: python source: type: code path: hello.py node_variants: {}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_custom_connection/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_custom_connection/flow.dag.yaml", "repo_id": "promptflow", "token_count": 113 }
70
{{text}}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_non_english_input/hello.jinja2/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_non_english_input/hello.jinja2", "repo_id": "promptflow", "token_count": 3 }
71
import os import sys from promptflow import tool sys.path.append(f"{os.path.dirname(__file__)}/custom_lib") from custom_lib.foo import foo @tool def my_python_tool(input1: str) -> str: return foo(param=input1)
promptflow/src/promptflow/tests/test_configs/flows/flow_with_sys_inject/hello.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_sys_inject/hello.py", "repo_id": "promptflow", "token_count": 81 }
72
{# Prompt is a jinja2 template that generates prompt for LLM #} system: You are a bot can tell good jokes user: A joke about {{topic}} please
promptflow/src/promptflow/tests/test_configs/flows/llm_tool/joke.jinja2/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/llm_tool/joke.jinja2", "repo_id": "promptflow", "token_count": 46 }
73
outputs: nodes: - name: say_hello type: python source: type: code path: say_hello.py
promptflow/src/promptflow/tests/test_configs/flows/no_inputs_outputs/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/no_inputs_outputs/flow.dag.yaml", "repo_id": "promptflow", "token_count": 43 }
74
Please summarize the following content in one paragraph. 50 words. Do not add any information that is not in the content. Text: {{text}} Images: ![image]({{image1}}) ![ image]({{image2}}) ![image ]({{image3}}) ![ image ]({{image4}}) Video: ![video]({{video1}}) Summary:
promptflow/src/promptflow/tests/test_configs/flows/prompt_tools/summarize_text_content_prompt.jinja2/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/prompt_tools/summarize_text_content_prompt.jinja2", "repo_id": "promptflow", "token_count": 100 }
75
from promptflow import tool @tool def passthrough_list(image_list: list, image_dict: dict): return image_list
promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_composite_image/passthrough_list.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_composite_image/passthrough_list.py", "repo_id": "promptflow", "token_count": 38 }
76
inputs: image_1: type: image default: logo.jpg image_2: type: image outputs: output: type: image reference: ${python_node.output} nodes: - name: python_node type: python source: type: code path: pick_an_image.py inputs: image_1: ${inputs.image_1} image_2: ${inputs.image_2...
promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_simple_image_with_default/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_simple_image_with_default/flow.dag.yaml", "repo_id": "promptflow", "token_count": 143 }
77
inputs: text: type: string outputs: output_prompt: type: string reference: ${node1.output} nodes: - name: node1 type: python source: type: code path: script_with___file__.py inputs: input1: ${inputs.text} - name: node2 type: python source: type: code path: folder/another-to...
promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/flow.dag.yaml", "repo_id": "promptflow", "token_count": 201 }
78
from promptflow import tool def raise_exception(s): msg = f"In raise_exception: {s}" raise Exception(msg) @tool def raise_an_exception(s: str): try: raise_exception(s) except Exception as e: raise Exception(f"In tool raise_an_exception: {s}") from e
promptflow/src/promptflow/tests/test_configs/flows/sync_tools_failures/sync_fail.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/sync_tools_failures/sync_fail.py", "repo_id": "promptflow", "token_count": 117 }
79
[ { "url": "https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h" }, { "url": "https://www.microsoft.com/en-us/windows/" } ]
promptflow/src/promptflow/tests/test_configs/flows/web_classification/samples.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/web_classification/samples.json", "repo_id": "promptflow", "token_count": 86 }
80
[ { "line_number": 0, "variant_id": "variant_0", "groundtruth": "App", "prediction": "App" } ]
promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/samples.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/samples.json", "repo_id": "promptflow", "token_count": 72 }
81
interactions: - request: body: null headers: Accept: - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive User-Agent: - promptflow-sdk/0.0.1 promptflow/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/...
promptflow/src/promptflow/tests/test_configs/recordings/test_connection_operations_TestConnectionOperations_test_get_connection.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_connection_operations_TestConnectionOperations_test_get_connection.yaml", "repo_id": "promptflow", "token_count": 2853 }
82
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.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.11.5 (Windows-1...
promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_eager_flow_download.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_eager_flow_download.yaml", "repo_id": "promptflow", "token_count": 30319 }
83
interactions: - request: body: null headers: Accept: - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive User-Agent: - promptflow-sdk/0.0.1 promptflow/0.0.1 azure-ai-ml/1.12.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/...
promptflow/src/promptflow/tests/test_configs/recordings/test_telemetry_TestTelemetry_test_custom_event.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_telemetry_TestTelemetry_test_custom_event.yaml", "repo_id": "promptflow", "token_count": 2445 }
84
flow: ../flows/classification_accuracy_evaluation data: ../datas/webClassification1.jsonl column_mapping: groundtruth: "${data.answer}" prediction: "${run.outputs.category}" variant_id: "${data.variant_id}" run: flow_run_20230629_101205 # ./sample_bulk_run.yaml # run config: env related environment_variables: en...
promptflow/src/promptflow/tests/test_configs/runs/sample_eval_run.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/runs/sample_eval_run.yaml", "repo_id": "promptflow", "token_count": 116 }
85
import importlib from pathlib import Path from promptflow._core.tool import tool from promptflow.contracts.types import FilePath @tool(name="Tool with FilePath Input", description="This is a tool to demonstrate the usage of FilePath input") def my_tool(input_file: FilePath, input_text: str) -> str: # customise yo...
promptflow/src/promptflow/tests/test_configs/tools/tool_with_file_path_input.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/tools/tool_with_file_path_input.py", "repo_id": "promptflow", "token_count": 139 }
86
name: node_condition_conflict inputs: text: type: string outputs: result: type: string reference: ${test_node} nodes: - name: test_node type: python source: type: code path: test.py inputs: text: ${inputs.text} skip: when: ${inputs.text} is: true return: ${inputs.text} ...
promptflow/src/promptflow/tests/test_configs/wrong_flows/node_condition_conflict/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/wrong_flows/node_condition_conflict/flow.dag.yaml", "repo_id": "promptflow", "token_count": 159 }
87
inputs: num: type: int outputs: content: type: string reference: ${stringify_num.output} nodes: - name: stringify_num type: python source: type: code path: stringify_num.py inputs: num: ${inputs.num}
promptflow/src/promptflow/tests/test_configs/wrong_flows/source_file_missing/flow.dag.python.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/wrong_flows/source_file_missing/flow.dag.python.yaml", "repo_id": "promptflow", "token_count": 101 }
88
FROM python:3.9-slim-bullseye AS base RUN set -x RUN apt-get update \ && apt-get -y install curl \ && apt-get -y install net-tools \ && apt-get -y install procps \ && apt-get -y install build-essential \ && apt-get -y install docker.io RUN pip install ipython ipykernel RUN ipython kernel install ...
promptflow/.devcontainer/Dockerfile/0
{ "file_path": "promptflow/.devcontainer/Dockerfile", "repo_id": "promptflow", "token_count": 166 }
0
# Promptflow documentation contribute guidelines This folder contains the source code for [prompt flow documentation site](https://microsoft.github.io/promptflow/). This readme file will not be included in above doc site. It keeps a guide for promptflow documentation contributors. ## Content Below is a table of imp...
promptflow/docs/README.md/0
{ "file_path": "promptflow/docs/README.md", "repo_id": "promptflow", "token_count": 1034 }
1
# Promptflow Reference Documentation Guide ## Overview This guide describes how to author Python docstrings for promptflow public interfaces. See our doc site at [Promptflow API reference documentation](https://microsoft.github.io/promptflow/reference/python-library-reference/promptflow.html). ## Principles - **Cov...
promptflow/docs/dev/documentation_guidelines.md/0
{ "file_path": "promptflow/docs/dev/documentation_guidelines.md", "repo_id": "promptflow", "token_count": 2474 }
2
# Creating Cascading Tool Inputs Cascading input settings are useful when the value of one input field determines which subsequent inputs are shown. This makes the input process more streamlined, user-friendly, and error-free. This guide will walk through how to create cascading inputs for your tools. ## Prerequisite...
promptflow/docs/how-to-guides/develop-a-tool/create-cascading-tool-inputs.md/0
{ "file_path": "promptflow/docs/how-to-guides/develop-a-tool/create-cascading-tool-inputs.md", "repo_id": "promptflow", "token_count": 1955 }
3
# Use column mapping In this document, we will introduce how to map inputs with column mapping when running a flow. ## Column mapping introduction Column mapping is a mapping from flow input name to specified values. If specified, the flow will be executed with provided value for specified inputs. The following type...
promptflow/docs/how-to-guides/run-and-evaluate-a-flow/use-column-mapping.md/0
{ "file_path": "promptflow/docs/how-to-guides/run-and-evaluate-a-flow/use-column-mapping.md", "repo_id": "promptflow", "token_count": 654 }
4
# Faiss Index Lookup Faiss Index Lookup is a tool tailored for querying within a user-provided Faiss-based vector store. In combination with our Large Language Model (LLM) tool, it empowers users to extract contextually relevant information from a domain knowledge base. ## Requirements - For AzureML users, the tool i...
promptflow/docs/reference/tools-reference/faiss_index_lookup_tool.md/0
{ "file_path": "promptflow/docs/reference/tools-reference/faiss_index_lookup_tool.md", "repo_id": "promptflow", "token_count": 1307 }
5
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CognitiveSearchConnection.schema.json name: cognitive_search_connection type: cognitive_search api_key: "<to-be-replaced>" api_base: "endpoint" api_version: "2023-07-01-Preview"
promptflow/examples/connections/cognitive_search.yml/0
{ "file_path": "promptflow/examples/connections/cognitive_search.yml", "repo_id": "promptflow", "token_count": 86 }
6
system: You are an assistant to calculate the answer to the provided math problems. Please think step by step. Return the final numerical answer only and any accompanying reasoning or explanation seperately as json format. user: A jar contains two red marbles, three green marbles, ten white marbles and no other marble...
promptflow/examples/flows/chat/chat-math-variant/chat_variant_1.jinja2/0
{ "file_path": "promptflow/examples/flows/chat/chat-math-variant/chat_variant_1.jinja2", "repo_id": "promptflow", "token_count": 474 }
7
import contextlib import os import sys if sys.platform.startswith("win"): import msvcrt else: import fcntl @contextlib.contextmanager def acquire_lock(filename): if not sys.platform.startswith("win"): with open(filename, "a+") as f: fcntl.flock(f, fcntl.LOCK_EX) yield f ...
promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/utils/lock.py/0
{ "file_path": "promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/utils/lock.py", "repo_id": "promptflow", "token_count": 338 }
8
from promptflow import tool from chat_with_pdf.qna import qna @tool def qna_tool(prompt: str, history: list): stream = qna(prompt, convert_chat_history_to_chatml_messages(history)) answer = "" for str in stream: answer = answer + str + "" return {"answer": answer} def convert_chat_history_...
promptflow/examples/flows/chat/chat-with-pdf/qna_tool.py/0
{ "file_path": "promptflow/examples/flows/chat/chat-with-pdf/qna_tool.py", "repo_id": "promptflow", "token_count": 212 }
9
# Use Functions with Chat Models This flow covers how to use the LLM tool chat API in combination with external functions to extend the capabilities of GPT models. `functions` is an optional parameter in the <a href='https://platform.openai.com/docs/api-reference/chat/create' target='_blank'>Chat Completion API</a>...
promptflow/examples/flows/chat/use_functions_with_chat_models/README.md/0
{ "file_path": "promptflow/examples/flows/chat/use_functions_with_chat_models/README.md", "repo_id": "promptflow", "token_count": 1074 }
10
# Eval chat math This example shows how to evaluate the answer of math questions, which can compare the output results with the standard answers numerically. Learn more on corresponding [tutorials](../../../tutorials/flow-fine-tuning-evaluation/promptflow-quality-improvement.md) Tools used in this flow: - `python` t...
promptflow/examples/flows/evaluation/eval-chat-math/README.md/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-chat-math/README.md", "repo_id": "promptflow", "token_count": 272 }
11
import unittest from match import is_match class IsMatchTest(unittest.TestCase): def test_normal(self): self.assertEqual(is_match(["a", "b"], ["B", "a"], True, True, False), True) self.assertEqual(is_match(["a", "b"], ["B", "a"], True, False, False), False) self.assertEqual(is_match(["a",...
promptflow/examples/flows/evaluation/eval-entity-match-rate/is_match_test.py/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-entity-match-rate/is_match_test.py", "repo_id": "promptflow", "token_count": 269 }
12
from promptflow import tool import re @tool def parse_score(gpt_score: str): return float(extract_float(gpt_score)) def extract_float(s): match = re.search(r"[-+]?\d*\.\d+|\d+", s) if match: return float(match.group()) else: return None
promptflow/examples/flows/evaluation/eval-perceived-intelligence/parse_score.py/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-perceived-intelligence/parse_score.py", "repo_id": "promptflow", "token_count": 119 }
13
from promptflow import tool @tool def validate_input(question: str, answer: str, context: str, ground_truth: str, selected_metrics: dict) -> dict: input_data = {"question": question, "answer": answer, "context": context, "ground_truth": ground_truth} expected_input_cols = set(input_data.keys()) dict_metri...
promptflow/examples/flows/evaluation/eval-qna-non-rag/validate_input.py/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-qna-non-rag/validate_input.py", "repo_id": "promptflow", "token_count": 689 }
14
# Analyze Documents A flow that analyzes documents with various language-based Machine Learning models. This sample flow utilizes Azure AI Language's pre-built and optimized language models to perform various analyses on text or documents. It performs: - [Translation](https://learn.microsoft.com/en-us/rest/api/cogni...
promptflow/examples/flows/integrations/azure-ai-language/analyze_documents/README.md/0
{ "file_path": "promptflow/examples/flows/integrations/azure-ai-language/analyze_documents/README.md", "repo_id": "promptflow", "token_count": 1454 }
15
from promptflow.tools.aoai import chat as aoai_chat from promptflow.tools.openai import chat as openai_chat from promptflow.connections import AzureOpenAIConnection, OpenAIConnection from util import count_message_tokens, count_string_tokens, create_chat_message, generate_context, get_logger, \ parse_reply, constru...
promptflow/examples/flows/standard/autonomous-agent/autogpt_class.py/0
{ "file_path": "promptflow/examples/flows/standard/autonomous-agent/autogpt_class.py", "repo_id": "promptflow", "token_count": 3387 }
16
system: You are a assistant which can write code. Response should only contain code. user: Write a simple {{text}} program that displays the greeting message when executed.
promptflow/examples/flows/standard/basic-with-builtin-llm/hello.jinja2/0
{ "file_path": "promptflow/examples/flows/standard/basic-with-builtin-llm/hello.jinja2", "repo_id": "promptflow", "token_count": 38 }
17
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Run.schema.json flow: . data: data.jsonl environment_variables: # environment variables from connection AZURE_OPENAI_API_KEY: ${open_ai_connection.api_key} AZURE_OPENAI_API_BASE: ${open_ai_connection.api_base} AZURE_OPENAI_API_TYPE: azure column_ma...
promptflow/examples/flows/standard/basic/run.yml/0
{ "file_path": "promptflow/examples/flows/standard/basic/run.yml", "repo_id": "promptflow", "token_count": 135 }
18
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json inputs: query: type: string default: When will my order be shipped? outputs: response: type: string reference: ${generate_response.output} nodes: - name: classify_with_llm type: llm source: type: code path: ...
promptflow/examples/flows/standard/conditional-flow-for-switch/flow.dag.yaml/0
{ "file_path": "promptflow/examples/flows/standard/conditional-flow-for-switch/flow.dag.yaml", "repo_id": "promptflow", "token_count": 588 }
19
You are given a list of orders with item_numbers from a customer and a statement from the customer. It is your job to identify the intent that the customer has with their statement. Possible intents can be: "product return", "product exchange", "general question", "product question", "other". If the intent is product...
promptflow/examples/flows/standard/customer-intent-extraction/user_intent_few_shot.jinja2/0
{ "file_path": "promptflow/examples/flows/standard/customer-intent-extraction/user_intent_few_shot.jinja2", "repo_id": "promptflow", "token_count": 417 }
20
import os from pathlib import Path saved_path = os.getcwd() os.chdir(Path(__file__).parent) source_folder = Path("../web-classification") for file_name in os.listdir(source_folder): if not Path(file_name).exists(): os.symlink( source_folder / file_name, file_name ) os.chdi...
promptflow/examples/flows/standard/flow-with-symlinks/create_symlinks.py/0
{ "file_path": "promptflow/examples/flows/standard/flow-with-symlinks/create_symlinks.py", "repo_id": "promptflow", "token_count": 150 }
21
from promptflow import tool from file import File @tool def load_code(source: str): file = File(source) return file.content
promptflow/examples/flows/standard/gen-docstring/load_code_tool.py/0
{ "file_path": "promptflow/examples/flows/standard/gen-docstring/load_code_tool.py", "repo_id": "promptflow", "token_count": 43 }
22
system: Your task is to find entities of certain type from the given text content. If there're multiple entities, please return them all with comma separated, e.g. "entity1, entity2, entity3". You should only return the entity list, nothing else. If there's no such entity, please return "None". user: Entity type: {{en...
promptflow/examples/flows/standard/named-entity-recognition/NER_LLM.jinja2/0
{ "file_path": "promptflow/examples/flows/standard/named-entity-recognition/NER_LLM.jinja2", "repo_id": "promptflow", "token_count": 96 }
23
from jinja2 import Template from promptflow import tool from promptflow.connections import CustomConnection from promptflow.contracts.types import PromptTemplate @tool def my_tool(connection: CustomConnection, prompt: PromptTemplate, **kwargs) -> str: # Replace with your tool code, customise your own code to hand...
promptflow/examples/tools/tool-package-quickstart/my_tool_package/tools/tool_with_custom_llm_type.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/my_tool_package/tools/tool_with_custom_llm_type.py", "repo_id": "promptflow", "token_count": 171 }
24
import pytest import unittest from promptflow.connections import CustomConnection from my_tool_package.tools.my_tool_1 import my_tool @pytest.fixture def my_custom_connection() -> CustomConnection: my_custom_connection = CustomConnection( { "api-key" : "my-api-key", "api-secret" :...
promptflow/examples/tools/tool-package-quickstart/tests/test_my_tool_1.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/tests/test_my_tool_1.py", "repo_id": "promptflow", "token_count": 278 }
25
def hello(input_text: str) -> str: # Replace with your own code. return "Hello " + input_text
promptflow/examples/tools/use-cases/filepath-input-tool-showcase/hello_method.py/0
{ "file_path": "promptflow/examples/tools/use-cases/filepath-input-tool-showcase/hello_method.py", "repo_id": "promptflow", "token_count": 36 }
26
import os import sys from promptflow._cli._pf._connection import create_connection from streamlit.web import cli as st_cli from streamlit.runtime import exists from main import start def is_yaml_file(file_path): _, file_extension = os.path.splitext(file_path) return file_extension.lower() in ('.yaml', '.yml...
promptflow/examples/tutorials/flow-deploy/distribute-flow-as-executable-app/app.py/0
{ "file_path": "promptflow/examples/tutorials/flow-deploy/distribute-flow-as-executable-app/app.py", "repo_id": "promptflow", "token_count": 384 }
27
<jupyter_start><jupyter_text>Flow Run Management in Azure**Requirements** - In order to benefit from this tutorial, you will need:- An Azure account with an active subscription - [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F)- An Azure ML workspace - [Configure workspace](../../confi...
promptflow/examples/tutorials/run-management/cloud-run-management.ipynb/0
{ "file_path": "promptflow/examples/tutorials/run-management/cloud-run-management.ipynb", "repo_id": "promptflow", "token_count": 2407 }
28
@echo off setlocal set MAIN_EXE=%~dp0.\pfcli.exe "%MAIN_EXE%" pfazure %*
promptflow/scripts/installer/windows/scripts/pfazure.bat/0
{ "file_path": "promptflow/scripts/installer/windows/scripts/pfazure.bat", "repo_id": "promptflow", "token_count": 41 }
29
import subprocess from pathlib import Path import hashlib from jinja2 import Environment, FileSystemLoader, Template from .telemetry_obj import Telemetry class Step: """ StepType in workflow """ Environment = None @staticmethod def init_jinja_loader() -> Environment: jinja_folder_pat...
promptflow/scripts/readme/ghactions_driver/readme_step.py/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/readme_step.py", "repo_id": "promptflow", "token_count": 5810 }
30
{% extends "workflow_skeleton.yml.jinja2" %} {% block steps %} runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Setup Python 3.9 environment uses: actions/setup-python@v4 with: python-version: "3.9" {%- filter indent(width=2) -%} {% for step in steps %} {...
promptflow/scripts/readme/ghactions_driver/workflow_templates/basic_workflow_replace.yml.jinja2/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/workflow_templates/basic_workflow_replace.yml.jinja2", "repo_id": "promptflow", "token_count": 161 }
31
import argparse from utils.repo_utils import create_remote_branch_in_ADO_with_new_tool_pkg_version, deploy_test_endpoint if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--tool_pkg_version", type=str, required=True) parser.add_argument("--ado_pat", type=str, required=True...
promptflow/scripts/tool/deploy_endpoint.py/0
{ "file_path": "promptflow/scripts/tool/deploy_endpoint.py", "repo_id": "promptflow", "token_count": 219 }
32
import json try: from openai import AzureOpenAI as AzureOpenAIClient except Exception: raise Exception( "Please upgrade your OpenAI package to version 1.0.0 or later using the command: pip install --upgrade openai.") from promptflow.tools.common import render_jinja_template, handle_openai_error, parse...
promptflow/src/promptflow-tools/promptflow/tools/aoai.py/0
{ "file_path": "promptflow/src/promptflow-tools/promptflow/tools/aoai.py", "repo_id": "promptflow", "token_count": 3768 }
33
promptflow.tools.openai_gpt4v.OpenAI.chat: name: OpenAI GPT-4V description: Use OpenAI GPT-4V to leverage vision ability. type: custom_llm module: promptflow.tools.openai_gpt4v class_name: OpenAI function: chat tool_state: preview icon: light: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCA...
promptflow/src/promptflow-tools/promptflow/tools/yamls/openai_gpt4v.yaml/0
{ "file_path": "promptflow/src/promptflow-tools/promptflow/tools/yamls/openai_gpt4v.yaml", "repo_id": "promptflow", "token_count": 1040 }
34
# system: As an AI assistant, your task involves interpreting images and responding to questions about the image. Remember to provide accurate answers based on the information present in the image. Directly give the answer, no more explanation is needed. # user: {{question}} ![image]({{image_input}})
promptflow/src/promptflow-tools/tests/test_configs/prompt_templates/prompt_with_image.jinja2/0
{ "file_path": "promptflow/src/promptflow-tools/tests/test_configs/prompt_templates/prompt_with_image.jinja2", "repo_id": "promptflow", "token_count": 72 }
35
#!/usr/bin/env python import sys import os if os.environ.get('PF_INSTALLER') is None: os.environ['PF_INSTALLER'] = 'PIP' os.execl(sys.executable, sys.executable, '-m', 'promptflow._cli._pf.entry', *sys.argv[1:])
promptflow/src/promptflow/pf/0
{ "file_path": "promptflow/src/promptflow/pf", "repo_id": "promptflow", "token_count": 97 }
36
.env __pycache__/ .promptflow/* !.promptflow/flow.tools.json .runs/
promptflow/src/promptflow/promptflow/_cli/data/entry_flow/gitignore/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/data/entry_flow/gitignore", "repo_id": "promptflow", "token_count": 30 }
37
{# Please replace the template with your own prompt. #} Write a simple {{text}} program that displays the greeting message when executed.
promptflow/src/promptflow/promptflow/_cli/data/standard_flow/hello.jinja2/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/data/standard_flow/hello.jinja2", "repo_id": "promptflow", "token_count": 30 }
38
import threading from abc import ABC, abstractmethod from promptflow.exceptions import UserErrorException # to access azure ai services, we need to get the token with this audience COGNITIVE_AUDIENCE = "https://cognitiveservices.azure.com/" class TokenProviderABC(ABC): def __init__(self) -> None: super(...
promptflow/src/promptflow/promptflow/_core/token_provider.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_core/token_provider.py", "repo_id": "promptflow", "token_count": 629 }
39