text
stringlengths
8
1.72M
id
stringlengths
22
143
metadata
dict
__index_level_0__
int64
0
104
from promptflow import tool @tool def my_python_tool(input1: str) -> str: return 'hello ' + input1
promptflow/src/promptflow/tests/test_configs/flows/activate_with_no_inputs/node_a.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/activate_with_no_inputs/node_a.py", "repo_id": "promptflow", "token_count": 37 }
60
import asyncio import json from openai import AsyncOpenAI from openai.types.beta.threads import MessageContentImageFile, MessageContentText from promptflow import tool, trace from promptflow.connections import OpenAIConnection from promptflow.contracts.multimedia import Image from promptflow.contracts.types import As...
promptflow/src/promptflow/tests/test_configs/flows/assistant-with-file/add_message_and_run.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/assistant-with-file/add_message_and_run.py", "repo_id": "promptflow", "token_count": 3874 }
61
{# Please replace the template with your own prompt. #} system: You task is to generate what I ask user: Write a simple {{text}} program that displays the greeting message when executed.
promptflow/src/promptflow/tests/test_configs/flows/basic-with-connection/hello.jinja2/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/basic-with-connection/hello.jinja2", "repo_id": "promptflow", "token_count": 45 }
62
from promptflow import tool from promptflow.contracts.multimedia import Image @tool def mock_chat(chat_history: list, question: list): ensure_image_in_list(question, "question") for item in chat_history: ensure_image_in_list(item["inputs"]["question"], "inputs of chat history") ensure_image_in...
promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_image/mock_chat.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_image/mock_chat.py", "repo_id": "promptflow", "token_count": 310 }
63
from promptflow import tool @tool def grade(groundtruth: str, prediction: str): groundtruth = groundtruth.lower().strip('"') prediction = prediction.lower().strip('"') return "Correct" if groundtruth == prediction else "Incorrect"
promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/grade.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/grade.py", "repo_id": "promptflow", "token_count": 71 }
64
from promptflow import tool @tool def kql_retriever(content: str) -> str: return "KQL: " + content
promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/kql_tsg_retriever.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/kql_tsg_retriever.py", "repo_id": "promptflow", "token_count": 35 }
65
inputs: image: type: image default: logo.jpg 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} image_2: data:image/png;path: logo_2.png - name: a...
promptflow/src/promptflow/tests/test_configs/flows/eval_flow_with_simple_image/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/eval_flow_with_simple_image/flow.dag.yaml", "repo_id": "promptflow", "token_count": 231 }
66
from promptflow import tool from promptflow.connections import CustomConnection @tool def my_python_tool(text: str, connection: CustomConnection) -> dict: return connection._to_dict()
promptflow/src/promptflow/tests/test_configs/flows/flow_with_custom_connection/hello.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_custom_connection/hello.py", "repo_id": "promptflow", "token_count": 51 }
67
id: web_classification inputs: url: default: https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h is_chat_input: false type: string nodes: - inputs: url: ${inputs.url} name: fetch_text_content_from_url reduce: false source: path: f...
promptflow/src/promptflow/tests/test_configs/flows/flow_with_ignore_file/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_ignore_file/flow.dag.yaml", "repo_id": "promptflow", "token_count": 219 }
68
{"text": "Hello World!"}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_package_tool_with_custom_connection/data.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_package_tool_with_custom_connection/data.jsonl", "repo_id": "promptflow", "token_count": 9 }
69
inputs: user_id: type: int default: 1 outputs: output: type: string reference: ${greetings.output.greeting} nodes: - name: greetings type: python source: type: code path: greetings.py inputs: user_id: ${inputs.user_id}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_trace/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_trace/flow.dag.yaml", "repo_id": "promptflow", "token_count": 111 }
70
inputs: text: type: string outputs: output_prompt: type: string reference: ${llm_tool_with_duplicated_inputs.output} nodes: - name: llm_tool_with_duplicated_inputs type: llm provider: AzureOpenAI api: completion module: promptflow.tools.aoai connection: azure_open_ai_connection source: t...
promptflow/src/promptflow/tests/test_configs/flows/llm_tool_with_duplicated_inputs/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/llm_tool_with_duplicated_inputs/flow.dag.yaml", "repo_id": "promptflow", "token_count": 189 }
71
from promptflow import tool @tool def stringify_num(): print("hello world")
promptflow/src/promptflow/tests/test_configs/flows/no_inputs_outputs/say_hello.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/no_inputs_outputs/say_hello.py", "repo_id": "promptflow", "token_count": 26 }
72
{"key": "no"} {"key": "raise"} {"key": "matter"}
promptflow/src/promptflow/tests/test_configs/flows/partial_fail/data.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/partial_fail/data.jsonl", "repo_id": "promptflow", "token_count": 21 }
73
{ "name": "summarize_text_content_prompt", "type": "prompt", "inputs": { "text": { "type": [ "string" ] }, "image1": { "type": [ "image" ] }, "image2": { "type": [ "image" ] }, "image3": { "type": [ "image" ...
promptflow/src/promptflow/tests/test_configs/flows/prompt_tools/summarize_text_content_prompt.meta.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/prompt_tools/summarize_text_content_prompt.meta.json", "repo_id": "promptflow", "token_count": 311 }
74
inputs: image: type: image default: logo.jpg outputs: output: type: image reference: ${python_node.output} nodes: - name: python_node type: python source: type: code path: passthrough.py inputs: image: ${inputs.image}
promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_image_nested_api_calls/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_image_nested_api_calls/flow.dag.yaml", "repo_id": "promptflow", "token_count": 106 }
75
[ { "image_2": { "data:image/png;path": "logo.jpg" } }, { "image_2": { "data:image/png;path": "logo_2.png" } } ]
promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_simple_image_with_default/inputs.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_simple_image_with_default/inputs.json", "repo_id": "promptflow", "token_count": 125 }
76
from promptflow import tool print(f"The script is {__file__}") @tool def my_python_tool(input1: str) -> str: from pathlib import Path assert Path(__file__).as_posix().endswith("folder/another-tool.py") assert __name__ == "__pf_main__" return f"Prompt: {input1} {__file__}"
promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/folder/another-tool.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/folder/another-tool.py", "repo_id": "promptflow", "token_count": 114 }
77
model: mock_model instructions: mock_instructions tools: - type: function tool_type: python source: type: code path: echo.py
promptflow/src/promptflow/tests/test_configs/flows/tool_with_assistant_definition/assistant_definition.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/tool_with_assistant_definition/assistant_definition.yaml", "repo_id": "promptflow", "token_count": 51 }
78
Please summarize the following text in one paragraph. 100 words. Do not add any information that is not in the text. Text: {{text}} Summary:
promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/lkg_sources/summarize_text_content.jinja2/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/lkg_sources/summarize_text_content.jinja2", "repo_id": "promptflow", "token_count": 35 }
79
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.10.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.10.13 (Windows-...
promptflow/src/promptflow/tests/test_configs/recordings/test_connection_operations_TestConnectionOperations_test_list_connection_spec.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_connection_operations_TestConnectionOperations_test_list_connection_spec.yaml", "repo_id": "promptflow", "token_count": 3527 }
80
inputs: text: type: string outputs: output: type: string reference: ${summarize_text_content.output} nodes: - name: summarize_text_content source: type: code path: summarize_text_content__variant_1.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '256' temp...
promptflow/src/promptflow/tests/test_configs/wrong_flows/tool_type_missing/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/wrong_flows/tool_type_missing/flow.dag.yaml", "repo_id": "promptflow", "token_count": 272 }
81
# Frequency asked questions (FAQ) ## Troubleshooting ## ### Token expired when run pfazure cmd If hit error "AADSTS700082: The refresh token has expired due to inactivity." when running pfazure cmd, it's caused by local cached token expired. Please clear the cached token under "%LOCALAPPDATA%/.IdentityService/msal.c...
promptflow/docs/cloud/azureai/faq.md/0
{ "file_path": "promptflow/docs/cloud/azureai/faq.md", "repo_id": "promptflow", "token_count": 108 }
0
# Deploy a flow using development server :::{admonition} Experimental feature This is an experimental feature, and may change at any time. Learn [more](../faq.md#stable-vs-experimental). ::: Once you have created and thoroughly tested a flow, you can use it as an HTTP endpoint. ::::{tab-set} :::{tab-item} CLI :sync: ...
promptflow/docs/how-to-guides/deploy-a-flow/deploy-using-dev-server.md/0
{ "file_path": "promptflow/docs/how-to-guides/deploy-a-flow/deploy-using-dev-server.md", "repo_id": "promptflow", "token_count": 999 }
1
# Customizing an LLM Tool In this document, we will guide you through the process of customizing an LLM tool, allowing users to seamlessly connect to a large language model with prompt tuning experience using a `PromptTemplate`. ## Prerequisites - Please ensure that your [Prompt flow for VS Code](https://marketplace.v...
promptflow/docs/how-to-guides/develop-a-tool/customize_an_llm_tool.md/0
{ "file_path": "promptflow/docs/how-to-guides/develop-a-tool/customize_an_llm_tool.md", "repo_id": "promptflow", "token_count": 1277 }
2
--- myst: html_meta: "description lang=en": "Prompt flow Doc" "google-site-verification": "rEZN-2h5TVqEco07aaMpqNcDx4bjr2czx1Hwfoxydrg" html_theme.sidebar_secondary.remove: true --- # Prompt flow [**Prompt flow**](https://github.com/microsoft/promptflow) is a suite of development tools designed to streamlin...
promptflow/docs/index.md/0
{ "file_path": "promptflow/docs/index.md", "repo_id": "promptflow", "token_count": 1541 }
3
# OpenAI GPT-4V ## Introduction OpenAI GPT-4V tool enables you to leverage OpenAI's GPT-4 with vision, also referred to as GPT-4V or gpt-4-vision-preview in the API, to take images as input and answer questions about them. ## Prerequisites - Create OpenAI resources Sign up account [OpenAI website](https://opena...
promptflow/docs/reference/tools-reference/openai-gpt-4v-tool.md/0
{ "file_path": "promptflow/docs/reference/tools-reference/openai-gpt-4v-tool.md", "repo_id": "promptflow", "token_count": 1118 }
4
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/OpenAIConnection.schema.json name: open_ai_connection type: open_ai api_key: "<user-input>" organization: "" # optional
promptflow/examples/connections/openai.yml/0
{ "file_path": "promptflow/examples/connections/openai.yml", "repo_id": "promptflow", "token_count": 68 }
5
from promptflow import tool import json import re # 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 # Please update the function name/signature per need @tool def my_python_too...
promptflow/examples/flows/chat/chat-math-variant/extract_result.py/0
{ "file_path": "promptflow/examples/flows/chat/chat-math-variant/extract_result.py", "repo_id": "promptflow", "token_count": 172 }
6
import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__)))
promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/__init__.py/0
{ "file_path": "promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/__init__.py", "repo_id": "promptflow", "token_count": 33 }
7
from typing import Tuple, Union, Optional, Type import functools import time import random def retry_and_handle_exceptions( exception_to_check: Union[Type[Exception], Tuple[Type[Exception], ...]], max_retries: int = 3, initial_delay: float = 1, exponential_base: float = 2, jitter: bool = False, ...
promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/utils/retry.py/0
{ "file_path": "promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/utils/retry.py", "repo_id": "promptflow", "token_count": 1963 }
8
import os from typing import Union from promptflow import tool from promptflow.connections import AzureOpenAIConnection, OpenAIConnection from chat_with_pdf.utils.lock import acquire_lock BASE_DIR = os.path.dirname(os.path.abspath(__file__)) + "/chat_with_pdf/" @tool def setup_env(connection: Union[AzureOpenAIConn...
promptflow/examples/flows/chat/chat-with-pdf/setup_env.py/0
{ "file_path": "promptflow/examples/flows/chat/chat-with-pdf/setup_env.py", "repo_id": "promptflow", "token_count": 531 }
9
inputs: groundtruth: type: string default: "10" is_chat_input: false prediction: type: string default: "10" is_chat_input: false outputs: score: type: string reference: ${line_process.output} nodes: - name: line_process type: python source: type: code path: line_process...
promptflow/examples/flows/evaluation/eval-chat-math/flow.dag.yaml/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-chat-math/flow.dag.yaml", "repo_id": "promptflow", "token_count": 273 }
10
from promptflow import tool import numpy as np from numpy.linalg import norm @tool def compute_ada_cosine_similarity(a, b) -> float: return np.dot(a, b)/(norm(a)*norm(b))
promptflow/examples/flows/evaluation/eval-qna-non-rag/ada_cosine_similarity_score.py/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-qna-non-rag/ada_cosine_similarity_score.py", "repo_id": "promptflow", "token_count": 67 }
11
from promptflow import tool import numpy as np @tool def concat_results(rag_retrieval_score: dict = None, rag_grounding_score: dict = None, rag_generation_score: dict = None): load_list = [{'name': 'gpt_groundedness', 'result': rag_grounding_score}, {'name': 'gpt_retrieval_sco...
promptflow/examples/flows/evaluation/eval-qna-rag-metrics/concat_scores.py/0
{ "file_path": "promptflow/examples/flows/evaluation/eval-qna-rag-metrics/concat_scores.py", "repo_id": "promptflow", "token_count": 529 }
12
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json inputs: name: type: string default: "FilmTriviaGPT" goals: type: list default: ["Introduce 'Lord of the Rings' film trilogy including the film title, release year, director, current age of the director, production compa...
promptflow/examples/flows/standard/autonomous-agent/flow.dag.yaml/0
{ "file_path": "promptflow/examples/flows/standard/autonomous-agent/flow.dag.yaml", "repo_id": "promptflow", "token_count": 591 }
13
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CustomConnection.schema.json name: basic_custom_connection type: custom configs: api_type: azure api_version: 2023-03-15-preview api_base: https://<to-be-replaced>.openai.azure.com/ secrets: # must-have api_key: <to-be-replaced>
promptflow/examples/flows/standard/basic-with-connection/custom.yml/0
{ "file_path": "promptflow/examples/flows/standard/basic-with-connection/custom.yml", "repo_id": "promptflow", "token_count": 119 }
14
from promptflow import tool @tool def product_info(query: str) -> str: print(f"Your query is {query}.\nLooking for product information...") return "This product is produced by Microsoft."
promptflow/examples/flows/standard/conditional-flow-for-switch/product_info.py/0
{ "file_path": "promptflow/examples/flows/standard/conditional-flow-for-switch/product_info.py", "repo_id": "promptflow", "token_count": 58 }
15
import unittest from cleansing import cleansing class CleansingTest(unittest.TestCase): def test_normal(self): self.assertEqual(cleansing("a, b, c"), ["a", "b", "c"]) self.assertEqual(cleansing("a, b, (425)137-98-25, "), ["a", "b", "(425)137-98-25"]) self.assertEqual(cleansing("a, b, F. S...
promptflow/examples/flows/standard/named-entity-recognition/cleansing_test.py/0
{ "file_path": "promptflow/examples/flows/standard/named-entity-recognition/cleansing_test.py", "repo_id": "promptflow", "token_count": 252 }
16
system: Please summarize the following text in one paragraph. 100 words. Do not add any information that is not in the text. user: Text: {{text}} Summary:
promptflow/examples/flows/standard/web-classification/summarize_text_content.jinja2/0
{ "file_path": "promptflow/examples/flows/standard/web-classification/summarize_text_content.jinja2", "repo_id": "promptflow", "token_count": 42 }
17
import importlib from pathlib import Path from promptflow import tool from promptflow.contracts.types import FilePath @tool def my_tool(input_file: FilePath, input_text: str) -> str: # customise your own code to handle and use the input_file here new_module = importlib.import_module(Path(input_file).stem) ...
promptflow/examples/tools/tool-package-quickstart/my_tool_package/tools/tool_with_file_path_input.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/my_tool_package/tools/tool_with_file_path_input.py", "repo_id": "promptflow", "token_count": 111 }
18
import pytest import unittest from promptflow.connections import CustomConnection from my_tool_package.tools.tool_with_custom_llm_type import my_tool @pytest.fixture def my_custom_connection() -> CustomConnection: my_custom_connection = CustomConnection( { "api-key" : "my-api-key", ...
promptflow/examples/tools/tool-package-quickstart/tests/test_tool_with_custom_llm_type.py/0
{ "file_path": "promptflow/examples/tools/tool-package-quickstart/tests/test_tool_with_custom_llm_type.py", "repo_id": "promptflow", "token_count": 295 }
19
{"text": "Python Hello World!"} {"text": "C Hello World!"} {"text": "C# Hello World!"}
promptflow/examples/tools/use-cases/custom-strong-type-connection-script-tool-showcase/data.jsonl/0
{ "file_path": "promptflow/examples/tools/use-cases/custom-strong-type-connection-script-tool-showcase/data.jsonl", "repo_id": "promptflow", "token_count": 31 }
20
--- resources: examples/connections/azure_openai.yml, examples/flows/standard/web-classification --- # Deploy a flow using Docker This example demos how to deploy flow as a docker app. We will use [web-classification](../../../flows/standard/web-classification/README.md) as example in this tutorial. ## Build a flow ...
promptflow/examples/tutorials/flow-deploy/docker/README.md/0
{ "file_path": "promptflow/examples/tutorials/flow-deploy/docker/README.md", "repo_id": "promptflow", "token_count": 672 }
21
import argparse import json from pathlib import Path from azure.keyvault.secrets import SecretClient from azure.identity import ClientSecretCredential, DefaultAzureCredential CONNECTION_FILE_NAME = "connections.json" CONNECTION_TPL_FILE_PATH = Path(".") / "src/promptflow" / "dev-connections.json.example" def get_s...
promptflow/scripts/building/generate_connection_config.py/0
{ "file_path": "promptflow/scripts/building/generate_connection_config.py", "repo_id": "promptflow", "token_count": 1219 }
22
"""A directive to generate a gallery of images from structured data. Generating a gallery of images that are all the same size is a common pattern in documentation, and this can be cumbersome if the gallery is generated programmatically. This directive wraps this particular use-case in a helper-directive to generate it...
promptflow/scripts/docs/gallery_directive/__init__.py/0
{ "file_path": "promptflow/scripts/docs/gallery_directive/__init__.py", "repo_id": "promptflow", "token_count": 2104 }
23
@echo off setlocal set MAIN_EXE=%~dp0.\pfcli.exe "%MAIN_EXE%" pfsvc %*
promptflow/scripts/installer/windows/scripts/pfsvc.bat/0
{ "file_path": "promptflow/scripts/installer/windows/scripts/pfsvc.bat", "repo_id": "promptflow", "token_count": 40 }
24
from pathlib import Path from typing import List import markdown import nbformat from .readme_step import ReadmeStepsManage RESOURCES_KEY_NAME = "resources" RESOURCES_KEY_ERROR_MESSAGE = ( "Please follow examples contributing guide to declare tutorial resources: " "https://github.com/microsoft/promptflow/blo...
promptflow/scripts/readme/ghactions_driver/resource_resolver.py/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/resource_resolver.py", "repo_id": "promptflow", "token_count": 1216 }
25
{% extends "workflow_skeleton.yml.jinja2" %} {% block steps %} runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Generate config.json for canary workspace (scheduled runs only) if: github.event_name == 'schedule' run: echo '${{ '{{' }} secrets.TEST_WORKSPACE_CON...
promptflow/scripts/readme/ghactions_driver/workflow_templates/pdf_workflow.yml.jinja2/0
{ "file_path": "promptflow/scripts/readme/ghactions_driver/workflow_templates/pdf_workflow.yml.jinja2", "repo_id": "promptflow", "token_count": 1069 }
26
import argparse import json from pathlib import Path from utils.secret_manager import get_secret, get_secret_client, list_secret_names CONNECTION_FILE_NAME = "connections.json" PROMPTFLOW_TOOLS_ROOT = Path(__file__) / "../../../src/promptflow-tools" CONNECTION_TPL_FILE_PATH = PROMPTFLOW_TOOLS_ROOT / "connections.json...
promptflow/scripts/tool/generate_connection_config.py/0
{ "file_path": "promptflow/scripts/tool/generate_connection_config.py", "repo_id": "promptflow", "token_count": 677 }
27
""" This file can generate a meta file for the given prompt template or a python file. """ import inspect import types from dataclasses import asdict from utils.tool_utils import function_to_interface from promptflow.contracts.tool import Tool, ToolType # Avoid circular dependencies: Use import 'from promptflow._inte...
promptflow/scripts/tool/utils/generate_tool_meta_utils.py/0
{ "file_path": "promptflow/scripts/tool/utils/generate_tool_meta_utils.py", "repo_id": "promptflow", "token_count": 1865 }
28
import functools import json import re import sys import time from typing import List, Mapping from jinja2 import Template from openai import APIConnectionError, APIStatusError, OpenAIError, RateLimitError, APITimeoutError from promptflow.tools.exception import ChatAPIInvalidRole, WrappedOpenAIError, LLMError, JinjaTe...
promptflow/src/promptflow-tools/promptflow/tools/common.py/0
{ "file_path": "promptflow/src/promptflow-tools/promptflow/tools/common.py", "repo_id": "promptflow", "token_count": 8205 }
29
import httpx import pytest from jinja2.exceptions import TemplateSyntaxError from openai import ( APIConnectionError, RateLimitError, AuthenticationError, BadRequestError, APITimeoutError, InternalServerError, UnprocessableEntityError ) from promptflow.tools.aoai import chat, completion from promptf...
promptflow/src/promptflow-tools/tests/test_handle_openai_error.py/0
{ "file_path": "promptflow/src/promptflow-tools/tests/test_handle_openai_error.py", "repo_id": "promptflow", "token_count": 7049 }
30
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import argparse import functools import json from typing import Dict, List, Optional from promptflow._cli._params import ( add_param_a...
promptflow/src/promptflow/promptflow/_cli/_pf_azure/_run.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/_pf_azure/_run.py", "repo_id": "promptflow", "token_count": 7636 }
31
{ "package": {}, "code": { "line_process.py": { "type": "python", "inputs": { "groundtruth": { "type": [ "string" ] }, "prediction": { "type": [ "string" ] } }, "function": "line_process" ...
promptflow/src/promptflow/promptflow/_cli/data/evaluation_flow/.promptflow/flow.tools.json/0
{ "file_path": "promptflow/src/promptflow/promptflow/_cli/data/evaluation_flow/.promptflow/flow.tools.json", "repo_id": "promptflow", "token_count": 328 }
32
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- CONNECTION_NAME_PROPERTY = "__connection_name" CONNECTION_SECRET_KEYS = "__secret_keys" PROMPTFLOW_CONNECTIONS = "PROMPTFLOW_CONNECTIONS" P...
promptflow/src/promptflow/promptflow/_constants.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_constants.py", "repo_id": "promptflow", "token_count": 565 }
33
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import importlib import importlib.util import inspect import logging import traceback import types from functools import partial from pathl...
promptflow/src/promptflow/promptflow/_core/tools_manager.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_core/tools_manager.py", "repo_id": "promptflow", "token_count": 9268 }
34
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from os import PathLike from typing import IO, AnyStr, Union from promptflow._sdk._load_functions import load_run from promptflow._sdk._pf_...
promptflow/src/promptflow/promptflow/_sdk/_run_functions.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_run_functions.py", "repo_id": "promptflow", "token_count": 236 }
35
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from promptflow.exceptions import ErrorTarget, UserErrorException class BadRequest(UserErrorException): pass class JsonPayloadRequi...
promptflow/src/promptflow/promptflow/_sdk/_serving/_errors.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_serving/_errors.py", "repo_id": "promptflow", "token_count": 655 }
36
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import json import time from types import GeneratorType from flask import Response, jsonify from werkzeug.datastructures import MIMEAccept...
promptflow/src/promptflow/promptflow/_sdk/_serving/response_creator.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_serving/response_creator.py", "repo_id": "promptflow", "token_count": 1813 }
37
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from ._asset_utils import IgnoreFile, get_ignore_file, get_upload_files_from_folder __all__ = ["get_ignore_file", "IgnoreFile", "get_uploa...
promptflow/src/promptflow/promptflow/_sdk/_vendor/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/_vendor/__init__.py", "repo_id": "promptflow", "token_count": 79 }
38
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): # Get the file extension _, file_extension = os.path.splitext(file_path) # Check if the file...
promptflow/src/promptflow/promptflow/_sdk/data/executable/app.py.jinja2/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/data/executable/app.py.jinja2", "repo_id": "promptflow", "token_count": 435 }
39
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- # pylint: disable=protected-access import copy import json import os.path import typing from pathlib import Path from typing import Dict, ...
promptflow/src/promptflow/promptflow/_sdk/entities/_validation/core.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/entities/_validation/core.py", "repo_id": "promptflow", "token_count": 9020 }
40
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import copy import typing from pathlib import Path from marshmallow import fields from marshmallow.exceptions import FieldInstanceResolutio...
promptflow/src/promptflow/promptflow/_sdk/schemas/_fields.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_sdk/schemas/_fields.py", "repo_id": "promptflow", "token_count": 4708 }
41
import re from dataclasses import dataclass from enum import Enum from functools import partial from pathlib import Path from typing import Any, Callable from promptflow._utils.multimedia_utils import is_multimedia_dict class ResourceType(Enum): """ Enumeration of different types of multimedia resources. ...
promptflow/src/promptflow/promptflow/_utils/multimedia_data_converter.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/_utils/multimedia_data_converter.py", "repo_id": "promptflow", "token_count": 2299 }
42
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- from dataclasses import asdict, dataclass from promptflow.azure._restclient.flow.models import ConnectionConfigSpec as RestConnectionConfi...
promptflow/src/promptflow/promptflow/azure/_entities/_workspace_connection_spec.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_entities/_workspace_connection_spec.py", "repo_id": "promptflow", "token_count": 771 }
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/_bulk_runs_operations.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/aio/operations/_bulk_runs_operations.py", "repo_id": "promptflow", "token_count": 9909 }
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/_bulk_runs_operations.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/operations/_bulk_runs_operations.py", "repo_id": "promptflow", "token_count": 14864 }
45
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import json from pathlib import Path from azure.ai.ml._schema import UnionField, YamlFileSchema from azure.ai.ml._schema.core.fields import...
promptflow/src/promptflow/promptflow/azure/_schemas/_flow_schema.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/azure/_schemas/_flow_schema.py", "repo_id": "promptflow", "token_count": 684 }
46
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import re from pathlib import Path from typing import Any, Dict, List, Mapping, Optional from promptflow._constants import LINE_NUMBER_KEY...
promptflow/src/promptflow/promptflow/batch/_batch_inputs_processor.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/batch/_batch_inputs_processor.py", "repo_id": "promptflow", "token_count": 6425 }
47
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- # isort: skip_file # skip to avoid circular import __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore from p...
promptflow/src/promptflow/promptflow/entities/__init__.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/entities/__init__.py", "repo_id": "promptflow", "token_count": 384 }
48
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import asyncio import copy import functools import inspect import os import uuid from pathlib import Path from threading import current_thr...
promptflow/src/promptflow/promptflow/executor/flow_executor.py/0
{ "file_path": "promptflow/src/promptflow/promptflow/executor/flow_executor.py", "repo_id": "promptflow", "token_count": 21318 }
49
from types import GeneratorType import pytest from promptflow._utils.dataclass_serializer import serialize from promptflow.contracts.run_info import Status from promptflow.executor import FlowExecutor from ..utils import get_yaml_file @pytest.mark.usefixtures("dev_connections") @pytest.mark.e2etest class TestExecu...
promptflow/src/promptflow/tests/executor/e2etests/test_traces.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/e2etests/test_traces.py", "repo_id": "promptflow", "token_count": 4733 }
50
{ "tool_with_init_error": { "class_name": "TestLoadErrorTool", "function": "tool", "inputs": { "name": {"type": ["string"]} }, "module": "tool_with_init_error", "name": "Tool with init error", "type": "python" } }
promptflow/src/promptflow/tests/executor/package_tools/tool_with_init_error/package_tool_definition.json/0
{ "file_path": "promptflow/src/promptflow/tests/executor/package_tools/tool_with_init_error/package_tool_definition.json", "repo_id": "promptflow", "token_count": 151 }
51
import pytest from datetime import datetime from dataclasses import dataclass from typing import Dict, List from promptflow._core.generator_proxy import GeneratorProxy from promptflow._utils.dataclass_serializer import \ get_type, serialize, deserialize_dataclass, deserialize_value, assertEqual from promptflow.cont...
promptflow/src/promptflow/tests/executor/unittests/_utils/test_dataclass_serializer.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/_utils/test_dataclass_serializer.py", "repo_id": "promptflow", "token_count": 2910 }
52
from datetime import datetime import pytest from promptflow.batch._result import BatchResult, ErrorSummary, LineError, SystemMetrics from promptflow.contracts.run_info import FlowRunInfo from promptflow.contracts.run_info import RunInfo as NodeRunInfo from promptflow.contracts.run_info import Status from promptflow.e...
promptflow/src/promptflow/tests/executor/unittests/batch/test_result.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/batch/test_result.py", "repo_id": "promptflow", "token_count": 5308 }
53
import pytest from promptflow.contracts.flow import Flow, FlowInputDefinition from promptflow.contracts.tool import ValueType from promptflow.executor._errors import InputParseError, InputTypeError, InvalidAggregationInput, InvalidFlowRequest from promptflow.executor.flow_validator import FlowValidator from ...utils ...
promptflow/src/promptflow/tests/executor/unittests/executor/test_flow_validator.py/0
{ "file_path": "promptflow/src/promptflow/tests/executor/unittests/executor/test_flow_validator.py", "repo_id": "promptflow", "token_count": 5912 }
54
import os import sys import timeit from typing import Callable from unittest import mock import pytest from promptflow._cli._user_agent import USER_AGENT as CLI_USER_AGENT # noqa: E402 from promptflow._sdk._telemetry import log_activity from promptflow._sdk._utils import ClientUserAgentUtil from sdk_cli_azure_test.r...
promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_azure_cli_perf.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_azure_cli_perf.py", "repo_id": "promptflow", "token_count": 1950 }
55
import copy import pytest def build_from_data_and_assert(data, expected): from azure.ai.ml._restclient.v2023_06_01_preview.models import WorkspaceConnectionPropertiesV2BasicResource from promptflow.azure.operations._arm_connection_operations import ArmConnectionOperations data = copy.deepcopy(data) ...
promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_arm_connection_build.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_arm_connection_build.py", "repo_id": "promptflow", "token_count": 3536 }
56
import importlib.util import json import sys from pathlib import Path from unittest.mock import patch import pytest from promptflow import ToolProvider, tool from promptflow._core.tool_meta_generator import ToolValidationError from promptflow._sdk._pf_client import PFClient from promptflow.entities import DynamicList...
promptflow/src/promptflow/tests/sdk_cli_test/e2etests/test_tool.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/e2etests/test_tool.py", "repo_id": "promptflow", "token_count": 8463 }
57
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- import pytest from promptflow import PFClient from promptflow._sdk._utils import ClientUserAgentUtil @pytest.mark.sdk_test @pytest.mark.e...
promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_pf_client.py/0
{ "file_path": "promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_pf_client.py", "repo_id": "promptflow", "token_count": 166 }
58
{ "subscription_id": "", "resource_group": "", "workspace_name": "" }
promptflow/src/promptflow/tests/test_configs/configs/mock_flow_empty_config/.azureml/config.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/configs/mock_flow_empty_config/.azureml/config.json", "repo_id": "promptflow", "token_count": 37 }
59
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/WeaviateConnection.schema.json name: my_weaviate_connection type: weaviate api_key: "<to-be-replaced>" api_base: "endpoint"
promptflow/src/promptflow/tests/test_configs/connections/weaviate_connection.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/connections/weaviate_connection.yaml", "repo_id": "promptflow", "token_count": 73 }
60
path: ./entry.py entry: my_flow
promptflow/src/promptflow/tests/test_configs/eager_flows/flow_with_dataclass_output/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/flow_with_dataclass_output/flow.dag.yaml", "repo_id": "promptflow", "token_count": 12 }
61
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- def my_flow(input_val) -> str: """Simple flow with yaml.""" print(f"Hello world! {input_val}") return f"Hello world! {input_val...
promptflow/src/promptflow/tests/test_configs/eager_flows/simple_with_req/entry.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/simple_with_req/entry.py", "repo_id": "promptflow", "token_count": 81 }
62
inputs: text: type: string outputs: text: type: string reference: ${node_a.output} nodes: - name: node_a type: python source: type: code path: node_a.py inputs: input1: ${inputs.text} - name: node_b type: python source: type: code path: node_b.py inputs: {} activate: ...
promptflow/src/promptflow/tests/test_configs/flows/activate_with_no_inputs/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/activate_with_no_inputs/flow.dag.yaml", "repo_id": "promptflow", "token_count": 162 }
63
from promptflow import tool @tool def test(text: str): return text + "hello world!"
promptflow/src/promptflow/tests/test_configs/flows/all_nodes_bypassed/test.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/all_nodes_bypassed/test.py", "repo_id": "promptflow", "token_count": 29 }
64
{"text": "Hello World!"} {"text": "Hello PromptFlow!"}
promptflow/src/promptflow/tests/test_configs/flows/basic-with-connection/data.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/basic-with-connection/data.jsonl", "repo_id": "promptflow", "token_count": 19 }
65
from openai import AsyncOpenAI from promptflow import tool from promptflow.connections import OpenAIConnection @tool async def get_or_create_thread(conn: OpenAIConnection, thread_id: str): if thread_id: return thread_id cli = AsyncOpenAI(api_key=conn.api_key, organization=conn.organization) threa...
promptflow/src/promptflow/tests/test_configs/flows/chat-with-assistant-no-file/get_or_create_thread.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/chat-with-assistant-no-file/get_or_create_thread.py", "repo_id": "promptflow", "token_count": 136 }
66
{ "grade.completed": 3, "calculate_accuracy.completed": 1, "aggregation_assert.completed": 1 }
promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/expected_status_summary.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/expected_status_summary.json", "repo_id": "promptflow", "token_count": 46 }
67
system: You are a helpful assistant. user: When an incident occurs, there have 3 ways to deal with it, please choose one. 1. {{first_method}} 2. {{second_method}} 3. {{third_method}}
promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/investigation_steps.jinja2/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/investigation_steps.jinja2", "repo_id": "promptflow", "token_count": 55 }
68
{"question": "What's promptflow1?"} {"question": "What's promptflow2?"} {"question": "What's promptflow3?"}
promptflow/src/promptflow/tests/test_configs/flows/csharp_flow/inputs.jsonl/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/csharp_flow/inputs.jsonl", "repo_id": "promptflow", "token_count": 35 }
69
from promptflow import tool from promptflow.contracts.multimedia import Image @tool def merge_images(image_list: list, image_dict: list): res = set() for item in image_list[0]: res.add(item) for _, v in image_dict[0].items(): res.add(v) assert all(isinstance(item, Image) for item in re...
promptflow/src/promptflow/tests/test_configs/flows/eval_flow_with_composite_image/merge_images.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/eval_flow_with_composite_image/merge_images.py", "repo_id": "promptflow", "token_count": 134 }
70
import os from promptflow import tool @tool def get_env_var(key: str): from tensorflow import __version__ print(__version__) print(os.environ.get(key)) # get from env var return {"value": os.environ.get(key)}
promptflow/src/promptflow/tests/test_configs/flows/flow_with_additional_include_req/print_env.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_additional_include_req/print_env.py", "repo_id": "promptflow", "token_count": 89 }
71
ignored_folder *.ignored
promptflow/src/promptflow/tests/test_configs/flows/flow_with_ignore_file/.amlignore/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_ignore_file/.amlignore", "repo_id": "promptflow", "token_count": 8 }
72
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json inputs: text: type: string default: Hello 日本語 outputs: output: type: string reference: ${hello_prompt.output} nodes: - name: hello_prompt type: prompt source: type: code path: hello.jinja2 inputs: text...
promptflow/src/promptflow/tests/test_configs/flows/flow_with_non_english_input/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_non_english_input/flow.dag.yaml", "repo_id": "promptflow", "token_count": 144 }
73
inputs: text: type: string outputs: output_prompt: type: string reference: ${echo_my_prompt.output} nodes: - inputs: input1: ${inputs.text} name: echo_my_prompt type: python source: type: code path: hello.py
promptflow/src/promptflow/tests/test_configs/flows/flow_with_sys_inject/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_sys_inject/flow.dag.yaml", "repo_id": "promptflow", "token_count": 105 }
74
inputs: topic: type: string default: hello world is_chat_input: false stream: type: bool default: false is_chat_input: false outputs: joke: type: string reference: ${echo.output} nodes: - name: echo type: python source: type: code path: echo.py inputs: input: ${jo...
promptflow/src/promptflow/tests/test_configs/flows/llm_tool/flow.dag.yaml/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/llm_tool/flow.dag.yaml", "repo_id": "promptflow", "token_count": 313 }
75
from promptflow import tool @tool def mod_two(number: int): if number % 2 != 0: raise Exception("cannot mod 2!") return {"value": number}
promptflow/src/promptflow/tests/test_configs/flows/mod-n/two/mod_two.py/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/mod-n/two/mod_two.py", "repo_id": "promptflow", "token_count": 58 }
76
{ "prompt": "What is the capital of the United States of America?" }
promptflow/src/promptflow/tests/test_configs/flows/openai_completion_api_flow/samples.json/0
{ "file_path": "promptflow/src/promptflow/tests/test_configs/flows/openai_completion_api_flow/samples.json", "repo_id": "promptflow", "token_count": 24 }
77