text
stringlengths
8
1.72M
id
stringlengths
22
143
metadata
dict
__index_level_0__
int64
0
104
# Basic flow with custom connection A basic standard flow that using custom python tool calls Azure OpenAI with connection info stored in custom connection. Tools used in this flow: - `prompt` tool - custom `python` Tool Connections used in this flow: - None ## Prerequisites Install promptflow sdk and other depend...
promptflow/examples/flows/standard/basic-with-connection/README.md/0
{ "file_path": "promptflow/examples/flows/standard/basic-with-connection/README.md", "repo_id": "promptflow", "token_count": 983 }
15
from promptflow import tool import random @tool def content_safety_check(text: str) -> str: # You can use a content safety node to replace this tool. return random.choice([True, False])
promptflow/examples/flows/standard/conditional-flow-for-if-else/content_safety_check.py/0
{ "file_path": "promptflow/examples/flows/standard/conditional-flow-for-if-else/content_safety_check.py", "repo_id": "promptflow", "token_count": 58 }
16
from promptflow import tool @tool def order_search(query: str) -> str: print(f"Your query is {query}.\nSearching for order...") return "Your order is being mailed, please wait patiently."
promptflow/examples/flows/standard/conditional-flow-for-switch/order_search.py/0
{ "file_path": "promptflow/examples/flows/standard/conditional-flow-for-switch/order_search.py", "repo_id": "promptflow", "token_count": 61 }
17
# Describe image flow A flow that take image input, flip it horizontally and uses OpenAI GPT-4V tool to describe it. Tools used in this flow: - `OpenAI GPT-4V` tool - custom `python` Tool Connections used in this flow: - OpenAI Connection ## Prerequisites Install promptflow sdk and other dependencies, create connec...
promptflow/examples/flows/standard/describe-image/README.md/0
{ "file_path": "promptflow/examples/flows/standard/describe-image/README.md", "repo_id": "promptflow", "token_count": 608 }
18
import sys from promptflow.tools.common import render_jinja_template from divider import Divider class PromptLimitException(Exception): def __init__(self, message="", **kwargs): super().__init__(message, **kwargs) self._message = str(message) self._kwargs = kwargs self._inner_excep...
promptflow/examples/flows/standard/gen-docstring/prompt.py/0
{ "file_path": "promptflow/examples/flows/standard/gen-docstring/prompt.py", "repo_id": "promptflow", "token_count": 518 }
19
from typing import List from promptflow import tool @tool def cleansing(entities_str: str) -> List[str]: # Split, remove leading and trailing spaces/tabs/dots parts = entities_str.split(",") cleaned_parts = [part.strip(" \t.\"") for part in parts] entities = [part for part in cleaned_parts if len(part...
promptflow/examples/flows/standard/named-entity-recognition/cleansing.py/0
{ "file_path": "promptflow/examples/flows/standard/named-entity-recognition/cleansing.py", "repo_id": "promptflow", "token_count": 114 }
20
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Run.schema.json flow: ../../evaluation/eval-classification-accuracy data: data.jsonl run: web_classification_variant_1_20230724_173442_973403 # replace with your run name column_mapping: groundtruth: ${data.answer} prediction: ${run.outputs.category}
promptflow/examples/flows/standard/web-classification/run_evaluation.yml/0
{ "file_path": "promptflow/examples/flows/standard/web-classification/run_evaluation.yml", "repo_id": "promptflow", "token_count": 111 }
21
from promptflow import tool from typing import List, Union, Dict def my_list_func(prefix: str = "", size: int = 10, **kwargs) -> List[Dict[str, Union[str, int, float, list, Dict]]]: """This is a dummy function to generate a list of items. :param prefix: prefix to add to each item. :param size: number of ...
promptflow/examples/tools/tool-package-quickstart/my_tool_package/tools/tool_with_dynamic_list_input.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/my_tool_package/tools/tool_with_dynamic_list_input.py", "repo_id": "promptflow", "token_count": 1111 }
22
from my_tool_package.tools.tool_with_cascading_inputs import my_tool def test_my_tool(): result = my_tool(user_type="student", student_id="student_id") assert result == '123'
promptflow/examples/tools/tool-package-quickstart/tests/test_tool_with_cascading_inputs.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/tests/test_tool_with_cascading_inputs.py", "repo_id": "promptflow", "token_count": 67 }
23
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CustomConnection.schema.json name: normal_custom_connection type: custom configs: api_base: test secrets: # must-have api_key: <to-be-replaced>
promptflow/examples/tools/use-cases/custom-strong-type-connection-script-tool-showcase/custom.yml/0
{ "file_path": "promptflow/examples/tools/use-cases/custom-strong-type-connection-script-tool-showcase/custom.yml", "repo_id": "promptflow", "token_count": 79 }
24
--- resources: examples/connections/azure_openai.yml, examples/flows/chat/chat-with-pdf --- # Tutorial: Chat with PDF ## Overview Retrieval Augmented Generation (or RAG) has become a prevalent pattern to build intelligent application with Large Language Models (or LLMs) since it can infuse external knowledge into the...
promptflow/examples/tutorials/e2e-development/chat-with-pdf.md/0
{ "file_path": "promptflow/examples/tutorials/e2e-development/chat-with-pdf.md", "repo_id": "promptflow", "token_count": 6861 }
25
import base64 import json import os import re import streamlit as st from pathlib import Path from streamlit_quill import st_quill # noqa: F401 from bs4 import BeautifulSoup, NavigableString, Tag from promptflow._sdk._utils import print_yellow_warning from promptflow._sdk._serving.flow_invoker import FlowInvoker from...
promptflow/examples/tutorials/flow-deploy/distribute-flow-as-executable-app/main.py/0
{ "file_path": "promptflow/examples/tutorials/flow-deploy/distribute-flow-as-executable-app/main.py", "repo_id": "promptflow", "token_count": 4079 }
26
import argparse from pathlib import Path from platform import system from utils import print_blue, run_command def setup_promptflow(extra_deps: list, command_args: dict) -> None: print_blue("- Setting up the promptflow SDK ") print_blue("- Installing promptflow Python SDK from local directory") package_l...
promptflow/scripts/building/dev_setup.py/0
{ "file_path": "promptflow/scripts/building/dev_setup.py", "repo_id": "promptflow", "token_count": 646 }
27
<# .DESCRIPTION Script to build doc site .EXAMPLE PS> ./doc_generation.ps1 -SkipInstall # skip pip install PS> ./doc_generation.ps1 -BuildLinkCheck -WarningAsError:$true -SkipInstall #> [CmdletBinding()] param( [switch]$SkipInstall, [switch]$WarningAsError = $false, [switch]$BuildLinkCheck = $false, ...
promptflow/scripts/docs/doc_generation.ps1/0
{ "file_path": "promptflow/scripts/docs/doc_generation.ps1", "repo_id": "promptflow", "token_count": 1687 }
28
@echo off setlocal set MAIN_EXE=%~dp0.\pfcli.exe "%MAIN_EXE%" pfs %*
promptflow/scripts/installer/windows/scripts/pfs.bat/0
{ "file_path": "promptflow/scripts/installer/windows/scripts/pfs.bat", "repo_id": "promptflow", "token_count": 39 }
29
from pathlib import Path from .readme_step import ReadmeStepsManage, ReadmeSteps from ghactions_driver.telemetry_obj import Telemetry def write_readme_workflow(readme_path, output_telemetry=Telemetry()): relative_path = Path(readme_path).relative_to( Path(ReadmeStepsManage.git_base_dir()) ) workf...
promptflow/scripts/readme/ghactions_driver/readme_workflow_generate.py/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/readme_workflow_generate.py", "repo_id": "promptflow", "token_count": 1043 }
30
class SecretNameAlreadyExistsException(Exception): pass class SecretNameInvalidException(Exception): pass class SecretNoSetPermissionException(Exception): pass
promptflow/scripts/tool/exceptions/secret_exceptions.py/0
{ "file_path": "promptflow/scripts/tool/exceptions/secret_exceptions.py", "repo_id": "promptflow", "token_count": 48 }
31
storage: storage_account: promptflowgall5817910653 deployment: subscription_id: 96aede12-2f73-41cb-b983-6d11a904839b resource_group: promptflow workspace_name: promptflow-gallery endpoint_name: tool-test638236049123389546 deployment_name: blue mt_service_endpoint: https://eastus2euap.api.azureml.ms
promptflow/scripts/tool/utils/configs/promptflow-gallery-tool-test.yaml/0
{ "file_path": "promptflow/scripts/tool/utils/configs/promptflow-gallery-tool-test.yaml", "repo_id": "promptflow", "token_count": 117 }
32
from enum import Enum from typing import Dict, List, Union import json import requests from promptflow import tool, ToolProvider from promptflow.connections import AzureContentSafetyConnection from promptflow.tools.exception import AzureContentSafetyInputValueError, AzureContentSafetySystemError class TextCategorySe...
promptflow/src/promptflow-tools/promptflow/tools/azure_content_safety.py/0
{ "file_path": "promptflow/src/promptflow-tools/promptflow/tools/azure_content_safety.py", "repo_id": "promptflow", "token_count": 4937 }
33
import pytest from promptflow.tools.embedding import embedding from promptflow.tools.exception import InvalidConnectionType @pytest.mark.usefixtures("use_secrets_config_file") class TestEmbedding: def test_embedding_conn_aoai(self, azure_open_ai_connection): result = embedding( connection=azu...
promptflow/src/promptflow-tools/tests/test_embedding.py/0
{ "file_path": "promptflow/src/promptflow-tools/tests/test_embedding.py", "repo_id": "promptflow", "token_count": 465 }
34
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore from promptflow._core.metric_logger import log_metric # f...
promptflow/src/promptflow/promptflow/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/__init__.py", "repo_id": "promptflow", "token_count": 214 }
35
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import argparse import json from typing import Dict, List from promptflow._cli._params import ( add_param_archived_only, add_param_...
promptflow/src/promptflow/promptflow/_cli/_pf_azure/_flow.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/_pf_azure/_flow.py", "repo_id": "promptflow", "token_count": 2954 }
36
import os from promptflow import tool from promptflow.connections import CustomConnection {{ function_import }} @tool def {{ tool_function }}( {% for arg in tool_arg_list %} {{ arg.name }}, {% endfor %} connection: CustomConnection) -> str: # set environment variables for key, value in dict(connect...
promptflow/src/promptflow/promptflow/_cli/data/entry_flow/tool.py.jinja2/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/data/entry_flow/tool.py.jinja2", "repo_id": "promptflow", "token_count": 192 }
37
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from promptflow._cli._pf.entry import main # this is a compatibility layer for the old CLI which is used for vscode extension if __name__ ...
promptflow/src/promptflow/promptflow/_cli/pf.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/pf.py", "repo_id": "promptflow", "token_count": 74 }
38
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- """ This file can generate a meta file for the given prompt template or a python file. """ import importlib.util import inspect import json...
promptflow/src/promptflow/promptflow/_core/tool_meta_generator.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_core/tool_meta_generator.py", "repo_id": "promptflow", "token_count": 5685 }
39
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import os from os import PathLike from pathlib import Path from typing import Any, Dict, List, Union from .._utils.logger_utils import get_...
promptflow/src/promptflow/promptflow/_sdk/_pf_client.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_pf_client.py", "repo_id": "promptflow", "token_count": 4260 }
40
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from promptflow._sdk._serving.utils import get_cost_up_to_now from promptflow._sdk._serving.monitor.metrics import ResponseType class Str...
promptflow/src/promptflow/promptflow/_sdk/_serving/monitor/streaming_monitor.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_serving/monitor/streaming_monitor.py", "repo_id": "promptflow", "token_count": 1046 }
41
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import collections import hashlib import json import multiprocessing import os import platform import re import shutil import stat import sy...
promptflow/src/promptflow/promptflow/_sdk/_utils.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_utils.py", "repo_id": "promptflow", "token_count": 16979 }
42
Exported entry file & its dependencies are located in the same folder. The structure is as below: - flow: the folder contains all the flow files - connections: the folder contains yaml files to create all related connections - app.py: the entry file is included as the entry point for the bundled application. - app.spec...
promptflow/src/promptflow/promptflow/_sdk/data/executable/README.md/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/data/executable/README.md", "repo_id": "promptflow", "token_count": 223 }
43
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from .core import MutableValidationResult, ValidationResult, ValidationResultBuilder from .schema import SchemaValidatableMixin __all__ =...
promptflow/src/promptflow/promptflow/_sdk/entities/_validation/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/entities/_validation/__init__.py", "repo_id": "promptflow", "token_count": 106 }
44
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from marshmallow import fields, post_load, pre_load from promptflow._sdk._constants import ExperimentNodeType from promptflow._sdk.schemas....
promptflow/src/promptflow/promptflow/_sdk/schemas/_experiment.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/schemas/_experiment.py", "repo_id": "promptflow", "token_count": 1863 }
45
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- # This file is for open source, # so it should not contain any dependency on azure or azureml-related packages. import json import loggin...
promptflow/src/promptflow/promptflow/_utils/logger_utils.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_utils/logger_utils.py", "repo_id": "promptflow", "token_count": 5614 }
46
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import copy import os.path from contextlib import contextmanager from os import PathLike from pathlib import Path from typing import Dict, L...
promptflow/src/promptflow/promptflow/azure/_entities/_flow.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_entities/_flow.py", "repo_id": "promptflow", "token_count": 3918 }
47
# 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/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/aio/operations/__init__.py", "repo_id": "promptflow", "token_count": 348 }
48
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import asyncio import signal import threading import uuid from datetime import datetime from pathlib import Path from typing import Any, Di...
promptflow/src/promptflow/promptflow/batch/_batch_engine.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/batch/_batch_engine.py", "repo_id": "promptflow", "token_count": 8341 }
49
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from dataclasses import dataclass class Secret(str): """This class is used to hint a parameter is a secret to load.""" def set_s...
promptflow/src/promptflow/promptflow/contracts/types.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/contracts/types.py", "repo_id": "promptflow", "token_count": 527 }
50
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import copy import inspect import types from dataclasses import dataclass from functools import partial from pathlib import Path from typin...
promptflow/src/promptflow/promptflow/executor/_tool_resolver.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/executor/_tool_resolver.py", "repo_id": "promptflow", "token_count": 8974 }
51
import json import uuid from collections import namedtuple from importlib.metadata import version from pathlib import Path from tempfile import mkdtemp from unittest.mock import patch import pytest from promptflow._core.operation_context import OperationContext from promptflow.batch._batch_engine import OUTPUT_FILE_N...
promptflow/src/promptflow/tests/executor/e2etests/test_telemetry.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/e2etests/test_telemetry.py", "repo_id": "promptflow", "token_count": 1802 }
52
inputs: {} outputs: {} nodes: - name: tool_with_init_error type: python source: type: package tool: tool_with_init_error inputs: name: test_name
promptflow/src/promptflow/tests/executor/package_tools/tool_with_init_error/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/executor/package_tools/tool_with_init_error/flow.dag.yaml", "repo_id": "promptflow", "token_count": 67 }
53
import pytest from promptflow._utils.credential_scrubber import CredentialScrubber def mock_connection_string(): connection_str_before_key = "DefaultEndpointsProtocol=https;AccountName=accountName;" connection_str_after_key = "EndpointSuffix=core.windows.net" return ( f"{connection_str_before_key...
promptflow/src/promptflow/tests/executor/unittests/_utils/test_credential_scrubber.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/_utils/test_credential_scrubber.py", "repo_id": "promptflow", "token_count": 1079 }
54
import json import socket import subprocess from pathlib import Path from tempfile import mkdtemp from unittest.mock import MagicMock, patch import pytest from promptflow._core._errors import MetaFileNotFound, MetaFileReadError from promptflow._sdk._constants import FLOW_TOOLS_JSON, PROMPT_FLOW_DIR_NAME from promptfl...
promptflow/src/promptflow/tests/executor/unittests/batch/test_csharp_executor_proxy.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/batch/test_csharp_executor_proxy.py", "repo_id": "promptflow", "token_count": 2125 }
55
from concurrent.futures import Future from typing import Callable from unittest.mock import MagicMock import pytest from promptflow._core.flow_execution_context import FlowExecutionContext from promptflow.contracts.flow import Node from promptflow.executor._dag_manager import DAGManager from promptflow.executor._flow...
promptflow/src/promptflow/tests/executor/unittests/executor/test_flow_nodes_scheduler.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/executor/test_flow_nodes_scheduler.py", "repo_id": "promptflow", "token_count": 2450 }
56
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import pytest from .._azure_utils import DEFAULT_TEST_TIMEOUT, PYTEST_TIMEOUT_METHOD @pytest.fixture def connection_ops(pf): return ...
promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_arm_connection_operations.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_arm_connection_operations.py", "repo_id": "promptflow", "token_count": 530 }
57
[run] source = */promptflow/_cli/* */promptflow/_sdk/* */promptflow/azure/* omit = */promptflow/azure/_restclient/* *__init__.py*
promptflow/src/promptflow/tests/sdk_cli_test/.coveragerc/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/.coveragerc", "repo_id": "promptflow", "token_count": 72 }
58
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import datetime import json import uuid import pytest from promptflow._sdk._constants import ListViewType, RunStatus, RunTypes from promp...
promptflow/src/promptflow/tests/sdk_cli_test/e2etests/test_orm.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/e2etests/test_orm.py", "repo_id": "promptflow", "token_count": 2077 }
59
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import uuid import pytest from sqlalchemy import TEXT, Column, create_engine, inspect, text from sqlalchemy.orm import declarative_base, s...
promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_orm.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_orm.py", "repo_id": "promptflow", "token_count": 3383 }
60
{ "subscription_id": "sub1", "resource_group": "rg1", "workspace_name": "ws1" }
promptflow/src/promptflow/tests/test_configs/configs/mock_flow1/.azureml/config.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/configs/mock_flow1/.azureml/config.json", "repo_id": "promptflow", "token_count": 44 }
61
name: my_custom_strong_type_connection type: custom custom_type: MyFirstConnection module: my_tool_package.connections package: test-custom-tools package_version: 0.0.2 configs: api_base: "new_value" secrets: # must-have api_key: "******"
promptflow/src/promptflow/tests/test_configs/connections/update_custom_strong_type_connection.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/connections/update_custom_strong_type_connection.yaml", "repo_id": "promptflow", "token_count": 86 }
62
from dataclasses import dataclass @dataclass class Data: text: str models: list def my_flow(text: str = "default_text", models: list = ["default_model"]): return Data(text=text, models=models)
promptflow/src/promptflow/tests/test_configs/eager_flows/flow_with_dataclass_output/entry.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/flow_with_dataclass_output/entry.py", "repo_id": "promptflow", "token_count": 74 }
63
path: ./entry.py entry: my_flow
promptflow/src/promptflow/tests/test_configs/eager_flows/primitive_output/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/primitive_output/flow.dag.yaml", "repo_id": "promptflow", "token_count": 12 }
64
[ { "expected_node_count": 2, "expected_outputs":{ "text": "hello world" }, "expected_bypassed_nodes":[] } ]
promptflow/src/promptflow/tests/test_configs/flows/activate_with_no_inputs/expected_result.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/activate_with_no_inputs/expected_result.json", "repo_id": "promptflow", "token_count": 92 }
65
{ "text": "bypass" }
promptflow/src/promptflow/tests/test_configs/flows/all_nodes_bypassed/inputs.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/all_nodes_bypassed/inputs.json", "repo_id": "promptflow", "token_count": 14 }
66
from promptflow import tool import time @tool def passthrough_str_and_wait_sync(input1: str, wait_seconds=3) -> str: assert isinstance(input1, str), f"input1 should be a string, got {input1}" print(f"Wait for {wait_seconds} seconds in sync function") for i in range(wait_seconds): print(i) ...
promptflow/src/promptflow/tests/test_configs/flows/async_tools_with_sync_tools/sync_passthrough.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/async_tools_with_sync_tools/sync_passthrough.py", "repo_id": "promptflow", "token_count": 134 }
67
import random import time from promptflow import tool @tool def get_current_city(): """Get current city.""" # Generating a random number between 0.2 and 1 for tracing purpose time.sleep(random.uniform(0.2, 1)) return random.choice(["Beijing", "Shanghai"])
promptflow/src/promptflow/tests/test_configs/flows/chat-with-assistant-no-file/get_current_city.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/chat-with-assistant-no-file/get_current_city.py", "repo_id": "promptflow", "token_count": 92 }
68
{"accuracy": 0.67}
promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/expected_metrics.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/expected_metrics.json", "repo_id": "promptflow", "token_count": 8 }
69
from promptflow import tool @tool def choose_investigation_method(method1="Skip job info extractor", method2="Skip incident info extractor"): method = {} if method1: method["first"] = method1 if method2: method["second"] = method2 return method
promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/investigation_method.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/investigation_method.py", "repo_id": "promptflow", "token_count": 97 }
70
language: csharp inputs: question: type: string default: what is promptflow? outputs: answer: type: string reference: ${get_answer.output} nodes: - name: get_answer type: csharp source: type: package tool: (Basic)Basic.Flow.HelloWorld inputs: question: ${inputs.question}
promptflow/src/promptflow/tests/test_configs/flows/csharp_flow/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/csharp_flow/flow.dag.yaml", "repo_id": "promptflow", "token_count": 118 }
71
import os import pip def extract_intent(chat_prompt: str): from langchain.chat_models import AzureChatOpenAI from langchain.schema import HumanMessage if "AZURE_OPENAI_API_KEY" not in os.environ: # load environment variables from .env file try: from dotenv import load_dotenv ...
promptflow/src/promptflow/tests/test_configs/flows/export/linux/flow/intent.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/export/linux/flow/intent.py", "repo_id": "promptflow", "token_count": 1014 }
72
import os from promptflow import tool @tool def get_env_var(key: str): print(os.environ.get(key)) # get from env var return {"value": os.environ.get(key)}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_environment_variables/print_env.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_environment_variables/print_env.py", "repo_id": "promptflow", "token_count": 67 }
73
{"text": "Hello 123 日本語"} {"text": "World 123 日本語"}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_non_english_input/data.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_non_english_input/data.jsonl", "repo_id": "promptflow", "token_count": 30 }
74
def foo(param: str) -> str: return f"{param} from func foo"
promptflow/src/promptflow/tests/test_configs/flows/flow_with_sys_inject/custom_lib/foo.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_sys_inject/custom_lib/foo.py", "repo_id": "promptflow", "token_count": 25 }
75
from promptflow import tool @tool def echo(input: str) -> str: return input
promptflow/src/promptflow/tests/test_configs/flows/llm_tool/echo.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/llm_tool/echo.py", "repo_id": "promptflow", "token_count": 27 }
76
inputs: number: type: int outputs: output: type: int reference: ${mod_two.output.value} nodes: - name: mod_two type: python source: type: code path: mod_two.py inputs: number: ${inputs.number}
promptflow/src/promptflow/tests/test_configs/flows/mod-n/two/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/mod-n/two/flow.dag.yaml", "repo_id": "promptflow", "token_count": 99 }
77
{"prompt": "What is the capital of the United States of America?", "stream": true} {"prompt": "What is the capital of the United States of America?", "stream": false}
promptflow/src/promptflow/tests/test_configs/flows/openai_completion_api_flow/inputs.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/openai_completion_api_flow/inputs.jsonl", "repo_id": "promptflow", "token_count": 44 }
78
inputs: text: type: string outputs: output_prompt: type: string reference: ${summarize_text_content_prompt.output} nodes: - name: summarize_text_content_prompt type: prompt source: type: code path: summarize_text_content_prompt.jinja2 inputs: text: ${inputs.text}
promptflow/src/promptflow/tests/test_configs/flows/prompt_tools/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/prompt_tools/flow.dag.yaml", "repo_id": "promptflow", "token_count": 118 }
79
from promptflow import ToolProvider, tool class ScriptToolWithInit(ToolProvider): def __init__(self, init_input: str): super().__init__() self.init_input = init_input @tool def call(self, input: str): return str.join(" ", [self.init_input, input])
promptflow/src/promptflow/tests/test_configs/flows/script_tool_with_init/script_tool_with_init.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/script_tool_with_init/script_tool_with_init.py", "repo_id": "promptflow", "token_count": 110 }
80
from promptflow import tool @tool def passthrough(input: str): return input
promptflow/src/promptflow/tests/test_configs/flows/simple_aggregation/passthrough.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/simple_aggregation/passthrough.py", "repo_id": "promptflow", "token_count": 25 }
81
from promptflow import tool @tool def hello_world(name: str) -> str: return f"Hello World {name}!"
promptflow/src/promptflow/tests/test_configs/flows/simple_hello_world/hello_world.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/simple_hello_world/hello_world.py", "repo_id": "promptflow", "token_count": 36 }
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_cancel.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_eager_flow_cancel.yaml", "repo_id": "promptflow", "token_count": 11893 }
83
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_run_bulk_with_registry_flow.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_run_bulk_with_registry_flow.yaml", "repo_id": "promptflow", "token_count": 8027 }
84
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_run_operations_TestFlowRun_test_tools_json_ignored.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_tools_json_ignored.yaml", "repo_id": "promptflow", "token_count": 6859 }
85
name: flow_run_20230629_101205 flow: ../flows/web_classification data: ../datas/webClassification1.jsonl column_mapping: url: "${data.url}" variant: ${summarize_text_content.variant_0} # run config: env related environment_variables: env_file
promptflow/src/promptflow/tests/test_configs/runs/sample_bulk_run_cloud.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/runs/sample_bulk_run_cloud.yaml", "repo_id": "promptflow", "token_count": 91 }
86
from promptflow import tool @tool def divide_num(num: int) -> int: return (int)(num / 2)
promptflow/src/promptflow/tests/test_configs/wrong_flows/node_circular_dependency/divide_num.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/wrong_flows/node_circular_dependency/divide_num.py", "repo_id": "promptflow", "token_count": 35 }
87
{% for val in values %} {{val}}
promptflow/src/promptflow/tests/test_configs/wrong_tools/no_end.jinja2/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/wrong_tools/no_end.jinja2", "repo_id": "promptflow", "token_count": 12 }
88
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK --> ## Security Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), ...
promptflow/SECURITY.md/0
{ "file_path": "promptflow/SECURITY.md", "repo_id": "promptflow", "token_count": 674 }
0
# Concepts In this section, you will learn the basic concepts of prompt flow. ```{toctree} :maxdepth: 1 concept-flows concept-tools concept-connections concept-variants design-principles ```
promptflow/docs/concepts/index.md/0
{ "file_path": "promptflow/docs/concepts/index.md", "repo_id": "promptflow", "token_count": 61 }
1
# Adding Category and Tags for Tool This document is dedicated to guiding you through the process of categorizing and tagging your tools for optimal organization and efficiency. Categories help you organize your tools into specific folders, making it much easier to find what you need. Tags, on the other hand, work lik...
promptflow/docs/how-to-guides/develop-a-tool/add-category-and-tags-for-tool.md/0
{ "file_path": "promptflow/docs/how-to-guides/develop-a-tool/add-category-and-tags-for-tool.md", "repo_id": "promptflow", "token_count": 1073 }
2
# Quick Start This guide will walk you through the fist step using of prompt flow code-first experience. **Prerequisite** - To make the most of this tutorial, you'll need: - Know how to program with Python :) - A basic understanding of Machine Learning can be beneficial, but it's not mandatory. **Learning Objectiv...
promptflow/docs/how-to-guides/quick-start.md/0
{ "file_path": "promptflow/docs/how-to-guides/quick-start.md", "repo_id": "promptflow", "token_count": 3764 }
3
# Content Safety (Text) Azure Content Safety is a content moderation service developed by Microsoft that help users detect harmful content from different modalities and languages. This tool is a wrapper for the Azure Content Safety Text API, which allows you to detect text content and get moderation results. See the [...
promptflow/docs/reference/tools-reference/contentsafety_text_tool.md/0
{ "file_path": "promptflow/docs/reference/tools-reference/contentsafety_text_tool.md", "repo_id": "promptflow", "token_count": 917 }
4
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/AzureContentSafetyConnection.schema.json name: azure_content_safety_connection type: azure_content_safety api_key: "<to-be-replaced>" endpoint: "endpoint" api_version: "2023-04-30-preview"
promptflow/examples/connections/azure_content_safety.yml/0
{ "file_path": "promptflow/examples/connections/azure_content_safety.yml", "repo_id": "promptflow", "token_count": 93 }
5
# Test your prompt variants for chat with math This is a prompt tuning case with 3 prompt variants for math question answering. By utilizing this flow, in conjunction with the `evaluation/eval-chat-math` flow, you can quickly grasp the advantages of prompt tuning and experimentation with prompt flow. Here we provide a...
promptflow/examples/flows/chat/chat-math-variant/README.md/0
{ "file_path": "promptflow/examples/flows/chat/chat-math-variant/README.md", "repo_id": "promptflow", "token_count": 623 }
6
inputs: chat_history: type: list default: - inputs: question: what is BERT? outputs: answer: BERT (Bidirectional Encoder Representations from Transformers) is a language representation model that pre-trains deep bidirectional representations from unlabeled text by...
promptflow/examples/flows/chat/chat-with-pdf/flow.dag.yaml.single-node/0
{ "file_path": "promptflow/examples/flows/chat/chat-with-pdf/flow.dag.yaml.single-node", "repo_id": "promptflow", "token_count": 723 }
7
{"entities": ["software engineer","CEO"],"ground_truth": "\"CEO, Software Engineer, Finance Manager\""} {"entities": ["Software Engineer","CEO", "Finance Manager"],"ground_truth": "\"CEO, Software Engineer, Finance Manager\""}
promptflow/examples/flows/evaluation/eval-entity-match-rate/data.jsonl/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-entity-match-rate/data.jsonl", "repo_id": "promptflow", "token_count": 57 }
8
from promptflow import tool def is_valid(input_item): return True if input_item and input_item.strip() else False @tool def validate_input(question: str, answer: str, documents: str, selected_metrics: dict) -> dict: input_data = {"question": is_valid(question), "answer": is_valid(answer), "documents": is_va...
promptflow/examples/flows/evaluation/eval-qna-rag-metrics/validate_input.py/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-qna-rag-metrics/validate_input.py", "repo_id": "promptflow", "token_count": 507 }
9
import os from openai.version import VERSION as OPENAI_VERSION from dotenv import load_dotenv from promptflow import tool # The inputs section will change based on the arguments of the tool function, after you save the code # Adding type to arguments and return value will help the system show the types properly # Ple...
promptflow/examples/flows/standard/basic/hello.py/0
{ "file_path": "promptflow/examples/flows/standard/basic/hello.py", "repo_id": "promptflow", "token_count": 1164 }
10
{ "package": {}, "code": { "summarize_text_content.jinja2": { "type": "llm", "inputs": { "text": { "type": [ "string" ] } }, "description": "Summarize webpage content into a short paragraph." }, "summarize_text_content__variant_1.ji...
promptflow/examples/flows/standard/flow-with-symlinks/.promptflow/flow.tools.json/0
{ "file_path": "promptflow/examples/flows/standard/flow-with-symlinks/.promptflow/flow.tools.json", "repo_id": "promptflow", "token_count": 321 }
11
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json inputs: source: type: string default: ./azure_open_ai.py outputs: code: type: string reference: ${combine_code.output} nodes: - name: load_code type: python source: type: code path: load_code_tool.py input...
promptflow/examples/flows/standard/gen-docstring/flow.dag.yaml/0
{ "file_path": "promptflow/examples/flows/standard/gen-docstring/flow.dag.yaml", "repo_id": "promptflow", "token_count": 352 }
12
from setuptools import find_packages, setup PACKAGE_NAME = "my-tools-package" setup( name=PACKAGE_NAME, version="0.0.12", description="This is my tools package", packages=find_packages(), entry_points={ "package_tools": ["my_tools = my_tool_package.tools.utils:list_package_tools"], }, ...
promptflow/examples/tools/tool-package-quickstart/setup.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/setup.py", "repo_id": "promptflow", "token_count": 224 }
13
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json inputs: text: type: string default: Microsoft outputs: my_output: type: string reference: ${my_package_tool.output} nodes: - name: my_package_tool type: python source: type: package tool: my_tool_package.too...
promptflow/examples/tools/use-cases/custom-strong-type-connection-package-tool-showcase/flow.dag.yaml/0
{ "file_path": "promptflow/examples/tools/use-cases/custom-strong-type-connection-package-tool-showcase/flow.dag.yaml", "repo_id": "promptflow", "token_count": 173 }
14
import json import logging from flask import Flask, jsonify, request from promptflow import load_flow from promptflow.connections import AzureOpenAIConnection from promptflow.entities import FlowContext from promptflow.exceptions import SystemErrorException, UserErrorException class SimpleScoreApp(Flask): pass ...
promptflow/examples/tutorials/flow-deploy/create-service-with-flow/simple_score.py/0
{ "file_path": "promptflow/examples/tutorials/flow-deploy/create-service-with-flow/simple_score.py", "repo_id": "promptflow", "token_count": 1105 }
15
<jupyter_start><jupyter_text>Getting started with prompt flow**Prerequisite** - To make the most of this tutorial, you'll need:- A local clone of the prompt flow repository- A Python environment with Jupyter Notebook support (such as Jupyter Lab or the Python extension for Visual Studio Code)- Know how to program with ...
promptflow/examples/tutorials/get-started/quickstart.ipynb/0
{ "file_path": "promptflow/examples/tutorials/get-started/quickstart.ipynb", "repo_id": "promptflow", "token_count": 2618 }
16
// Get the head element let head = document.getElementsByTagName("head")[0]; // Create the script element let script = document.createElement("script"); script.async = true; script.src = "https://www.googletagmanager.com/gtag/js?id=G-KZXK5PFBZY"; // Create another script element for the gtag code let script2 = docume...
promptflow/scripts/docs/_static/custom.js/0
{ "file_path": "promptflow/scripts/docs/_static/custom.js", "repo_id": "promptflow", "token_count": 771 }
17
#!/usr/bin/env bash set -xe {{ command }}
promptflow/scripts/readme/ghactions_driver/bash_script/bash_script.sh.jinja2/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/bash_script/bash_script.sh.jinja2", "repo_id": "promptflow", "token_count": 16 }
18
- name: {{ step_name }} working-directory: ${{ '{{' }} github.workspace }} run: pf connection create --file {{ yaml_name }} --set api_key=${{ '{{' }} secrets.AOAI_API_KEY_TEST }} api_base=${{ '{{' }} secrets.AOAI_API_ENDPOINT_TEST }}
promptflow/scripts/readme/ghactions_driver/workflow_steps/step_yml_create_aoai.yml.jinja2/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/workflow_steps/step_yml_create_aoai.yml.jinja2", "repo_id": "promptflow", "token_count": 90 }
19
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import argparse import time from pathlib import Path import requests from azure.ai.ml import MLClient, load_environment from azure.identit...
promptflow/scripts/runtime_mgmt/update-runtime.py/0
{ "file_path": "promptflow/scripts/runtime_mgmt/update-runtime.py", "repo_id": "promptflow", "token_count": 1584 }
20
from ruamel.yaml import YAML from pathlib import Path 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/scripts/tool/templates/utils.py.j2/0
{ "file_path": "promptflow/scripts/tool/templates/utils.py.j2", "repo_id": "promptflow", "token_count": 235 }
21
{ "azure_open_ai_connection": { "type": "AzureOpenAIConnection", "value": { "api_key": "aoai-api-key", "api_base": "aoai-api-endpoint", "api_type": "azure", "api_version": "2023-07-01-preview" }, "module": "promptflow.connections" }, "serp_connection": { "type": "SerpCo...
promptflow/src/promptflow-tools/connections.json.example/0
{ "file_path": "promptflow/src/promptflow-tools/connections.json.example", "repo_id": "promptflow", "token_count": 815 }
22
promptflow.tools.embedding.embedding: name: Embedding description: Use Open AI's embedding model to create an embedding vector representing the input text. type: python module: promptflow.tools.embedding function: embedding inputs: connection: type: [AzureOpenAIConnection, OpenAIConnection] de...
promptflow/src/promptflow-tools/promptflow/tools/yamls/embedding.yaml/0
{ "file_path": "promptflow/src/promptflow-tools/promptflow/tools/yamls/embedding.yaml", "repo_id": "promptflow", "token_count": 403 }
23
# System: You are a marketing writing assistant.For user: You help come up with creative content ideas and content like marketing emails, blog posts, tweets, ad copy and product descriptions.You write in a friendly yet professional tone but can tailor your writing style that best works for a user-specified audience.If...
promptflow/src/promptflow-tools/tests/test_configs/prompt_templates/marketing_writer/prompt.jinja2/0
{ "file_path": "promptflow/src/promptflow-tools/tests/test_configs/prompt_templates/marketing_writer/prompt.jinja2", "repo_id": "promptflow", "token_count": 153 }
24
{ "azure_open_ai_connection": { "type": "AzureOpenAIConnection", "value": { "api_key": "aoai-api-key", "api_base": "aoai-api-endpoint", "api_type": "azure", "api_version": "2023-07-01-preview" }, "module": "promptflow.connections" }, "bing_config": { "type": "BingConnec...
promptflow/src/promptflow/dev-connections.json.example/0
{ "file_path": "promptflow/src/promptflow/dev-connections.json.example", "repo_id": "promptflow", "token_count": 988 }
25