repo_id
stringlengths
15
132
file_path
stringlengths
34
176
content
stringlengths
2
3.52M
__index_level_0__
int64
0
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/prompt_tools/samples.json
[ { "text": "text_1" }, { "text": "text_2" }, { "text": "text_3" }, { "text": "text_4" } ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/script_with___file__.meta.json
{ "name": "script_with___file__", "type": "python", "inputs": { "input1": { "type": [ "string" ] } }, "source": "script_with___file__.py", "function": "my_python_tool" }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/script_with___file__.py
from pathlib import Path from promptflow import tool print(f"The script is {__file__}") assert Path(__file__).is_absolute(), f"__file__ should be absolute path, got {__file__}" @tool def my_python_tool(input1: str) -> str: from pathlib import Path assert Path(__file__).name == "script_with___file__.py" assert __name__ == "__pf_main__" print(f"Prompt: {input1} {__file__}") return f"Prompt: {input1} {__file__}"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/flow.dag.yaml
inputs: text: type: string outputs: output_prompt: type: string reference: ${node1.output} nodes: - name: node1 type: python source: type: code path: script_with___file__.py inputs: input1: ${inputs.text} - name: node2 type: python source: type: code path: folder/another-tool.py inputs: input1: ${node1.output} - name: node3 type: python source: type: code path: folder/another-tool.py inputs: input1: random value
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/samples.json
[ { "text": "text_1" }, { "text": "text_2" }, { "text": "text_3" }, { "text": "text_4" } ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/script_with___file__
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/script_with___file__/folder/another-tool.py
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__}"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/expected_metrics.json
{"accuracy": 0.67}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/aggregation_assert.py
from typing import List from promptflow import tool @tool def aggregation_assert(input1: List[str], input2: List[str]): assert isinstance(input1, list) assert isinstance(input2, list) assert len(input1) == len(input2)
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/calculate_accuracy.py
from typing import List from promptflow import log_metric, tool @tool def calculate_accuracy(grades: List[str], variant_ids: List[str]): aggregate_grades = {} for index in range(len(grades)): grade = grades[index] variant_id = variant_ids[index] if variant_id not in aggregate_grades.keys(): aggregate_grades[variant_id] = [] aggregate_grades[variant_id].append(grade) # calculate accuracy for each variant for name, values in aggregate_grades.items(): accuracy = round((values.count("Correct") / len(values)), 2) log_metric("accuracy", accuracy, variant_id=name) return aggregate_grades
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/expected_status_summary.json
{ "grade.completed": 3, "calculate_accuracy.completed": 1, "aggregation_assert.completed": 1 }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/grade.py
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"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/flow.dag.yaml
inputs: variant_id: type: string groundtruth: type: string description: Please specify the groundtruth column, which contains the true label to the outputs that your flow produces. prediction: type: string description: Please specify the prediction column, which contains the predicted outputs that your flow produces. outputs: grade: type: string reference: ${grade.output} nodes: - name: grade type: python source: type: code path: grade.py inputs: groundtruth: ${inputs.groundtruth} prediction: ${inputs.prediction} - name: calculate_accuracy type: python source: type: code path: calculate_accuracy.py inputs: grades: ${grade.output} variant_ids: ${inputs.variant_id} aggregation: true - name: aggregation_assert type: python source: type: code path: aggregation_assert.py inputs: input1: ${inputs.groundtruth} input2: ${inputs.prediction} aggregation: true
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/samples.json
[ { "line_number": 0, "variant_id": "variant_0", "groundtruth": "App", "prediction": "App" }, { "line_number": 1, "variant_id": "variant_0", "groundtruth": "Pdf", "prediction": "PDF" }, { "line_number": 2, "variant_id": "variant_0", "groundtruth": "App", "prediction": "Pdf" } ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/classification_accuracy_evaluation/.promptflow/flow.tools.json
{ "package": {}, "code": { "grade.py": { "type": "python", "inputs": { "groundtruth": { "type": [ "string" ] }, "prediction": { "type": [ "string" ] } }, "function": "grade" }, "calculate_accuracy.py": { "type": "python", "inputs": { "grades": { "type": [ "list" ] }, "variant_ids": { "type": [ "list" ] } }, "function": "calculate_accuracy" } } }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/classify_with_llm.jinja2
Your task is to classify a given url into one of the following types: Movie, App, Academic, Channel, Profile, PDF or None based on the text content information. The classification will be based on the url, the webpage text content summary, or both. Here are a few examples: {% for ex in examples %} URL: {{ex.url}} Text content: {{ex.text_content}} OUTPUT: {"category": "{{ex.category}}", "evidence": "{{ex.evidence}}"} {% endfor %} For a given URL : {{url}}, and text content: {{text_content}}. Classify above url to complete the category and indicate evidence. OUTPUT:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/fetch_text_content_from_url.py
import bs4 import requests from promptflow import tool @tool def fetch_text_content_from_url(url: str): # Send a request to the URL try: headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.35" } response = requests.get(url, headers=headers) if response.status_code == 200: # Parse the HTML content using BeautifulSoup soup = bs4.BeautifulSoup(response.text, "html.parser") soup.prettify() return soup.get_text()[:2000] else: msg = ( f"Get url failed with status code {response.status_code}.\nURL: {url}\nResponse: {response.text[:100]}" ) print(msg) return "No available content" except Exception as e: print("Get url failed with error: {}".format(e)) return "No available content"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/convert_to_dict.py
import json from promptflow import tool @tool def convert_to_dict(input_str: str): try: return json.loads(input_str) except Exception as e: print("input is not valid, error: {}".format(e)) return {"category": "None", "evidence": "None"}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/summarize_text_content__variant_1.jinja2
Please summarize some keywords of this paragraph and have some details of each keywords. Do not add any information that is not in the text. Text: {{text}} Summary:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/summarize_text_content.jinja2
Please summarize the following text in one paragraph. 100 words. Do not add any information that is not in the text. Text: {{text}} Summary:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/flow.dag.yaml
inputs: url: type: string default: https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h outputs: category: type: string reference: ${convert_to_dict.output.category} evidence: type: string reference: ${convert_to_dict.output.evidence} nodes: - name: convert_to_dict type: python source: type: code path: convert_to_dict.py inputs: input_str: ${classify_with_llm.output} - name: summarize_text_content type: llm source: type: code path: summarize_text_content__variant_1.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '256' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' text: ${fetch_text_content_from_url.output} provider: AzureOpenAI connection: azure_open_ai_connection api: completion module: promptflow.tools.aoai - name: classify_with_llm type: llm source: type: code path: classify_with_llm.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '128' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' url: ${inputs.url} examples: ${prepare_examples.output} text_content: ${summarize_text_content.output} provider: AzureOpenAI connection: azure_open_ai_connection api: completion - name: fetch_text_content_from_url type: python source: type: code path: fetch_text_content_from_url.py inputs: url: ${inputs.url} - name: prepare_examples type: python source: type: code path: prepare_examples.py inputs: {}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/prepare_examples.py
from promptflow import tool @tool def prepare_examples(): return [ { "url": "https://play.google.com/store/apps/details?id=com.spotify.music", "text_content": "Spotify is a free music and podcast streaming app with millions of songs, albums, and original podcasts. It also offers audiobooks, so users can enjoy thousands of stories. It has a variety of features such as creating and sharing music playlists, discovering new music, and listening to popular and exclusive podcasts. It also has a Premium subscription option which allows users to download and listen offline, and access ad-free music. It is available on all devices and has a variety of genres and artists to choose from.", "category": "App", "evidence": "Both", }, { "url": "https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw", "text_content": "NFL Sunday Ticket is a service offered by Google LLC that allows users to watch NFL games on YouTube. It is available in 2023 and is subject to the terms and privacy policy of Google LLC. It is also subject to YouTube's terms of use and any applicable laws.", "category": "Channel", "evidence": "URL", }, { "url": "https://arxiv.org/abs/2303.04671", "text_content": "Visual ChatGPT is a system that enables users to interact with ChatGPT by sending and receiving not only languages but also images, providing complex visual questions or visual editing instructions, and providing feedback and asking for corrected results. It incorporates different Visual Foundation Models and is publicly available. Experiments show that Visual ChatGPT opens the door to investigating the visual roles of ChatGPT with the help of Visual Foundation Models.", "category": "Academic", "evidence": "Text content", }, { "url": "https://ab.politiaromana.ro/", "text_content": "There is no content available for this text.", "category": "None", "evidence": "None", }, ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants_unordered/samples.json
[ { "line_number": 0, "variant_id": "variant_0", "groundtruth": "App", "prediction": "App" } ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/flow_with_requirements_txt/requirements.txt
langchain
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/flow_with_requirements_txt/flow.dag.yaml
inputs: key: type: string outputs: output: type: string reference: ${print_env.output.value} nodes: - name: print_env type: python source: type: code path: print_env.py inputs: key: ${inputs.key}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/flow_with_requirements_txt/print_env.py
import os from promptflow import tool @tool def get_env_var(key: str): from langchain import __version__ print(__version__) print(os.environ.get(key)) # get from env var return {"value": os.environ.get(key)}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/long_run/long_run.py
import time from promptflow import tool def f1(): time.sleep(61) return 0 def f2(): return f1() @tool def long_run_func(): return f2()
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/long_run/flow.dag.yaml
inputs: {} outputs: output: type: string reference: ${long_run_node.output} nodes: - name: long_run_node type: python inputs: {} source: type: code path: long_run.py
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/simple_flow_with_python_tool/divide_num.py
from promptflow import tool @tool def divide_num(num: int) -> int: return (int)(num / 2)
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/simple_flow_with_python_tool/flow.dag.yaml
inputs: num: type: int outputs: content: type: string reference: ${divide_num.output} nodes: - name: divide_num type: python source: type: code path: divide_num.py inputs: num: ${inputs.num}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/simple_flow_with_python_tool/inputs.jsonl
{"num": "hello"}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_with_additional_include/classify_with_llm.jinja2
system: Your task is to classify a given url into one of the following types: Movie, App, Academic, Channel, Profile, PDF or None based on the text content information. The classification will be based on the url, the webpage text content summary, or both. user: Here are a few examples: {% for ex in examples %} URL: {{ex.url}} Text content: {{ex.text_content}} OUTPUT: {"category": "{{ex.category}}", "evidence": "{{ex.evidence}}"} {% endfor %} For a given URL : {{url}}, and text content: {{text_content}}. Classify above url to complete the category and indicate evidence. OUTPUT:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_with_additional_include/summarize_text_content__variant_1.jinja2
system: Please summarize some keywords of this paragraph and have some details of each keywords. Do not add any information that is not in the text. user: Text: {{text}} Summary:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_with_additional_include/flow.dag.yaml
inputs: url: type: string default: https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h outputs: category: type: string reference: ${convert_to_dict.output.category} evidence: type: string reference: ${convert_to_dict.output.evidence} nodes: - name: fetch_text_content_from_url type: python source: type: code path: fetch_text_content_from_url.py inputs: url: ${inputs.url} - name: summarize_text_content type: llm source: type: code path: summarize_text_content.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '128' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' text: ${fetch_text_content_from_url.output} provider: AzureOpenAI connection: azure_open_ai_connection api: chat module: promptflow.tools.aoai use_variants: true - name: prepare_examples type: python source: type: code path: prepare_examples.py inputs: {} - name: classify_with_llm type: llm source: type: code path: classify_with_llm.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '128' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' url: ${inputs.url} examples: ${prepare_examples.output} text_content: ${summarize_text_content.output} provider: AzureOpenAI connection: azure_open_ai_connection api: chat module: promptflow.tools.aoai - name: convert_to_dict type: python source: type: code path: convert_to_dict.py inputs: input_str: ${classify_with_llm.output} node_variants: summarize_text_content: default_variant_id: variant_1 variants: variant_0: node: type: llm source: type: code path: summarize_text_content.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '128' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' text: ${fetch_text_content_from_url.output} provider: AzureOpenAI connection: azure_open_ai_connection api: chat module: promptflow.tools.aoai variant_1: node: type: llm source: type: code path: summarize_text_content__variant_1.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '256' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' text: ${fetch_text_content_from_url.output} provider: AzureOpenAI connection: azure_open_ai_connection api: chat module: promptflow.tools.aoai additional_includes: - ../external_files/convert_to_dict.py - ../external_files/fetch_text_content_from_url.py - ../external_files/summarize_text_content.jinja2 - ../external_files/summarize_text_content.jinja2 - ../external_files - ../external_files
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_with_additional_include/prepare_examples.py
from pathlib import Path from promptflow import tool # read file from additional includes lines = open(r"fetch_text_content_from_url.py", "r").readlines() @tool def prepare_examples(): if not Path("summarize_text_content.jinja2").exists(): raise Exception("Cannot find summarize_text_content.jinja2") return [ { "url": "https://play.google.com/store/apps/details?id=com.spotify.music", "text_content": "Spotify is a free music and podcast streaming app with millions of songs, albums, and original podcasts. It also offers audiobooks, so users can enjoy thousands of stories. It has a variety of features such as creating and sharing music playlists, discovering new music, and listening to popular and exclusive podcasts. It also has a Premium subscription option which allows users to download and listen offline, and access ad-free music. It is available on all devices and has a variety of genres and artists to choose from.", "category": "App", "evidence": "Both", }, { "url": "https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw", "text_content": "NFL Sunday Ticket is a service offered by Google LLC that allows users to watch NFL games on YouTube. It is available in 2023 and is subject to the terms and privacy policy of Google LLC. It is also subject to YouTube's terms of use and any applicable laws.", "category": "Channel", "evidence": "URL", }, { "url": "https://arxiv.org/abs/2303.04671", "text_content": "Visual ChatGPT is a system that enables users to interact with ChatGPT by sending and receiving not only languages but also images, providing complex visual questions or visual editing instructions, and providing feedback and asking for corrected results. It incorporates different Visual Foundation Models and is publicly available. Experiments show that Visual ChatGPT opens the door to investigating the visual roles of ChatGPT with the help of Visual Foundation Models.", "category": "Academic", "evidence": "Text content", }, { "url": "https://ab.politiaromana.ro/", "text_content": "There is no content available for this text.", "category": "None", "evidence": "None", }, ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_with_additional_include/samples.json
[ { "line_number": 0, "variant_id": "variant_0", "groundtruth": "App", "prediction": "App" } ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/all_nodes_bypassed/test.py
from promptflow import tool @tool def test(text: str): return text + "hello world!"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/all_nodes_bypassed/flow.dag.yaml
name: all_nodes_bypassed inputs: text: type: string outputs: result: type: string reference: ${third_node.output} nodes: - name: first_node type: python source: type: code path: test.py inputs: text: ${inputs.text} activate: when: ${inputs.text} is: "hello" - name: second_node type: python source: type: code path: test.py inputs: text: ${first_node.output} - name: third_node type: python source: type: code path: test.py inputs: text: ${second_node.output}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/all_nodes_bypassed/inputs.json
{ "text": "bypass" }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/print_secret_flow/print_secret.py
import os from promptflow import tool from promptflow.connections import CustomConnection @tool def print_secret(text: str, connection: CustomConnection): print(connection["key1"]) print(connection["key2"]) return text
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/print_secret_flow/flow.dag.yaml
inputs: key: type: string default: text outputs: output: type: string reference: ${print_secret.output} nodes: - name: print_secret type: python source: type: code path: print_secret.py inputs: connection: custom_connection text: ${inputs.key}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/classify_with_llm.jinja2
Your task is to classify a given url into one of the following types: Movie, App, Academic, Channel, Profile, PDF or None based on the text content information. The classification will be based on the url, the webpage text content summary, or both. Here are a few examples: {% for ex in examples %} URL: {{ex.url}} Text content: {{ex.text_content}} OUTPUT: {"category": "{{ex.category}}", "evidence": "{{ex.evidence}}"} {% endfor %} For a given URL : {{url}}, and text content: {{text_content}}. Classify above url to complete the category and indicate evidence. OUTPUT:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/fetch_text_content_from_url.py
import bs4 import requests from promptflow import tool @tool def fetch_text_content_from_url(url: str): # Send a request to the URL try: headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.35" } response = requests.get(url, headers=headers) if response.status_code == 200: # Parse the HTML content using BeautifulSoup soup = bs4.BeautifulSoup(response.text, "html.parser") soup.prettify() return soup.get_text()[:2000] else: msg = ( f"Get url failed with status code {response.status_code}.\nURL: {url}\nResponse: {response.text[:100]}" ) print(msg) return "No available content" except Exception as e: print("Get url failed with error: {}".format(e)) return "No available content"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/convert_to_dict.py
import json from promptflow import tool @tool def convert_to_dict(input_str: str): try: return json.loads(input_str) except Exception as e: print("input is not valid, error: {}".format(e)) return {"category": "None", "evidence": "None"}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/summarize_text_content__variant_1.jinja2
Please summarize some keywords of this paragraph and have some details of each keywords. Do not add any information that is not in the text. Text: {{text}} Summary:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/summarize_text_content.jinja2
Please summarize the following text in one paragraph. 100 words. Do not add any information that is not in the text. Text: {{text}} Summary:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/flow.dag.yaml
inputs: url: type: string default: https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h outputs: category: type: string reference: ${convert_to_dict.output.category} evidence: type: string reference: ${convert_to_dict.output.evidence} nodes: - name: fetch_text_content_from_url type: python source: type: code path: fetch_text_content_from_url.py inputs: url: ${inputs.url} - name: summarize_text_content type: llm source: type: code path: summarize_text_content.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '128' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' text: ${fetch_text_content_from_url.output} provider: AzureOpenAI connection: azure_open_ai_connection api: completion module: promptflow.tools.aoai use_variants: true - name: prepare_examples type: python source: type: code path: prepare_examples.py inputs: {} - name: classify_with_llm type: llm source: type: code path: classify_with_llm.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '128' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' url: ${inputs.url} examples: ${prepare_examples.output} text_content: ${summarize_text_content.output} provider: AzureOpenAI connection: azure_open_ai_connection api: completion module: promptflow.tools.aoai - name: convert_to_dict type: python source: type: code path: convert_to_dict.py inputs: input_str: ${classify_with_llm.output} node_variants: summarize_text_content: default_variant_id: variant_1 variants: variant_0: node: type: llm source: type: code path: summarize_text_content.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '128' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' text: ${fetch_text_content_from_url.output} provider: AzureOpenAI connection: azure_open_ai_connection api: completion module: promptflow.tools.aoai variant_1: node: type: llm source: type: code path: summarize_text_content__variant_1.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '256' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' text: ${fetch_text_content_from_url.output} provider: AzureOpenAI connection: azure_open_ai_connection api: completion module: promptflow.tools.aoai
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/prepare_examples.py
from promptflow import tool @tool def prepare_examples(): return [ { "url": "https://play.google.com/store/apps/details?id=com.spotify.music", "text_content": "Spotify is a free music and podcast streaming app with millions of songs, albums, and original podcasts. It also offers audiobooks, so users can enjoy thousands of stories. It has a variety of features such as creating and sharing music playlists, discovering new music, and listening to popular and exclusive podcasts. It also has a Premium subscription option which allows users to download and listen offline, and access ad-free music. It is available on all devices and has a variety of genres and artists to choose from.", "category": "App", "evidence": "Both", }, { "url": "https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw", "text_content": "NFL Sunday Ticket is a service offered by Google LLC that allows users to watch NFL games on YouTube. It is available in 2023 and is subject to the terms and privacy policy of Google LLC. It is also subject to YouTube's terms of use and any applicable laws.", "category": "Channel", "evidence": "URL", }, { "url": "https://arxiv.org/abs/2303.04671", "text_content": "Visual ChatGPT is a system that enables users to interact with ChatGPT by sending and receiving not only languages but also images, providing complex visual questions or visual editing instructions, and providing feedback and asking for corrected results. It incorporates different Visual Foundation Models and is publicly available. Experiments show that Visual ChatGPT opens the door to investigating the visual roles of ChatGPT with the help of Visual Foundation Models.", "category": "Academic", "evidence": "Text content", }, { "url": "https://ab.politiaromana.ro/", "text_content": "There is no content available for this text.", "category": "None", "evidence": "None", }, ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/samples.json
[ { "url": "https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h" }, { "url": "https://www.microsoft.com/en-us/windows/" } ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v1/.promptflow/flow.tools.json
{ "package": {}, "code": { "fetch_text_content_from_url.py": { "type": "python", "inputs": { "url": { "type": [ "string" ] } }, "function": "fetch_text_content_from_url" }, "summarize_text_content.jinja2": { "type": "llm", "inputs": { "text": { "type": [ "string" ] } }, "description": "Summarize webpage content into a short paragraph." }, "summarize_text_content__variant_1.jinja2": { "type": "llm", "inputs": { "text": { "type": [ "string" ] } } }, "prepare_examples.py": { "type": "python", "function": "prepare_examples" }, "classify_with_llm.jinja2": { "type": "llm", "inputs": { "url": { "type": [ "string" ] }, "examples": { "type": [ "string" ] }, "text_content": { "type": [ "string" ] } }, "description": "Multi-class classification of a given url and text content." }, "convert_to_dict.py": { "type": "python", "inputs": { "input_str": { "type": [ "string" ] } }, "function": "convert_to_dict" } } }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/saved_component_spec/parallel.yaml
creation_context: created_at: xxx created_by: xxx created_by_type: xxx last_modified_at: xxx last_modified_by: xxx last_modified_by_type: xxx description: Create flows that use large language models to classify URLs into multiple categories. display_name: web_classification_4 error_threshold: -1 id: azureml:/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.MachineLearningServices/workspaces/xxx/components/xxx/versions/xxx input_data: ${{inputs.data}} inputs: connections.classify_with_llm.connection: default: azure_open_ai_connection optional: true type: string connections.classify_with_llm.deployment_name: default: text-davinci-003 optional: true type: string connections.classify_with_llm.model: enum: - text-davinci-001 - text-davinci-002 - text-davinci-003 - text-curie-001 - text-babbage-001 - text-ada-001 - code-cushman-001 - code-davinci-002 optional: true type: string connections.summarize_text_content.connection: default: azure_open_ai_connection optional: true type: string connections.summarize_text_content.deployment_name: default: text-davinci-003 optional: true type: string connections.summarize_text_content.model: enum: - text-davinci-001 - text-davinci-002 - text-davinci-003 - text-curie-001 - text-babbage-001 - text-ada-001 - code-cushman-001 - code-davinci-002 optional: true type: string data: optional: false type: uri_folder run_outputs: optional: true type: uri_folder url: default: https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h optional: false type: string is_deterministic: true logging_level: INFO max_concurrency_per_instance: 1 mini_batch_error_threshold: 0 mini_batch_size: '1' name: web_classification_4 outputs: debug_info: type: uri_folder flow_outputs: type: uri_folder retry_settings: max_retries: 2 timeout: 3600 task: append_row_to: ${{outputs.flow_outputs}} code: /subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.MachineLearningServices/workspaces/xxx/codes/xxx/versions/xxx entry_script: driver/azureml_user/parallel_run/prompt_flow_entry.py environment: azureml:/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.MachineLearningServices/workspaces/xxx/environments/xxx/versions/xxx program_arguments: --amlbi_pf_enabled True --amlbi_pf_run_mode component --amlbi_mini_batch_rows 1 --amlbi_file_format jsonl $[[--amlbi_pf_run_outputs ${{inputs.run_outputs}}]] --amlbi_pf_debug_info ${{outputs.debug_info}} --amlbi_pf_connections "$[[classify_with_llm.connection=${{inputs.connections.classify_with_llm.connection}},]]$[[summarize_text_content.connection=${{inputs.connections.summarize_text_content.connection}},]]" --amlbi_pf_deployment_names "$[[classify_with_llm.deployment_name=${{inputs.connections.classify_with_llm.deployment_name}},]]$[[summarize_text_content.deployment_name=${{inputs.connections.summarize_text_content.deployment_name}},]]" --amlbi_pf_model_names "$[[classify_with_llm.model=${{inputs.connections.classify_with_llm.model}},]]$[[summarize_text_content.model=${{inputs.connections.summarize_text_content.model}},]]" --amlbi_pf_input_url ${{inputs.url}} type: run_function type: parallel version: 1.0.0
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/openai_completion_api_flow/completion.py
from openai.version import VERSION as OPENAI_VERSION import openai from promptflow import tool from promptflow.connections import AzureOpenAIConnection IS_LEGACY_OPENAI = OPENAI_VERSION.startswith("0.") def get_client(connection: AzureOpenAIConnection): api_key = connection.api_key conn = dict( api_key=connection.api_key, ) if api_key.startswith("sk-"): from openai import OpenAI as Client else: from openai import AzureOpenAI as Client conn.update( azure_endpoint=connection.api_base, api_version=connection.api_version, ) return Client(**conn) @tool def completion(connection: AzureOpenAIConnection, prompt: str, stream: bool) -> str: if IS_LEGACY_OPENAI: completion = openai.Completion.create( prompt=prompt, engine="text-ada-001", max_tokens=256, temperature=0.8, top_p=1.0, n=1, stream=stream, stop=None, **dict(connection), ) else: completion = get_client(connection).completions.create( prompt=prompt, model="text-ada-001", max_tokens=256, temperature=0.8, top_p=1.0, n=1, stream=stream, stop=None, ) if stream: def generator(): for chunk in completion: if chunk.choices: if IS_LEGACY_OPENAI: yield getattr(chunk.choices[0], "text", "") else: yield chunk.choices[0].text or "" return "".join(generator()) else: if IS_LEGACY_OPENAI: return getattr(completion.choices[0], "text", "") else: return completion.choices[0].text or ""
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/openai_completion_api_flow/flow.dag.yaml
inputs: prompt: type: string stream: type: bool outputs: output: type: string reference: ${completion.output} nodes: - name: completion type: python source: type: code path: completion.py inputs: prompt: ${inputs.prompt} connection: azure_open_ai_connection stream: ${inputs.stream}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/openai_completion_api_flow/inputs.jsonl
{"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}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/openai_completion_api_flow/samples.json
{ "prompt": "What is the capital of the United States of America?" }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_python_node_streaming_output/stream.py
from promptflow import tool from typing import Generator, List def stream(question: str) -> Generator[str, None, None]: for word in question: yield word @tool def my_python_tool(chat_history: List[dict], question: str) -> dict: return {"answer": stream(question)}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_python_node_streaming_output/flow.dag.yaml
inputs: chat_history: type: list is_chat_history: true question: type: string is_chat_input: true outputs: answer: type: string reference: ${stream.output.answer} is_chat_output: true nodes: - name: stream type: python source: type: code path: stream.py inputs: chat_history: ${inputs.chat_history} question: ${inputs.question}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/llm_tool/echo.py
from promptflow import tool @tool def echo(input: str) -> str: return input
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/llm_tool/joke.jinja2
{# Prompt is a jinja2 template that generates prompt for LLM #} system: You are a bot can tell good jokes user: A joke about {{topic}} please
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/llm_tool/flow.dag.yaml
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: ${joke.output} use_variants: false - name: joke type: llm source: type: code path: joke.jinja2 inputs: deployment_name: gpt-35-turbo temperature: 1 top_p: 1 max_tokens: 256 presence_penalty: 0 frequency_penalty: 0 stream: ${inputs.stream} topic: ${inputs.topic} provider: AzureOpenAI connection: azure_open_ai_connection api: chat module: promptflow.tools.aoai use_variants: false
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/script_tool_with_init/flow.dag.yaml
inputs: input: type: string default: World outputs: output: type: string reference: ${script_tool_with_init.output} nodes: - name: script_tool_with_init type: python source: type: code path: script_tool_with_init.py inputs: init_input: Hello input: ${inputs.input}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/script_tool_with_init/script_tool_with_init.py
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])
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/classify_with_llm.jinja2
system: Your task is to classify a given url into one of the following types: Movie, App, Academic, Channel, Profile, PDF or None based on the text content information. The classification will be based on the url, the webpage text content summary, or both. user: Here are a few examples: {% for ex in examples %} URL: {{ex.url}} Text content: {{ex.text_content}} OUTPUT: {"category": "{{ex.category}}", "evidence": "{{ex.evidence}}"} {% endfor %} For a given URL : {{url}}, and text content: {{text_content}}. Classify above url to complete the category and indicate evidence. OUTPUT:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/fetch_text_content_from_url.py
import bs4 import requests from promptflow import tool @tool def fetch_text_content_from_url(url: str): # Send a request to the URL try: headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.35" } response = requests.get(url, headers=headers) if response.status_code == 200: # Parse the HTML content using BeautifulSoup soup = bs4.BeautifulSoup(response.text, "html.parser") soup.prettify() return soup.get_text()[:2000] else: msg = ( f"Get url failed with status code {response.status_code}.\nURL: {url}\nResponse: {response.text[:100]}" ) print(msg) return "No available content" except Exception as e: print("Get url failed with error: {}".format(e)) return "No available content"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/convert_to_dict.py
import json from promptflow import tool @tool def convert_to_dict(input_str: str): try: return json.loads(input_str) except Exception as e: print("input is not valid, error: {}".format(e)) return {"category": "None", "evidence": "None"}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/summarize_text_content__variant_1.jinja2
system: Please summarize some keywords of this paragraph and have some details of each keywords. Do not add any information that is not in the text. user: Text: {{text}} Summary:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/summarize_text_content.jinja2
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:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/flow.dag.yaml
inputs: url: type: string default: https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h outputs: category: type: string reference: ${convert_to_dict.output.category} evidence: type: string reference: ${convert_to_dict.output.evidence} nodes: - name: fetch_text_content_from_url type: python source: type: code path: fetch_text_content_from_url.py inputs: url: ${inputs.url} - name: summarize_text_content type: llm source: type: code path: summarize_text_content__variant_1.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '256' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' text: ${fetch_text_content_from_url.output} provider: AzureOpenAI connection: azure_open_ai_connection api: chat module: promptflow.tools.aoai - name: prepare_examples type: python source: type: code path: prepare_examples.py inputs: {} - name: classify_with_llm type: llm source: type: code path: classify_with_llm.jinja2 inputs: deployment_name: gpt-35-turbo suffix: '' max_tokens: '128' temperature: '0.2' top_p: '1.0' logprobs: '' echo: 'False' stop: '' presence_penalty: '0' frequency_penalty: '0' best_of: '1' logit_bias: '' url: ${inputs.url} examples: ${prepare_examples.output} text_content: ${summarize_text_content.output} provider: AzureOpenAI connection: azure_open_ai_connection api: chat module: promptflow.tools.aoai - name: convert_to_dict type: python source: type: code path: convert_to_dict.py inputs: input_str: ${classify_with_llm.output}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/prepare_examples.py
from promptflow import tool @tool def prepare_examples(): return [ { "url": "https://play.google.com/store/apps/details?id=com.spotify.music", "text_content": "Spotify is a free music and podcast streaming app with millions of songs, albums, and original podcasts. It also offers audiobooks, so users can enjoy thousands of stories. It has a variety of features such as creating and sharing music playlists, discovering new music, and listening to popular and exclusive podcasts. It also has a Premium subscription option which allows users to download and listen offline, and access ad-free music. It is available on all devices and has a variety of genres and artists to choose from.", "category": "App", "evidence": "Both", }, { "url": "https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw", "text_content": "NFL Sunday Ticket is a service offered by Google LLC that allows users to watch NFL games on YouTube. It is available in 2023 and is subject to the terms and privacy policy of Google LLC. It is also subject to YouTube's terms of use and any applicable laws.", "category": "Channel", "evidence": "URL", }, { "url": "https://arxiv.org/abs/2303.04671", "text_content": "Visual ChatGPT is a system that enables users to interact with ChatGPT by sending and receiving not only languages but also images, providing complex visual questions or visual editing instructions, and providing feedback and asking for corrected results. It incorporates different Visual Foundation Models and is publicly available. Experiments show that Visual ChatGPT opens the door to investigating the visual roles of ChatGPT with the help of Visual Foundation Models.", "category": "Academic", "evidence": "Text content", }, { "url": "https://ab.politiaromana.ro/", "text_content": "There is no content available for this text.", "category": "None", "evidence": "None", }, ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/samples.json
[ { "url": "https://www.microsoft.com/en-us/d/xbox-wireless-controller-stellar-shift-special-edition/94fbjc7h0h6h" }, { "url": "https://www.microsoft.com/en-us/windows/" } ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/flow.tools.json
{ "package": {}, "code": { "fetch_text_content_from_url.py": { "type": "python", "inputs": { "url": { "type": [ "string" ] } }, "function": "fetch_text_content_from_url" }, "summarize_text_content.jinja2": { "type": "llm", "inputs": { "text": { "type": [ "string" ] } }, "description": "Summarize webpage content into a short paragraph." }, "summarize_text_content__variant_1.jinja2": { "type": "llm", "inputs": { "text": { "type": [ "string" ] } } }, "prepare_examples.py": { "type": "python", "function": "prepare_examples" }, "classify_with_llm.jinja2": { "type": "llm", "inputs": { "url": { "type": [ "string" ] }, "examples": { "type": [ "string" ] }, "text_content": { "type": [ "string" ] } }, "description": "Multi-class classification of a given url and text content." }, "convert_to_dict.py": { "type": "python", "inputs": { "input_str": { "type": [ "string" ] } }, "function": "convert_to_dict" } } }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/flow.env_files/setup.sh
#!/bin/bash # Install your packages here.
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/lkg_sources/classify_with_llm.jinja2
Your task is to classify a given url into one of the following types: Movie, App, Academic, Channel, Profile, PDF or None based on the text content information. The classification will be based on the url, the webpage text content summary, or both. Here are a few examples: {% for ex in examples %} URL: {{ex.url}} Text content: {{ex.text_content}} OUTPUT: {"category": "{{ex.category}}", "evidence": "{{ex.evidence}}"} {% endfor %} For a given URL : {{url}}, and text content: {{text_content}}. Classify above url to complete the category and indicate evidence. OUTPUT:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/lkg_sources/fetch_text_content_from_url.py
import bs4 import requests from promptflow import tool @tool def fetch_text_content_from_url(url: str): # Send a request to the URL try: headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.35" } response = requests.get(url, headers=headers) if response.status_code == 200: # Parse the HTML content using BeautifulSoup soup = bs4.BeautifulSoup(response.text, "html.parser") soup.prettify() return soup.get_text()[:2000] else: msg = ( f"Get url failed with status code {response.status_code}.\nURL: {url}\nResponse: {response.text[:100]}" ) print(msg) return "No available content" except Exception as e: print("Get url failed with error: {}".format(e)) return "No available content"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/lkg_sources/convert_to_dict.py
import json from promptflow import tool @tool def convert_to_dict(input_str: str): try: return json.loads(input_str) except Exception as e: print("input is not valid, error: {}".format(e)) return {"category": "None", "evidence": "None"}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/lkg_sources/summarize_text_content__variant_1.jinja2
Please summarize some keywords of this paragraph and have some details of each keywords. Do not add any information that is not in the text. Text: {{text}} Summary:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/lkg_sources/summarize_text_content.jinja2
Please summarize the following text in one paragraph. 100 words. Do not add any information that is not in the text. Text: {{text}} Summary:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_no_variants/.promptflow/lkg_sources/prepare_examples.py
from promptflow import tool @tool def prepare_examples(): return [ { "url": "https://play.google.com/store/apps/details?id=com.spotify.music", "text_content": "Spotify is a free music and podcast streaming app with millions of songs, albums, and original podcasts. It also offers audiobooks, so users can enjoy thousands of stories. It has a variety of features such as creating and sharing music playlists, discovering new music, and listening to popular and exclusive podcasts. It also has a Premium subscription option which allows users to download and listen offline, and access ad-free music. It is available on all devices and has a variety of genres and artists to choose from.", "category": "App", "evidence": "Both", }, { "url": "https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw", "text_content": "NFL Sunday Ticket is a service offered by Google LLC that allows users to watch NFL games on YouTube. It is available in 2023 and is subject to the terms and privacy policy of Google LLC. It is also subject to YouTube's terms of use and any applicable laws.", "category": "Channel", "evidence": "URL", }, { "url": "https://arxiv.org/abs/2303.04671", "text_content": "Visual ChatGPT is a system that enables users to interact with ChatGPT by sending and receiving not only languages but also images, providing complex visual questions or visual editing instructions, and providing feedback and asking for corrected results. It incorporates different Visual Foundation Models and is publicly available. Experiments show that Visual ChatGPT opens the door to investigating the visual roles of ChatGPT with the help of Visual Foundation Models.", "category": "Academic", "evidence": "Text content", }, { "url": "https://ab.politiaromana.ro/", "text_content": "There is no content available for this text.", "category": "None", "evidence": "None", }, ]
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/activate_flow/print_input.py
from promptflow import tool @tool def print_input(input: str) -> str: return input
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/activate_flow/flow.dag.yaml
inputs: text: type: string default: world outputs: output1: type: string reference: ${nodeC.output} output2: type: string reference: ${nodeD.output} nodes: - name: nodeA type: python source: type: code path: print_input.py inputs: input: ${inputs.text} activate: when: ${inputs.text} is: hello - name: nodeB type: python source: type: code path: print_input.py inputs: input: ${inputs.text} activate: when: ${nodeA.output} is: hello - name: nodeC type: python source: type: code path: print_input.py inputs: input: ${nodeB.output} - name: nodeD type: python source: type: code path: print_input.py inputs: input: ${inputs.text} activate: when: ${inputs.text} is: world
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/hello-world/hello_world.py
from promptflow import tool @tool def hello_world(name: str) -> str: return f"Hello World {name}!"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/hello-world/flow.dag.yaml
inputs: name: type: string default: hod outputs: result: type: string reference: ${hello_world.output} nodes: - name: hello_world type: python source: type: code path: hello_world.py inputs: name: ${inputs.name}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/hello-world
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/hello-world/.promptflow/flow.tools.json
{ "code": { "hello_world.py": { "type": "python", "inputs": { "name": { "type": [ "string" ] } }, "source": "hello_world.py", "function": "hello_world" } }, "package": { "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" ] }, "deployment_name": { "type": [ "string" ], "enabled_by": "connection", "enabled_by_type": [ "AzureOpenAIConnection" ], "capabilities": { "completion": false, "chat_completion": false, "embeddings": true }, "model_list": [ "text-embedding-ada-002", "text-search-ada-doc-001", "text-search-ada-query-001" ] }, "model": { "type": [ "string" ], "enabled_by": "connection", "enabled_by_type": [ "OpenAIConnection" ], "enum": [ "text-embedding-ada-002", "text-search-ada-doc-001", "text-search-ada-query-001" ] }, "input": { "type": [ "string" ] } }, "package": "promptflow-tools", "package_version": "0.1.0b5" }, "promptflow.tools.serpapi.SerpAPI.search": { "name": "Serp API", "description": "Use Serp API to obtain search results from a specific search engine.", "inputs": { "connection": { "type": [ "SerpConnection" ] }, "engine": { "default": "google", "enum": [ "google", "bing" ], "type": [ "string" ] }, "location": { "default": "", "type": [ "string" ] }, "num": { "default": "10", "type": [ "int" ] }, "query": { "type": [ "string" ] }, "safe": { "default": "off", "enum": [ "active", "off" ], "type": [ "string" ] } }, "type": "python", "module": "promptflow.tools.serpapi", "class_name": "SerpAPI", "function": "search", "package": "promptflow-tools", "package_version": "0.1.0b5" }, "my_tool_package.tools.my_tool_1.my_tool": { "function": "my_tool", "inputs": { "connection": { "type": [ "CustomConnection" ], "custom_type": [ "MyFirstConnection", "MySecondConnection" ] }, "input_text": { "type": [ "string" ] } }, "module": "my_tool_package.tools.my_tool_1", "name": "My First Tool", "description": "This is my first tool", "type": "python", "package": "test-custom-tools", "package_version": "0.0.2" }, "my_tool_package.tools.my_tool_2.MyTool.my_tool": { "class_name": "MyTool", "function": "my_tool", "inputs": { "connection": { "type": [ "CustomConnection" ], "custom_type": [ "MySecondConnection" ] }, "input_text": { "type": [ "string" ] } }, "module": "my_tool_package.tools.my_tool_2", "name": "My Second Tool", "description": "This is my second tool", "type": "python", "package": "test-custom-tools", "package_version": "0.0.2" }, "my_tool_package.tools.my_tool_with_custom_strong_type_connection.my_tool": { "function": "my_tool", "inputs": { "connection": { "custom_type": [ "MyCustomConnection" ], "type": [ "CustomConnection" ] }, "input_param": { "type": [ "string" ] } }, "module": "my_tool_package.tools.my_tool_with_custom_strong_type_connection", "name": "Tool With Custom Strong Type Connection", "description": "This is my tool with custom strong type connection.", "type": "python", "package": "test-custom-tools", "package_version": "0.0.2" } } }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/generator_nodes/echo.py
from promptflow import tool @tool def echo(text): """yield the input string.""" echo_text = "Echo - " + text for word in echo_text.split(): yield word
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/generator_nodes/flow.dag.yaml
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}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/async_tools_failures/async_fail.py
from promptflow import tool async def raise_exception_async(s): msg = f"In raise_exception_async: {s}" raise Exception(msg) @tool async def raise_an_exception_async(s: str): try: await raise_exception_async(s) except Exception as e: raise Exception(f"In tool raise_an_exception_async: {s}") from e
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/async_tools_failures/flow.dag.yaml
inputs: text: type: string default: dummy_input outputs: output_prompt: type: string reference: ${async_fail.output} nodes: - name: async_fail type: python source: type: code path: async_fail.py inputs: s: ${inputs.text}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/flow_with_additional_include_req/flow.dag.yaml
inputs: key: type: string outputs: output: type: string reference: ${print_env.output.value} nodes: - name: print_env type: python source: type: code path: print_env.py inputs: key: ${inputs.key} additional_includes: - ../flow_with_environment/requirements environment: python_requirements_txt: requirements
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/flow_with_additional_include_req/print_env.py
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)}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_default_history/chat.jinja2
system: You are a helpful assistant. {% for item in chat_history %} user: {{item.inputs.question}} assistant: {{item.outputs.answer}} {% endfor %} user: {{question}}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_default_history/flow.dag.yaml
inputs: chat_history: type: list is_chat_history: true default: - inputs: question: hi outputs: answer: hi - inputs: question: who are you outputs: answer: who are you question: type: string is_chat_input: true default: What is ChatGPT? outputs: answer: type: string reference: ${chat_node.output} is_chat_output: true nodes: - inputs: deployment_name: gpt-35-turbo max_tokens: "256" temperature: "0.7" chat_history: ${inputs.chat_history} question: ${inputs.question} name: chat_node type: llm source: type: code path: chat.jinja2 api: chat provider: AzureOpenAI connection: azure_open_ai_connection
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_image/mock_chat.py
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_list(item["outputs"]["answer"], "outputs of chat history") res = [] for item in question: if isinstance(item, Image): res.append(item) res.append("text response") return res def ensure_image_in_list(value: list, name: str): include_image = False for item in value: if isinstance(item, Image): include_image = True if not include_image: raise Exception(f"No image found in {name}, you should include at least one image in your {name}.")
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_image/flow.dag.yaml
inputs: chat_history: type: list default: - inputs: question: - the first question - data:image/jpg;path: logo.jpg outputs: answer: - data:image/jpg;path: logo.jpg - inputs: question: - the second question - data:image/png;path: logo_2.png outputs: answer: - data:image/png;path: logo_2.png is_chat_history: true question: type: list default: - the third question - data:image/jpg;path: logo.jpg - data:image/png;path: logo_2.png is_chat_input: true outputs: answer: type: string reference: ${mock_chat_node.output} is_chat_output: true nodes: - name: mock_chat_node type: python source: type: code path: mock_chat.py inputs: chat_history: ${inputs.chat_history} question: ${inputs.question}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/chat_flow_with_image/inputs.jsonl
{"chat_history":[{"inputs": {"question": ["the first question",{"data:image/jpg;path": "logo.jpg"}]},"outputs": {"answer": [{"data:image/jpg;path": "logo.jpg"}]}},{"inputs": {"question": ["the second question",{"data:image/png;path": "logo_2.png"}]},"outputs": {"answer": [{"data:image/png;path": "logo_2.png"}]}}],"question": ["the third question",{"data:image/jpg;path": "logo.jpg"},{"data:image/png;path": "logo_2.png"}]} {"chat_history":[{"inputs": {"question": ["the first question",{"data:image/jpg;path": "logo.jpg"}]},"outputs": {"answer": [{"data:image/jpg;path": "logo.jpg"}]}},{"inputs": {"question": ["the second question",{"data:image/png;path": "logo_2.png"}]},"outputs": {"answer": [{"data:image/png;path": "logo_2.png"}]}}],"question": ["the third question",{"data:image/jpg;path": "logo.jpg"},{"data:image/png;path": "logo_2.png"}]}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/llm_connection_override/conn_tool.py
from promptflow import tool from promptflow.connections import AzureOpenAIConnection @tool def conn_tool(conn: AzureOpenAIConnection): assert isinstance(conn, AzureOpenAIConnection) return conn.api_base
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/llm_connection_override/connection_arm_template.json
{ "id": "/subscriptions/xxxx/resourceGroups/xxx/providers/Microsoft.MachineLearningServices/workspaces/xxx/connections/azure_open_ai_connection", "name": "azure_open_ai_connection", "type": "Microsoft.MachineLearningServices/workspaces/connections", "properties": { "authType": "ApiKey", "credentials": { "key": "api_key" }, "category": "AzureOpenAI", "expiryTime": null, "target": "api_base", "createdByWorkspaceArmId": null, "isSharedToAll": false, "sharedUserList": [], "metadata": { "azureml.flow.connection_type": "AzureOpenAI", "azureml.flow.module": "promptflow.connections", "ApiType": "azure", "ApiVersion": "2023-03-15-preview" } }, "systemData": { "createdAt": "2023-06-14T09:40:51.1117116Z", "createdBy": "[email protected]", "createdByType": "User", "lastModifiedAt": "2023-06-14T09:40:51.1117116Z", "lastModifiedBy": "[email protected]", "lastModifiedByType": "User" } }
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/llm_connection_override/flow.dag.yaml
inputs: {} outputs: output: type: string reference: ${conn_node.output} nodes: - name: conn_node type: python source: type: code path: conn_tool.py inputs: conn: aoai connection
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v2/classify_with_llm.jinja2
Your task is to classify a given url into one of the following types: Movie, App, Academic, Channel, Profile, PDF or None based on the text content information. The classification will be based on the url, the webpage text content summary, or both. Here are a few examples: {% for ex in examples %} URL: {{ex.url}} Text content: {{ex.text_content}} OUTPUT: {"category": "{{ex.category}}", "evidence": "{{ex.evidence}}"} {% endfor %} For a given URL : {{url}}, and text content: {{text_content}}. Classify above url to complete the category and indicate evidence. OUTPUT:
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v2/fetch_text_content_from_url.py
import bs4 import requests from promptflow import tool @tool def fetch_text_content_from_url(url: str): # Send a request to the URL try: headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.35" } response = requests.get(url, headers=headers) if response.status_code == 200: # Parse the HTML content using BeautifulSoup soup = bs4.BeautifulSoup(response.text, "html.parser") soup.prettify() return soup.get_text()[:2000] else: msg = ( f"Get url failed with status code {response.status_code}.\nURL: {url}\nResponse: {response.text[:100]}" ) print(msg) return "No available content" except Exception as e: print("Get url failed with error: {}".format(e)) return "No available content"
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v2/convert_to_dict.py
import json from promptflow import tool @tool def convert_to_dict(input_str: str): try: return json.loads(input_str) except Exception as e: print("input is not valid, error: {}".format(e)) return {"category": "None", "evidence": "None"}
0
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows
promptflow_repo/promptflow/src/promptflow/tests/test_configs/flows/web_classification_v2/summarize_text_content__variant_1.jinja2
Please summarize some keywords of this paragraph and have some details of each keywords. Do not add any information that is not in the text. Text: {{text}} Summary:
0