text stringlengths 8 1.72M | id stringlengths 22 143 | metadata dict | __index_level_0__ int64 0 104 |
|---|---|---|---|
import os
from promptflow import tool
@tool
def get_env_var(key: str):
if key == "raise":
raise Exception("expected raise!")
print(os.environ.get(key))
# get from env var
return {"value": os.environ.get(key)}
| promptflow/src/promptflow/tests/test_configs/flows/partial_fail/print_env.py/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/partial_fail/print_env.py",
"repo_id": "promptflow",
"token_count": 92
} | 70 |
inputs:
text:
type: string
outputs:
output_echo:
type: string
reference: ${echo_my_input.output}
nodes:
- name: echo_my_input
type: python
source:
type: code
path: echo_input.py
inputs:
input: ${inputs.text}
| promptflow/src/promptflow/tests/test_configs/flows/python_stream_tools/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_stream_tools/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 103
} | 71 |
from promptflow import tool
@tool
def passthrough(image, call_passthrough: bool = True):
if call_passthrough:
image = passthrough(image, False)
return image
| promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_image_nested_api_calls/passthrough.py/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_image_nested_api_calls/passthrough.py",
"repo_id": "promptflow",
"token_count": 63
} | 72 |
{
"name": "script_with___file__",
"type": "python",
"inputs": {
"input1": {
"type": [
"string"
]
}
},
"source": "script_with___file__.py",
"function": "my_python_tool"
} | promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/script_with___file__.meta.json/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/script_with___file__.meta.json",
"repo_id": "promptflow",
"token_count": 103
} | 73 |
inputs:
message:
type: string
default: Hello World!
outputs:
output:
type: object
reference: ${test_assistant_definition.output}
nodes:
- name: test_assistant_definition
type: python
source:
type: code
path: test_assistant_definition.py
inputs:
message: ${inputs.message}
assist... | promptflow/src/promptflow/tests/test_configs/flows/tool_with_assistant_definition/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/tool_with_assistant_definition/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 129
} | 74 |
'aadb0707e9a62b00df9d0d3fecb709ece90a8b67', (0, 2261)
'28e341291f602cdf951239f0152fa9e26deb501b', (67584, 3359)
'e25f352dc22315a0e2c3ee2a3cd629763fc0ae5e', (9216, 3302)
'dc8625906abf86f47f2c52b461f108ab6b98a1cf', (12800, 3795)
'a30838607856c1b8efd522af93ea1edb88f57b4f', (16896, 3671)
'4f7cfc5331a898e9c7abb00e2d0f6f818d... | promptflow/src/promptflow/tests/test_configs/node_recordings/node_cache.shelve.bak/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/node_recordings/node_cache.shelve.bak",
"repo_id": "promptflow",
"token_count": 3069
} | 75 |
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- promptflow-sdk/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0
Python/3.10.13 (Windows-... | promptflow/src/promptflow/tests/test_configs/recordings/test_flow_operations_TestFlow_test_get_flow.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_flow_operations_TestFlow_test_get_flow.yaml",
"repo_id": "promptflow",
"token_count": 14977
} | 76 |
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- promptflow-sdk/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0
Python/3.10.13 (Windows-... | promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_get_detail_against_partial_fail_run.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_get_detail_against_partial_fail_run.yaml",
"repo_id": "promptflow",
"token_count": 54461
} | 77 |
name: flow_run_20230629_101205
description: sample bulk run
# flow relative to current working directory should not be supported.
flow: tests/test_configs/flows/web_classification
data: ../datas/webClassification1.jsonl
column_mapping:
url: "${data.url}"
variant: ${summarize_text_content.variant_0}
# run config: en... | promptflow/src/promptflow/tests/test_configs/runs/bulk_run_invalid_flow_path.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/runs/bulk_run_invalid_flow_path.yaml",
"repo_id": "promptflow",
"token_count": 115
} | 78 |
from jinja2 import Template
from promptflow.connections import CustomConnection
from promptflow import ToolProvider, tool
from promptflow.connections import AzureOpenAIConnection
from promptflow.contracts.types import PromptTemplate
class TestCustomLLMTool(ToolProvider):
def __init__(self, connection: AzureOpenA... | promptflow/src/promptflow/tests/test_configs/tools/custom_llm_tool.py/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/tools/custom_llm_tool.py",
"repo_id": "promptflow",
"token_count": 396
} | 79 |
inputs:
text:
type: string
outputs:
output:
type: string
reference: ${summarize_text_content.output}
nodes:
- name: summarize_text_content
type: llm
source:
type: code
path: summarize_text_content__variant_1.jinja2
inputs:
deployment_name: text-davinci-003
suffix: ''
max_tokens... | promptflow/src/promptflow/tests/test_configs/wrong_flows/wrong_api/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/wrong_flows/wrong_api/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 280
} | 80 |
# Prompt flow
[](https://pypi.org/project/promptflow/)
[](https://pypi.python.org/pypi/promptflow/)
[](https://pypi.org... | promptflow/README.md/0 | {
"file_path": "promptflow/README.md",
"repo_id": "promptflow",
"token_count": 2770
} | 0 |
# Adding a Tool Icon
A tool icon serves as a graphical representation of your tool in the user interface (UI). Follow this guidance to add a custom tool icon when developing your own tool package.
Adding a custom tool icon is optional. If you do not provide one, the system uses a default icon.
## Prerequisites
- Ple... | promptflow/docs/how-to-guides/develop-a-tool/add-a-tool-icon.md/0 | {
"file_path": "promptflow/docs/how-to-guides/develop-a-tool/add-a-tool-icon.md",
"repo_id": "promptflow",
"token_count": 4044
} | 1 |
# Process image in flow
PromptFlow defines a contract to represent image data.
## Data class
`promptflow.contracts.multimedia.Image`
Image class is a subclass of `bytes`, thus you can access the binary data by directly using the object. It has an extra attribute `source_url` to store the origin url of the image, which... | promptflow/docs/how-to-guides/process-image-in-flow.md/0 | {
"file_path": "promptflow/docs/how-to-guides/process-image-in-flow.md",
"repo_id": "promptflow",
"token_count": 1332
} | 2 |
# Azure OpenAI GPT-4 Turbo with Vision
## Introduction
Azure OpenAI GPT-4 Turbo with Vision tool enables you to leverage your AzureOpenAI GPT-4 Turbo with Vision model deployment to analyze images and provide textual responses to questions about them.
## Prerequisites
- Create AzureOpenAI resources
Create Azure... | promptflow/docs/reference/tools-reference/aoai-gpt4-turbo-vision.md/0 | {
"file_path": "promptflow/docs/reference/tools-reference/aoai-gpt4-turbo-vision.md",
"repo_id": "promptflow",
"token_count": 1178
} | 3 |
# Working with Connection
This folder contains example `YAML` files for creating `connection` using `pf` cli. Learn more on all the [connections types](https://microsoft.github.io/promptflow/concepts/concept-connections.html).
## Prerequisites
- Install promptflow sdk and other dependencies:
```bash
pip install -r req... | promptflow/examples/connections/README.md/0 | {
"file_path": "promptflow/examples/connections/README.md",
"repo_id": "promptflow",
"token_count": 458
} | 4 |
{
"package": {},
"code": {
"chat.jinja2": {
"type": "llm",
"inputs": {
"chat_history": {
"type": [
"string"
]
},
"question": {
"type": [
"string"
]
}
},
"source": "chat.jinja2"
},
"cha... | promptflow/examples/flows/chat/chat-math-variant/.promptflow/flow.tools.json/0 | {
"file_path": "promptflow/examples/flows/chat/chat-math-variant/.promptflow/flow.tools.json",
"repo_id": "promptflow",
"token_count": 746
} | 5 |
<jupyter_start><jupyter_code>from main import chat_with_pdf, print_stream_and_return_full_answer
from dotenv import load_dotenv
load_dotenv()
bert_paper_url = "https://arxiv.org/pdf/1810.04805.pdf"
questions = [
"what is BERT?",
"what NLP tasks does it perform well?",
"is BERT suitable for NER?",
"is ... | promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/test.ipynb/0 | {
"file_path": "promptflow/examples/flows/chat/chat-with-pdf/chat_with_pdf/test.ipynb",
"repo_id": "promptflow",
"token_count": 321
} | 6 |
inputs:
chat_history:
type: list
default: []
pdf_url:
type: string
default: https://arxiv.org/pdf/1810.04805.pdf
question:
type: string
is_chat_input: true
default: what NLP tasks does it perform well?
outputs:
answer:
type: string
is_chat_output: true
reference: ${qna_to... | promptflow/examples/flows/chat/chat-with-pdf/flow.dag.yaml.multi-node/0 | {
"file_path": "promptflow/examples/flows/chat/chat-with-pdf/flow.dag.yaml.multi-node",
"repo_id": "promptflow",
"token_count": 501
} | 7 |
from promptflow import tool
@tool
def process_search_result(search_result):
def format(doc: dict):
return f"Content: {doc['Content']}\nSource: {doc['Source']}"
try:
context = []
for url, content in search_result:
context.append({"Content": content, "Source": url})
... | promptflow/examples/flows/chat/chat-with-wikipedia/process_search_result.py/0 | {
"file_path": "promptflow/examples/flows/chat/chat-with-wikipedia/process_search_result.py",
"repo_id": "promptflow",
"token_count": 198
} | 8 |
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
groundtruth:
type: string
default: groundtruth
prediction:
type: string
default: prediction
outputs:
results:
type: string
reference: ${line_process.output}
nodes:
- name: line_process
type: python
... | promptflow/examples/flows/evaluation/eval-basic/flow.dag.yaml/0 | {
"file_path": "promptflow/examples/flows/evaluation/eval-basic/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 242
} | 9 |
system:
You are an AI assistant. You will be given the definition of an evaluation metric for assessing the quality of an answer in a question-answering task. Your job is to compute an accurate evaluation score using the provided evaluation metric.
user:
Equivalence, as a metric, measures the similarity between the pre... | promptflow/examples/flows/evaluation/eval-qna-non-rag/gpt_similarity_prompt.jinja2/0 | {
"file_path": "promptflow/examples/flows/evaluation/eval-qna-non-rag/gpt_similarity_prompt.jinja2",
"repo_id": "promptflow",
"token_count": 828
} | 10 |
from promptflow import tool
@tool
def select_metrics(metrics: str) -> str:
supported_metrics = ('gpt_relevance', 'gpt_groundedness', 'gpt_retrieval_score')
user_selected_metrics = [metric.strip() for metric in metrics.split(',') if metric]
metric_selection_dict = {}
for metric in supported_metrics:
... | promptflow/examples/flows/evaluation/eval-qna-rag-metrics/select_metrics.py/0 | {
"file_path": "promptflow/examples/flows/evaluation/eval-qna-rag-metrics/select_metrics.py",
"repo_id": "promptflow",
"token_count": 196
} | 11 |
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
environment:
python_requirements_txt: requirements.txt
inputs:
chat_history:
type: list
is_chat_history: true
utterance:
type: string
is_chat_input: true
default: Play BB King and increase the volume.
outputs:
i... | promptflow/examples/flows/integrations/azure-ai-language/multi_intent_conversational_language_understanding/flow.dag.yaml/0 | {
"file_path": "promptflow/examples/flows/integrations/azure-ai-language/multi_intent_conversational_language_understanding/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 389
} | 12 |
# Basic flow with builtin llm tool
A basic standard flow that calls Azure OpenAI with builtin llm tool.
Tools used in this flow:
- `prompt` tool
- built-in `llm` tool
Connections used in this flow:
- `azure_open_ai` connection
## Prerequisites
Install promptflow sdk and other dependencies:
```bash
pip install -r r... | promptflow/examples/flows/standard/basic-with-builtin-llm/README.md/0 | {
"file_path": "promptflow/examples/flows/standard/basic-with-builtin-llm/README.md",
"repo_id": "promptflow",
"token_count": 730
} | 13 |
system:
There is a search bar in the mall APP and users can enter any query in the search bar.
The user may want to search for orders, view product information, or seek recommended products.
Therefore, please classify user intentions into the following three types according to the query: product_recommendation, order... | promptflow/examples/flows/standard/conditional-flow-for-switch/classify_with_llm.jinja2/0 | {
"file_path": "promptflow/examples/flows/standard/conditional-flow-for-switch/classify_with_llm.jinja2",
"repo_id": "promptflow",
"token_count": 110
} | 14 |
import logging
import os
from urllib.parse import urlparse
import requests
class File:
def __init__(self, source: str):
self._source = source
self._is_url = source.startswith("http://") or source.startswith("https://")
if self._is_url:
parsed_url = urlparse(source)
... | promptflow/examples/flows/standard/gen-docstring/file.py/0 | {
"file_path": "promptflow/examples/flows/standard/gen-docstring/file.py",
"repo_id": "promptflow",
"token_count": 1206
} | 15 |
my_tool_package.tools.tool_with_generated_by_input.my_tool:
function: my_tool
inputs:
index_json:
type:
- string
generated_by:
func_path: my_tool_package.tools.tool_with_generated_by_input.generate_index_json
func_kwargs:
- name: index_type
type:
... | promptflow/examples/tools/tool-package-quickstart/my_tool_package/yamls/tool_with_generated_by_input.yaml/0 | {
"file_path": "promptflow/examples/tools/tool-package-quickstart/my_tool_package/yamls/tool_with_generated_by_input.yaml",
"repo_id": "promptflow",
"token_count": 2072
} | 16 |
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs: {}
outputs:
output:
type: string
reference: ${My_Tool_with_Dynamic_List_Input_cywc.output}
nodes:
- name: My_Tool_with_Dynamic_List_Input_cywc
type: python
source:
type: package
tool: my_tool_package.tools.too... | promptflow/examples/tools/use-cases/dynamic-list-input-tool-showcase/flow.dag.yaml/0 | {
"file_path": "promptflow/examples/tools/use-cases/dynamic-list-input-tool-showcase/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 192
} | 17 |
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
flow_input:
type: string
outputs:
output:
type: object
reference: ${echo_connection.output}
nodes:
- name: echo_connection
type: python
source:
type: code
path: echo_connection.py
inputs:
flow_inpu... | promptflow/examples/tutorials/flow-deploy/create-service-with-flow/echo_connection_flow/flow.dag.yaml/0 | {
"file_path": "promptflow/examples/tutorials/flow-deploy/create-service-with-flow/echo_connection_flow/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 162
} | 18 |
<jupyter_start><jupyter_text>Run prompt flow in Azure AI**Requirements** - In order to benefit from this tutorial, you will need:- An Azure account with an active subscription - [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F)- An Azure ML workspace - [Configure workspace](../../config... | promptflow/examples/tutorials/get-started/quickstart-azure.ipynb/0 | {
"file_path": "promptflow/examples/tutorials/get-started/quickstart-azure.ipynb",
"repo_id": "promptflow",
"token_count": 2231
} | 19 |
.title {
font-weight:700;
}
.sd-card-header {
font-weight:700;
font-size: 16px;
}
.bd-page-width {
max-width: 100rem;
}
.bd-sidebar-primary {
flex: 0 0 20%;
}
.bd-main .bd-content .bd-article-container {
max-width: 70em;
}
html[data-theme="light"] {
--header-announcement-color: #fff070... | promptflow/scripts/docs/_static/custom.css/0 | {
"file_path": "promptflow/scripts/docs/_static/custom.css",
"repo_id": "promptflow",
"token_count": 554
} | 20 |
- name: {{ step_name }}
working-directory: examples
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements.txt | promptflow/scripts/readme/ghactions_driver/workflow_steps/step_install_dev_deps.yml.jinja2/0 | {
"file_path": "promptflow/scripts/readme/ghactions_driver/workflow_steps/step_install_dev_deps.yml.jinja2",
"repo_id": "promptflow",
"token_count": 47
} | 21 |
$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json
name: chat-with-pdf
build:
path: context
inference_config:
liveness_route:
port: 8080
path: /health
readiness_route:
port: 8080
path: /health
scoring_route:
port: 8080
path: /score
| promptflow/scripts/runtime_mgmt/runtime-env/env.yaml/0 | {
"file_path": "promptflow/scripts/runtime_mgmt/runtime-env/env.yaml",
"repo_id": "promptflow",
"token_count": 117
} | 22 |
{{ package_name }}.tools.{{ tool_name }}.{{ class_name }}.{{ function_name }}:
class_name: {{ class_name }}
function: {{ function_name }}
inputs:
url:
type:
- string
query:
type:
- string
module: {{ package_name }}.tools.{{ tool_name }}
name: Hello World Tool
description: Thi... | promptflow/scripts/tool/templates/tool2.yaml.j2/0 | {
"file_path": "promptflow/scripts/tool/templates/tool2.yaml.j2",
"repo_id": "promptflow",
"token_count": 133
} | 23 |
promptflow.tools.azure_content_safety.analyze_text:
module: promptflow.tools.azure_content_safety
function: analyze_text
inputs:
connection:
type:
- AzureContentSafetyConnection
hate_category:
default: medium_sensitivity
enum:
- disable
- low_sensitivity
- medium_... | promptflow/src/promptflow-tools/promptflow/tools/yamls/azure_content_safety.yaml/0 | {
"file_path": "promptflow/src/promptflow-tools/promptflow/tools/yamls/azure_content_safety.yaml",
"repo_id": "promptflow",
"token_count": 492
} | 24 |
# Prompt flow
[](https://pypi.org/project/promptflow/)
[](https://pypi.python.org/pypi/promptflow/)
[](https://pypi.or... | promptflow/src/promptflow/README.md/0 | {
"file_path": "promptflow/src/promptflow/README.md",
"repo_id": "promptflow",
"token_count": 1489
} | 25 |
import os
from promptflow._cli._params import (
add_param_yes,
base_params,
)
from promptflow._cli._utils import activate_action, get_cli_sdk_logger
from promptflow._utils.utils import prompt_y_n
from promptflow.exceptions import UserErrorException
logger = get_cli_sdk_logger()
UPGRADE_MSG = 'Not able to upgr... | promptflow/src/promptflow/promptflow/_cli/_pf/_upgrade.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_cli/_pf/_upgrade.py",
"repo_id": "promptflow",
"token_count": 2343
} | 26 |
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/OpenAIConnection.schema.json
name: {{ connection }}
type: open_ai
api_key: "<user-input>"
| promptflow/src/promptflow/promptflow/_cli/data/chat_flow/template/openai.yaml.jinja2/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_cli/data/chat_flow/template/openai.yaml.jinja2",
"repo_id": "promptflow",
"token_count": 59
} | 27 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from contextvars import ContextVar
from typing import Dict, Mapping
from promptflow._version import VERSION
class OperationContext(Dict):... | promptflow/src/promptflow/promptflow/_core/operation_context.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_core/operation_context.py",
"repo_id": "promptflow",
"token_count": 2764
} | 28 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from typing import List, Optional
from sqlalchemy import TEXT, Column
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import ... | promptflow/src/promptflow/promptflow/_sdk/_orm/connection.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_sdk/_orm/connection.py",
"repo_id": "promptflow",
"token_count": 1061
} | 29 |
packageName: Promptflow.Core.PfsClient
packageVersion: 0.0.1
targetFramework: netstandard2.0
optionalProjectFile: false
| promptflow/src/promptflow/promptflow/_sdk/_service/generator_configs/csharp.yaml/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_sdk/_service/generator_configs/csharp.yaml",
"repo_id": "promptflow",
"token_count": 37
} | 30 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from dataclasses import dataclass
from typing import Mapping, Any
from promptflow.contracts.run_info import FlowRunInfo
from promptflow.con... | promptflow/src/promptflow/promptflow/_sdk/_serving/flow_result.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_sdk/_serving/flow_result.py",
"repo_id": "promptflow",
"token_count": 154
} | 31 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from .activity import ( # noqa: F401
ActivityCompletionStatus,
ActivityType,
log_activity,
monitor_operation,
request_i... | promptflow/src/promptflow/promptflow/_sdk/_telemetry/__init__.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_sdk/_telemetry/__init__.py",
"repo_id": "promptflow",
"token_count": 150
} | 32 |
# syntax=docker/dockerfile:1
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /
COPY ./flow /flow
COPY ./connections /connections
COPY ./start.sh /start.sh
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
COPY --from=build / /
ENV IS_IN_DOCKER="true"
EXPOSE 8080
RUN apt-get update && apt-get install -y run... | promptflow/src/promptflow/promptflow/_sdk/data/docker_csharp/Dockerfile.jinja2/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_sdk/data/docker_csharp/Dockerfile.jinja2",
"repo_id": "promptflow",
"token_count": 194
} | 33 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from os import PathLike
from pathlib import Path
from typing import Union
from promptflow._constants import LANGUAGE_KEY, FlowLanguage
from... | promptflow/src/promptflow/promptflow/_sdk/entities/_eager_flow.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_sdk/entities/_eager_flow.py",
"repo_id": "promptflow",
"token_count": 724
} | 34 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import copy
import os.path
import sys
import time
from dataclasses import asdict
from typing import Any, Dict, List, Optional, Union
from ... | promptflow/src/promptflow/promptflow/_sdk/operations/_run_operations.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_sdk/operations/_run_operations.py",
"repo_id": "promptflow",
"token_count": 7452
} | 35 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import json
import os
from datetime import datetime
from enum import Enum
from traceback import TracebackException, format_tb
from types im... | promptflow/src/promptflow/promptflow/_utils/exception_utils.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/_utils/exception_utils.py",
"repo_id": "promptflow",
"token_count": 5410
} | 36 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
from ._pf_client import PFClient
__all__ = ["PFClient"]
| promptflow/src/promptflow/promptflow/azure/__init__.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/azure/__init__.py",
"repo_id": "promptflow",
"token_count": 75
} | 37 |
# --------------------------------------------------------------------------
# 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/_vendor.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/_vendor.py",
"repo_id": "promptflow",
"token_count": 365
} | 38 |
# 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/_tools_operations.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/aio/operations/_tools_operations.py",
"repo_id": "promptflow",
"token_count": 8893
} | 39 |
# 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/_tools_operations.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/azure/_restclient/flow/operations/_tools_operations.py",
"repo_id": "promptflow",
"token_count": 13696
} | 40 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
# pylint: disable=protected-access
import copy
import json
import os
import re
from datetime import datetime
from functools import cached_pr... | promptflow/src/promptflow/promptflow/azure/operations/_flow_operations.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/azure/operations/_flow_operations.py",
"repo_id": "promptflow",
"token_count": 10428
} | 41 |
import base64
import filetype
import hashlib
from typing import Callable, Optional
class PFBytes(bytes):
"""This class is used to represent a bytes object in PromptFlow.
It has all the functionalities of a bytes object,
and also has some additional methods to help with serialization and deserialization.
... | promptflow/src/promptflow/promptflow/contracts/multimedia.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/contracts/multimedia.py",
"repo_id": "promptflow",
"token_count": 977
} | 42 |
import contextvars
import multiprocessing
import os
import queue
import signal
import sys
import threading
import time
from datetime import datetime
from functools import partial
from logging import INFO
from multiprocessing import Manager, Queue
from multiprocessing.pool import ThreadPool
from typing import List, Opti... | promptflow/src/promptflow/promptflow/executor/_line_execution_process_pool.py/0 | {
"file_path": "promptflow/src/promptflow/promptflow/executor/_line_execution_process_pool.py",
"repo_id": "promptflow",
"token_count": 14550
} | 43 |
[tool.black]
line-length = 120
[tool.pytest.ini_options]
markers = [
"sdk_test",
"cli_test",
"unittest",
"e2etest",
"flaky",
"endpointtest",
"mt_endpointtest",
]
[tool.coverage.run]
omit = [
# omit anything in a _restclient directory anywhere
"*/_restclient/*",
]
| promptflow/src/promptflow/pyproject.toml/0 | {
"file_path": "promptflow/src/promptflow/pyproject.toml",
"repo_id": "promptflow",
"token_count": 139
} | 44 |
import json
from pathlib import Path
from tempfile import mkdtemp
import pytest
from promptflow._core._errors import FlowOutputUnserializable, InvalidSource
from promptflow._core.tools_manager import APINotFound
from promptflow._sdk._constants import DAG_FILE_NAME
from promptflow._utils.utils import dump_list_to_json... | promptflow/src/promptflow/tests/executor/e2etests/test_executor_validation.py/0 | {
"file_path": "promptflow/src/promptflow/tests/executor/e2etests/test_executor_validation.py",
"repo_id": "promptflow",
"token_count": 8603
} | 45 |
{{api}}
| promptflow/src/promptflow/tests/executor/package_tools/custom_llm_tool_with_duplicated_inputs/prompt_with_duplicated_inputs.jinja2/0 | {
"file_path": "promptflow/src/promptflow/tests/executor/package_tools/custom_llm_tool_with_duplicated_inputs/prompt_with_duplicated_inputs.jinja2",
"repo_id": "promptflow",
"token_count": 4
} | 46 |
import inspect
import pytest
from promptflow import tool
from promptflow._core.tool import InputSetting, ToolType
from promptflow._core.tracer import Tracer, TraceType
from promptflow.exceptions import UserErrorException
@tool
def decorated_without_parentheses(a: int):
return a
@tool()
def decorated_with_pare... | promptflow/src/promptflow/tests/executor/unittests/_core/test_tool.py/0 | {
"file_path": "promptflow/src/promptflow/tests/executor/unittests/_core/test_tool.py",
"repo_id": "promptflow",
"token_count": 1222
} | 47 |
import pytest
import os
from unittest.mock import patch
from datetime import datetime
from promptflow._utils.utils import is_json_serializable, get_int_env_var, log_progress
class MyObj:
pass
@pytest.mark.unittest
class TestUtils:
@pytest.mark.parametrize("value, expected_res", [(None, True), (1, True), ("... | promptflow/src/promptflow/tests/executor/unittests/_utils/test_utils.py/0 | {
"file_path": "promptflow/src/promptflow/tests/executor/unittests/_utils/test_utils.py",
"repo_id": "promptflow",
"token_count": 1286
} | 48 |
import pytest
from pathlib import Path
from typing import Callable
from promptflow import tool
from promptflow.executor._assistant_tool_invoker import AssistantToolInvoker
from promptflow.executor._errors import UnsupportedAssistantToolType
@pytest.mark.unittest
class TestAssistantToolInvoker:
@pytest.fixture
... | promptflow/src/promptflow/tests/executor/unittests/executor/test_assistant_tool_invoker.py/0 | {
"file_path": "promptflow/src/promptflow/tests/executor/unittests/executor/test_assistant_tool_invoker.py",
"repo_id": "promptflow",
"token_count": 1969
} | 49 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import copy
import inspect
import json
from pathlib import Path
from typing import Dict, List
import vcr
from vcr import matchers
from vcr... | promptflow/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/bases.py/0 | {
"file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/bases.py",
"repo_id": "promptflow",
"token_count": 6082
} | 50 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from unittest.mock import MagicMock
import pytest
from promptflow.exceptions import UserErrorException
@pytest.mark.unittest
class TestU... | promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_utils.py/0 | {
"file_path": "promptflow/src/promptflow/tests/sdk_cli_azure_test/unittests/test_utils.py",
"repo_id": "promptflow",
"token_count": 953
} | 51 |
import copy
import os.path
import re
import shutil
import tempfile
from pathlib import Path
import mock
import pytest
from promptflow._sdk._constants import FLOW_TOOLS_JSON, NODE_VARIANTS, PROMPT_FLOW_DIR_NAME, USE_VARIANTS
from promptflow._utils.yaml_utils import load_yaml
from promptflow.connections import AzureOpe... | promptflow/src/promptflow/tests/sdk_cli_test/e2etests/test_flow_local_operations.py/0 | {
"file_path": "promptflow/src/promptflow/tests/sdk_cli_test/e2etests/test_flow_local_operations.py",
"repo_id": "promptflow",
"token_count": 10437
} | 52 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from pathlib import Path
import pytest
from marshmallow import ValidationError
from promptflow import load_flow
from promptflow._sdk.entit... | promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_flow.py/0 | {
"file_path": "promptflow/src/promptflow/tests/sdk_cli_test/unittests/test_flow.py",
"repo_id": "promptflow",
"token_count": 1607
} | 53 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import pytest
from promptflow._sdk._utils import get_promptflow_sdk_version
from ..utils import PFSOperations
@pytest.mark.e2etest
clas... | promptflow/src/promptflow/tests/sdk_pfs_test/e2etests/test_general_apis.py/0 | {
"file_path": "promptflow/src/promptflow/tests/sdk_pfs_test/e2etests/test_general_apis.py",
"repo_id": "promptflow",
"token_count": 217
} | 54 |
path: ./entry.py
entry: my_flow | promptflow/src/promptflow/tests/test_configs/eager_flows/dummy_flow_with_exception/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/dummy_flow_with_exception/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 12
} | 55 |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import time
def my_flow(input_val) -> str:
"""Simple flow with yaml."""
time.sleep(100)
print(f"Hello world! {input_val}")
... | promptflow/src/promptflow/tests/test_configs/eager_flows/long_running/entry.py/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/eager_flows/long_running/entry.py",
"repo_id": "promptflow",
"token_count": 94
} | 56 |
{
"text": "hello"
} | promptflow/src/promptflow/tests/test_configs/flows/activate_condition_always_met/inputs.json/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/activate_condition_always_met/inputs.json",
"repo_id": "promptflow",
"token_count": 13
} | 57 |
[
{
"expected_node_count": 2,
"expected_outputs": {
"output": "Execution"
},
"expected_bypassed_nodes": [
"nodeA"
]
}
] | promptflow/src/promptflow/tests/test_configs/flows/all_depedencies_bypassed_with_activate_met/expected_result.json/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/all_depedencies_bypassed_with_activate_met/expected_result.json",
"repo_id": "promptflow",
"token_count": 117
} | 58 |
inputs:
input_str:
type: string
default: Hello
outputs:
ouput1:
type: string
reference: ${async_passthrough1.output}
output2:
type: string
reference: ${async_passthrough2.output}
nodes:
- name: async_passthrough
type: python
source:
type: code
path: async_passthrough.py
input... | promptflow/src/promptflow/tests/test_configs/flows/async_tools/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/async_tools/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 296
} | 59 |
model: gpt-4-1106-preview
instructions: You are a helpful assistant.
tools:
- type: code_interpreter
- type: function
source:
type: code
path: get_calorie_by_jogging.py
tool_type: python
- type: function
source:
type: code
path: get_calorie_by_swimming.py
tool_type: python
... | promptflow/src/promptflow/tests/test_configs/flows/chat-with-assistant-no-file/assistant_definition.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/chat-with-assistant-no-file/assistant_definition.yaml",
"repo_id": "promptflow",
"token_count": 224
} | 60 |
id: template_standard_flow
name: Template Standard Flow
inputs:
incident_content:
type: string
incident_id:
type: int
outputs:
investigation_method:
type: string
reference: ${investigation_method.output}
nodes:
- name: incident_id_extractor
type: python
source:
type: code
path: inciden... | promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_activate/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 999
} | 61 |
inputs:
case:
type: string
default: double
is_chat_input: false
value:
type: int
default: 1
outputs:
output:
type: string
reference: ${collect_node.output}
evaluation_only: false
is_chat_output: false
nodes:
- name: double
type: python
source:
type: code
path: doubl... | promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_aggregate_bypassed/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/conditional_flow_with_aggregate_bypassed/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 426
} | 62 |
{"question": "What is 2 to the 10th power?"}
{"question": "What is the sum of 2 and 2?"} | promptflow/src/promptflow/tests/test_configs/flows/flow_with_langchain_traces/inputs.jsonl/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/flow_with_langchain_traces/inputs.jsonl",
"repo_id": "promptflow",
"token_count": 29
} | 63 |
inputs:
text:
type: string
outputs:
answer:
type: string
reference: ${echo_generator.output}
nodes:
- name: echo_generator
type: python
source:
type: code
path: echo.py
inputs:
text: ${inputs.text}
| promptflow/src/promptflow/tests/test_configs/flows/generator_nodes/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/generator_nodes/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 97
} | 64 |
inputs:
question:
type: string
chat_history:
type: list
stream:
type: bool
outputs:
answer:
type: string
reference: ${chat.output}
nodes:
- name: chat
type: python
source:
type: code
path: chat.py
inputs:
question: ${inputs.question}
chat_history: ${inputs.chat_history}... | promptflow/src/promptflow/tests/test_configs/flows/openai_chat_api_flow/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/openai_chat_api_flow/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 157
} | 65 |
from promptflow import tool
import sys
@tool
def print_inputs(
text: str = None,
):
print(f"STDOUT: {text}")
print(f"STDERR: {text}", file=sys.stderr)
return text
| promptflow/src/promptflow/tests/test_configs/flows/print_input_flow/print_input.py/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/print_input_flow/print_input.py",
"repo_id": "promptflow",
"token_count": 75
} | 66 |
from promptflow import tool
@tool
def my_python_tool_with_failed_line(idx: int, mod) -> int:
if idx % mod == 0:
raise Exception("Failed")
return idx | promptflow/src/promptflow/tests/test_configs/flows/python_tool_partial_failure/my_python_tool_with_failed_line.py/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_tool_partial_failure/my_python_tool_with_failed_line.py",
"repo_id": "promptflow",
"token_count": 66
} | 67 |
{"image": {"data:image/png;path":"logo_1.png"}}
{"image": {"data:image/png;path":"logo_2.png"}} | promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_simple_image/image_inputs/inputs.jsonl/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/python_tool_with_simple_image/image_inputs/inputs.jsonl",
"repo_id": "promptflow",
"token_count": 41
} | 68 |
inputs:
text:
type: string
outputs:
output:
type: string
reference: ${node1.output}
nodes:
- name: node1
type: python
source:
type: code
path: dummy_utils/main.py
inputs:
x: ${inputs.text}
| promptflow/src/promptflow/tests/test_configs/flows/script_with_import/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/script_with_import/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 97
} | 69 |
id: template_standard_flow
name: Template Standard Flow
inputs:
input:
type: string
is_chat_input: false
index:
type: int
is_chat_input: false
outputs:
output:
type: string
reference: ${python_node.output}
nodes:
- name: python_node
type: python
source:
type: code
path: python_... | promptflow/src/promptflow/tests/test_configs/flows/simple_flow_with_ten_inputs/flow.dag.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/simple_flow_with_ten_inputs/flow.dag.yaml",
"repo_id": "promptflow",
"token_count": 171
} | 70 |
[
{
"url": "https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h"
},
{
"url": "https://www.microsoft.com/en-us/windows/"
}
]
| promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/samples.json/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/samples.json",
"repo_id": "promptflow",
"token_count": 86
} | 71 |
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_basic_evaluation.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_basic_evaluation.yaml",
"repo_id": "promptflow",
"token_count": 88949
} | 72 |
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- promptflow-sdk/0.0.1 promptflow/0.0.1 azure-ai-ml/1.12.0 azsdk-python-mgmt-machinelearningservices/0.1.0
Python/... | promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_request_id_when_making_http_requests.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_request_id_when_making_http_requests.yaml",
"repo_id": "promptflow",
"token_count": 12048
} | 73 |
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_show_run.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/recordings/test_run_operations_TestFlowRun_test_show_run.yaml",
"repo_id": "promptflow",
"token_count": 89116
} | 74 |
flow: ../flows/flow_with_dict_input
data: ../datas/webClassification1.jsonl
column_mapping:
key:
val1: 1
val2: 2
url: ${data.url}
| promptflow/src/promptflow/tests/test_configs/runs/input_with_dict_val.yaml/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/runs/input_with_dict_val.yaml",
"repo_id": "promptflow",
"token_count": 70
} | 75 |
from promptflow import tool
@tool
def divide_num(num: int):
return UnserializableClass(num=(int)(num / 2))
class UnserializableClass:
def __init__(self, num: int):
self.num = num
def __str__(self):
return str(self.num) | promptflow/src/promptflow/tests/test_configs/wrong_flows/flow_output_unserializable/divide_num.py/0 | {
"file_path": "promptflow/src/promptflow/tests/test_configs/wrong_flows/flow_output_unserializable/divide_num.py",
"repo_id": "promptflow",
"token_count": 99
} | 76 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.