promptflow

Форк
0

README.md

Promptflow examples

code style: black license: MIT

Get started

Install dependencies

  • Bootstrap your python environment.
    • e.g: create a new conda environment. conda create -n pf-examples python=3.9.
    • install required packages in python environment : pip install -r requirements.txt
      • show installed sdk: pip show promptflow

Quick start

pathstatusdescription
quickstart.ipynbsamples_getstarted_quickstartA quickstart tutorial to run a flow and evaluate it.
quickstart-azure.ipynbsamples_getstarted_quickstartazureA quickstart tutorial to run a flow in Azure AI and evaluate it.

CLI examples

Tutorials (tutorials)

pathstatusdescription
chat-with-pdfsamples_tutorials_e2e_development_chat_with_pdfRetrieval Augmented Generation (or RAG) has become a prevalent pattern to build intelligent application with Large Language Models (or LLMs) since it can infuse external knowledge into the model, which is not trained with those up-to-date or proprietary information
azure-app-servicesamples_tutorials_flow_deploy_azure_app_serviceThis example demos how to deploy a flow using Azure App Service
create-service-with-flowsamples_tutorials_flow_deploy_create_service_with_flowThis example shows how to create a simple service with flow
distribute-flow-as-executable-appsamples_tutorials_flow_deploy_distribute_flow_as_executable_appThis example demos how to package flow as a executable app
dockersamples_tutorials_flow_deploy_dockerThis example demos how to deploy flow as a docker app
kubernetessamples_tutorials_flow_deploy_kubernetesThis example demos how to deploy flow as a Kubernetes app
promptflow-quality-improvementsamples_tutorials_flow_fine_tuning_evaluation_promptflow_quality_improvementThis tutorial is designed to enhance your understanding of improving flow quality through prompt tuning and evaluation
tracingsamples_tutorials_tracingPrompt flow provides the tracing feature to capture and visualize the internal execution details for all flows

Prompty (prompty)

pathstatusdescription
basicsamples_prompty_basicA basic prompt that uses the chat API to answer questions, with connection configured using environment variables
chat-basicsamples_prompty_chat_basicA prompt that uses the chat API to answer questions with chat history, leveraging promptflow connection
eval-apologysamples_prompty_eval_apologyA prompt that determines whether a chat conversation contains an apology from the assistant
eval-basicsamples_prompty_eval_basicBasic evaluator prompt for QA scenario
format-outputsamples_prompty_format_outputA few examples that demos different prompty response format like text, json_object, and how to enable stream output

Flex Flows (flex-flows)

pathstatusdescription
basicsamples_flex_flows_basicA basic standard flow define using function entry that calls Azure OpenAI with connection info stored in environment variables
chat-async-streamsamples_flex_flows_chat_async_streamA chat flow defined using async class entry that return output in stream mode
chat-basicsamples_flex_flows_chat_basicA basic chat flow defined using class entry
chat-minimalsamples_flex_flows_chat_minimalA chat flow defined using function with minimal code
chat-streamsamples_flex_flows_chat_streamA chat flow defined using class entry that return output in stream mode
chat-with-functionssamples_flex_flows_chat_with_functionsThis flow covers how to use the LLM chat API in combination with external functions to extend the capabilities of GPT models
eval-checklistsamples_flex_flows_eval_checklistA example flow defined using class entry which demos how to evaluate the answer pass user specified check list
eval-code-qualitysamples_flex_flows_eval_code_qualityA example flow defined using class based entry which leverages model config to evaluate the quality of code snippet
eval-criteria-with-langchainsamples_flex_flows_eval_criteria_with_langchainA example flow of converting LangChain criteria evaluator application to flex flow

Flows (flows)

Standard flows

pathstatusdescription
autonomous-agentsamples_flows_standard_autonomous_agentThis is a flow showcasing how to construct a AutoGPT agent with promptflow to autonomously figures out how to apply the given functions to solve the goal, which is film trivia that provides accurate and up-to-date information about movies, directors, actors, and more in this sample
basicsamples_flows_standard_basicA basic standard flow using custom python tool that calls Azure OpenAI with connection info stored in environment variables
basic-with-builtin-llmsamples_flows_standard_basic_with_builtin_llmA basic standard flow that calls Azure OpenAI with builtin llm tool
basic-with-connectionsamples_flows_standard_basic_with_connectionA basic standard flow that using custom python tool calls Azure OpenAI with connection info stored in custom connection
conditional-flow-for-if-elsesamples_flows_standard_conditional_flow_for_if_elseThis example is a conditional flow for if-else scenario
conditional-flow-for-switchsamples_flows_standard_conditional_flow_for_switchThis example is a conditional flow for switch scenario
customer-intent-extractionsamples_flows_standard_customer_intent_extractionThis sample is using OpenAI chat model(ChatGPT/GPT4) to identify customer intent from customer's question
describe-imagesamples_flows_standard_describe_imageA flow that take image input, flip it horizontally and uses OpenAI GPT-4V tool to describe it
flow-with-additional-includessamples_flows_standard_flow_with_additional_includesUser sometimes need to reference some common files or folders, this sample demos how to solve the problem using additional_includes
flow-with-symlinkssamples_flows_standard_flow_with_symlinksUser sometimes need to reference some common files or folders, this sample demos how to solve the problem using symlinks
gen-docstringsamples_flows_standard_gen_docstringThis example can help you automatically generate Python code's docstring and return the modified code
maths-to-codesamples_flows_standard_maths_to_codeMath to Code is a project that utilizes the power of the chatGPT model to generate code that models math questions and then executes the generated code to obtain the final numerical answer
named-entity-recognitionsamples_flows_standard_named_entity_recognitionA flow that perform named entity recognition task
question-simulationsamples_flows_standard_question_simulationThis question simulation flow is used to generate suggestions for the next question based on the previous chat history
web-classificationsamples_flows_standard_web_classificationThis is a flow demonstrating multi-class classification with LLM

Evaluation flows

pathstatusdescription
eval-basicsamples_flows_evaluation_eval_basicThis example shows how to create a basic evaluation flow
eval-chat-mathsamples_flows_evaluation_eval_chat_mathThis example shows how to evaluate the answer of math questions, which can compare the output results with the standard answers numerically
eval-classification-accuracysamples_flows_evaluation_eval_classification_accuracyThis is a flow illustrating how to evaluate the performance of a classification system
eval-entity-match-ratesamples_flows_evaluation_eval_entity_match_rateThis is a flow evaluates: entity match rate
eval-groundednesssamples_flows_evaluation_eval_groundednessThis is a flow leverage llm to eval groundedness: whether answer is stating facts that are all present in the given context
eval-multi-turn-metricssamples_flows_evaluation_eval_multi_turn_metricsThis evaluation flow will evaluate a conversation by using Large Language Models (LLM) to measure the quality of the responses
eval-perceived-intelligencesamples_flows_evaluation_eval_perceived_intelligenceThis is a flow leverage llm to eval perceived intelligence
eval-qna-non-ragsamples_flows_evaluation_eval_qna_non_ragThis is a flow evaluating the Q&A systems by leveraging Large Language Models (LLM) to measure the quality and safety of responses
eval-qna-rag-metricssamples_flows_evaluation_eval_qna_rag_metricsThis is a flow evaluating the Q&A RAG (Retrieval Augmented Generation) systems by leveraging the state-of-the-art Large Language Models (LLM) to measure the quality and safety of responses
eval-single-turn-metricssamples_flows_evaluation_eval_single_turn_metricsThis evaluation flow will evaluate a question and answer pair by using Large Language Models (LLM) to measure the quality of the answer
eval-summarizationsamples_flows_evaluation_eval_summarizationThis flow implements a reference-free automatic abstractive summarization evaluation across four dimensions: fluency, coherence, consistency, relevance

Chat flows

pathstatusdescription
chat-basicsamples_flows_chat_chat_basicThis example shows how to create a basic chat flow
chat-math-variantsamples_flows_chat_chat_math_variantThis is a prompt tuning case with 3 prompt variants for math question answering
chat-with-imagesamples_flows_chat_chat_with_imageThis flow demonstrates how to create a chatbot that can take image and text as input
chat-with-pdfsamples_flows_chat_chat_with_pdfThis is a simple flow that allow you to ask questions about the content of a PDF file and get answers
chat-with-wikipediasamples_flows_chat_chat_with_wikipediaThis flow demonstrates how to create a chatbot that can remember previous interactions and use the conversation history to generate next message
use_functions_with_chat_modelssamples_flows_chat_use_functions_with_chat_modelsThis flow covers how to use the LLM tool chat API in combination with external functions to extend the capabilities of GPT models

Tool Use Cases (Tool Use Cases)

pathstatusdescription
cascading-inputs-tool-showcasesamples_tools_use_cases_cascading_inputs_tool_showcaseThis is a flow demonstrating the use of a tool with cascading inputs which frequently used in situations where the selection in one input field determines what subsequent inputs should be shown, and it helps in creating a more efficient, user-friendly, and error-free input process
custom-strong-type-connection-package-tool-showcasesamples_tools_use_cases_custom_strong_type_connection_package_tool_showcaseThis is a flow demonstrating the use of a package tool with custom string type connection which provides a secure way to manage credentials for external APIs and data sources, and it offers an improved user-friendly and intellisense experience compared to custom connections
custom-strong-type-connection-script-tool-showcasesamples_tools_use_cases_custom_strong_type_connection_script_tool_showcaseThis is a flow demonstrating the use of a script tool with custom string type connection which provides a secure way to manage credentials for external APIs and data sources, and it offers an improved user-friendly and intellisense experience compared to custom connections
custom_llm_tool_showcasesamples_tools_use_cases_custom_llm_tool_showcaseThis is a flow demonstrating how to use a custom_llm tool, which enables users to seamlessly connect to a large language model with prompt tuning experience using a PromptTemplate
dynamic-list-input-tool-showcasesamples_tools_use_cases_dynamic_list_input_tool_showcaseThis is a flow demonstrating how to use a tool with a dynamic list input

Connections (connections)

pathstatusdescription
connectionssamples_connectionsThis folder contains example YAML files for creating connection using pf cli

SDK examples

pathstatusdescription
quickstart.ipynbsamples_getstarted_quickstartA quickstart tutorial to run a flow and evaluate it.
quickstart-azure.ipynbsamples_getstarted_quickstartazureA quickstart tutorial to run a flow in Azure AI and evaluate it.
flow-as-function.ipynbsamples_getstarted_flowasfunctionThis guide will walk you through the main scenarios of executing flow as a function.
pipeline.ipynbsamples_runflowwithpipeline_pipelineCreate pipeline using components to run a distributed job with tensorflow
cloud-run-management.ipynbsamples_runmanagement_cloudrunmanagementFlow run management in Azure AI
run-management.ipynbsamples_runmanagement_runmanagementFlow run management
trace-autogen-groupchat.ipynbsamples_tracing_autogengroupchat_traceautogengroupchatTracing LLM calls in autogen group chat application
otlp-trace-collector.ipynbsamples_tracing_customotlpcollector_otlptracecollectorA tutorial on how to levarage custom OTLP collector.
trace-langchain.ipynbsamples_tracing_langchain_tracelangchainTracing LLM calls in langchain application
trace-llm.ipynbsamples_tracing_llm_tracellmTracing LLM application
connection.ipynbsamples_connections_connectionManage various types of connections using sdk
flex-flow-quickstart-azure.ipynbsamples_flexflows_basic_flexflowquickstartazureA quickstart tutorial to run a flex flow and evaluate it in azure.
flex-flow-quickstart.ipynbsamples_flexflows_basic_flexflowquickstartA quickstart tutorial to run a flex flow and evaluate it.
chat-stream-with-async-flex-flow.ipynbsamples_flexflows_chatasyncstream_chatstreamwithasyncflexflowA quickstart tutorial to run a class based flex flow in stream mode and evaluate it.
chat-with-class-based-flow-azure.ipynbsamples_flexflows_chatbasic_chatwithclassbasedflowazureA quickstart tutorial to run a class based flex flow and evaluate it in azure.
chat-with-class-based-flow.ipynbsamples_flexflows_chatbasic_chatwithclassbasedflowA quickstart tutorial to run a class based flex flow and evaluate it.
chat-stream-with-flex-flow.ipynbsamples_flexflows_chatstream_chatstreamwithflexflowA quickstart tutorial to run a class based flex flow in stream mode and evaluate it.
langchain-eval.ipynbsamples_flexflows_evalcriteriawithlangchain_langchainevalA tutorial to converting LangChain criteria evaluator application to flex flow.
prompty-quickstart.ipynbsamples_prompty_basic_promptyquickstartA quickstart tutorial to run a prompty and evaluate it.
chat-with-prompty.ipynbsamples_prompty_chatbasic_chatwithpromptyA quickstart tutorial to run a chat prompty and evaluate it.
prompty-output-format.ipynbsamples_prompty_formatoutput_promptyoutputformat
chat-with-pdf-azure.ipynbsamples_flows_chat_chatwithpdf_chatwithpdfazureA tutorial of chat-with-pdf flow that executes in Azure AI
chat-with-pdf.ipynbsamples_flows_chat_chatwithpdf_chatwithpdfA tutorial of chat-with-pdf flow that allows user ask questions about the content of a PDF file and get answers

Contributing

We welcome contributions and suggestions! Please see the contributing guidelines for details.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. Please see the code of conduct for details.

Reference

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.