diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 302b2f1..6078d7b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,4 +13,4 @@ repos: rev: 24.2.0 hooks: - id: black -exclude: 'generated/.*|artifacts/.*|.jsonl|.csv' +exclude: 'generated/.*|artifacts/.*|.jsonl|.csv|.json' diff --git a/apps/11_promptflow/README.md b/apps/11_promptflow/README.md index 4a30f58..ebedecf 100644 --- a/apps/11_promptflow/README.md +++ b/apps/11_promptflow/README.md @@ -203,6 +203,32 @@ $ pf run create \ $ pf run show-details --name $RUN_NAME ``` +### chat-math-variant + +Tuning prompts using `variants` is a powerful feature in Prompt flow. It allows you to test different prompts and see which one works best for your use case. + +Prompt flow repository provides an example of a chat flow with math variants at [examples/flows/chat/chat-math-variant](https://github.com/microsoft/promptflow/tree/main/examples/flows/chat/chat-math-variant). + +To understand how to use variants, you can refer to the [How-to Guides > Tune prompts using variants](https://microsoft.github.io/promptflow/how-to-guides/tune-prompts-with-variants.html) document. + +```shell +cd apps/11_promptflow/chat-math-variant + +# Create run with multiple lines data with variant +$ RUN_NAME=chat-math-variant-$(date +%s) +$ VARIANT='${chat.variant_0}' +$ pf run create \ + --name $RUN_NAME \ + --flow . \ + --data ./data.jsonl \ + --column-mapping question='${data.question}' \ + --variant $VARIANT \ + --stream + +# Show run details +$ pf run show-details --name $RUN_NAME +``` + ## References - [Prompt flow > repos](https://github.com/microsoft/promptflow) diff --git a/apps/11_promptflow/chat-math-variant/.gitignore b/apps/11_promptflow/chat-math-variant/.gitignore new file mode 100644 index 0000000..61bd725 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/.gitignore @@ -0,0 +1,5 @@ +.env +__pycache__/ +.promptflow/* +!.promptflow/flow.tools.json +.runs/ diff --git a/apps/11_promptflow/chat-math-variant/.promptflow/flow.tools.json b/apps/11_promptflow/chat-math-variant/.promptflow/flow.tools.json new file mode 100644 index 0000000..74f6d91 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/.promptflow/flow.tools.json @@ -0,0 +1,65 @@ +{ + "package": {}, + "code": { + "chat.jinja2": { + "type": "llm", + "inputs": { + "chat_history": { + "type": [ + "string" + ] + }, + "question": { + "type": [ + "string" + ] + } + }, + "source": "chat.jinja2" + }, + "chat_variant_1.jinja2": { + "type": "llm", + "inputs": { + "chat_history": { + "type": [ + "string" + ] + }, + "question": { + "type": [ + "string" + ] + } + }, + "source": "chat_variant_1.jinja2" + }, + "chat_variant_2.jinja2": { + "type": "llm", + "inputs": { + "chat_history": { + "type": [ + "string" + ] + }, + "question": { + "type": [ + "string" + ] + } + }, + "source": "chat_variant_2.jinja2" + }, + "extract_result.py": { + "type": "python", + "inputs": { + "input1": { + "type": [ + "string" + ] + } + }, + "source": "extract_result.py", + "function": "my_python_tool" + } + } +} \ No newline at end of file diff --git a/apps/11_promptflow/chat-math-variant/README.md b/apps/11_promptflow/chat-math-variant/README.md new file mode 100644 index 0000000..5caac37 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/README.md @@ -0,0 +1,48 @@ +# Test your prompt variants for chat with math +This is a prompt tuning case with 3 prompt variants for math question answering. + +By utilizing this flow, in conjunction with the `evaluation/eval-chat-math` flow, you can quickly grasp the advantages of prompt tuning and experimentation with prompt flow. Here we provide a [video](https://www.youtube.com/watch?v=gcIe6nk2gA4) and a [tutorial]((../../../tutorials/flow-fine-tuning-evaluation/promptflow-quality-improvement.md)) for you to get started. + +Tools used in this flow: +- `llm` tool +- custom `python` Tool + +## Prerequisites + +Install promptflow sdk and other dependencies in this folder: +```bash +pip install -r requirements.txt +``` + +## Getting started + +### 1 Create connection for LLM tool to use +Go to "Prompt flow" "Connections" tab. Click on "Create" button, select one of LLM tool supported connection types and fill in the configurations. + +Currently, there are two connection types supported by LLM tool: "AzureOpenAI" and "OpenAI". If you want to use "AzureOpenAI" connection type, you need to create an Azure OpenAI service first. Please refer to [Azure OpenAI Service](https://azure.microsoft.com/en-us/products/cognitive-services/openai-service/) for more details. If you want to use "OpenAI" connection type, you need to create an OpenAI account first. Please refer to [OpenAI](https://platform.openai.com/) for more details. + +```bash +# Override keys with --set to avoid yaml file changes +pf connection create --file ../../../connections/azure_openai.yml --set api_key= api_base= --name open_ai_connection +``` + +Note in [flow.dag.yaml](flow.dag.yaml) we are using connection named `open_ai_connection`. +```bash +# show registered connection +pf connection show --name open_ai_connection +``` + +### 2 Start chatting + +```bash +# run chat flow with default question in flow.dag.yaml +pf flow test --flow . + +# run chat flow with new question +pf flow test --flow . --inputs question="2+5=?" + +# start a interactive chat session in CLI +pf flow test --flow . --interactive + +# start a interactive chat session in CLI with verbose info +pf flow test --flow . --interactive --verbose diff --git a/apps/11_promptflow/chat-math-variant/chat.jinja2 b/apps/11_promptflow/chat-math-variant/chat.jinja2 new file mode 100644 index 0000000..99ccef4 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/chat.jinja2 @@ -0,0 +1,13 @@ +# system: +You are an assistant to calculate the answer to the provided math problems. +Please return the final numerical answer only, without any accompanying reasoning or explanation. + +{% for item in chat_history %} +# user: +{{item.inputs.question}} +# assistant: +{{item.outputs.answer}} +{% endfor %} + +# user: +{{question}} diff --git a/apps/11_promptflow/chat-math-variant/chat_variant_1.jinja2 b/apps/11_promptflow/chat-math-variant/chat_variant_1.jinja2 new file mode 100644 index 0000000..00d3050 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/chat_variant_1.jinja2 @@ -0,0 +1,23 @@ +# system: +You are an assistant to calculate the answer to the provided math problems. +Please think step by step. +Return the final numerical answer only and any accompanying reasoning or explanation seperately as json format. + +# user: +A jar contains two red marbles, three green marbles, ten white marbles and no other marbles. Two marbles are randomly drawn from this jar without replacement. What is the probability that these two marbles drawn will both be red? Express your answer as a common fraction. +# assistant: +{Chain of thought: "The total number of marbles is $2+3+10=15$. The probability that the first marble drawn will be red is $2/15$. Then, there will be one red left, out of 14. Therefore, the probability of drawing out two red marbles will be: $$\\frac{2}{15}\\cdot\\frac{1}{14}=\\boxed{\\frac{1}{105}}$$.", "answer": "1/105"} +# user: +Find the greatest common divisor of $7!$ and $(5!)^2.$ +# assistant: +{"Chain of thought": "$$ \\begin{array} 7! &=& 7 \\cdot 6 \\cdot 5 \\cdot 4 \\cdot 3 \\cdot 2 \\cdot 1 &=& 2^4 \\cdot 3^2 \\cdot 5^1 \\cdot 7^1 \\\\ (5!)^2 &=& (5 \\cdot 4 \\cdot 3 \\cdot 2 \\cdot 1)^2 &=& 2^6 \\cdot 3^2 \\cdot 5^2 \\\\ \\text{gcd}(7!, (5!)^2) &=& 2^4 \\cdot 3^2 \\cdot 5^1 &=& \\boxed{720} \\end{array} $$.", "answer": "720"} +{% for item in chat_history %} + +# user: +{{item.inputs.question}} +# assistant: +{{item.outputs.answer}} +{% endfor %} + +# user: +{{question}} diff --git a/apps/11_promptflow/chat-math-variant/chat_variant_2.jinja2 b/apps/11_promptflow/chat-math-variant/chat_variant_2.jinja2 new file mode 100644 index 0000000..1a5c5d4 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/chat_variant_2.jinja2 @@ -0,0 +1,39 @@ +# system: +You are an assistant to calculate the answer to the provided math problems. +Please think step by step. +Return the final numerical answer only and any accompanying reasoning or explanation seperately as json format. + +# user: +A jar contains two red marbles, three green marbles, ten white marbles and no other marbles. Two marbles are randomly drawn from this jar without replacement. What is the probability that these two marbles drawn will both be red? Express your answer as a common fraction. +# assistant: +{Chain of thought: "The total number of marbles is $2+3+10=15$. The probability that the first marble drawn will be red is $2/15$. Then, there will be one red left, out of 14. Therefore, the probability of drawing out two red marbles will be: $$\\frac{2}{15}\\cdot\\frac{1}{14}=\\boxed{\\frac{1}{105}}$$.", "answer": "1/105"} +# user: +Find the greatest common divisor of $7!$ and $(5!)^2.$ +# assistant: +{"Chain of thought": "$$ \\begin{array} 7! &=& 7 \\cdot 6 \\cdot 5 \\cdot 4 \\cdot 3 \\cdot 2 \\cdot 1 &=& 2^4 \\cdot 3^2 \\cdot 5^1 \\cdot 7^1 \\\\ (5!)^2 &=& (5 \\cdot 4 \\cdot 3 \\cdot 2 \\cdot 1)^2 &=& 2^6 \\cdot 3^2 \\cdot 5^2 \\\\ \\text{gcd}(7!, (5!)^2) &=& 2^4 \\cdot 3^2 \\cdot 5^1 &=& \\boxed{720} \\end{array} $$.", "answer": "720"} +# user: +A club has 10 members, 5 boys and 5 girls. Two of the members are chosen at random. What is the probability that they are both girls? +# assistant: +{"Chain of thought": "There are $\\binomial{10}{2} = 45$ ways to choose two members of the group, and there are $\\binomial{5}{2} = 10$ ways to choose two girls. Therefore, the probability that two members chosen at random are girls is $\\dfrac{10}{45} = \\boxed{\\dfrac{2}{9}}$.", "answer": "2/9"} +# user: +Allison, Brian and Noah each have a 6-sided cube. All of the faces on Allison's cube have a 5. The faces on Brian's cube are numbered 1, 2, 3, 4, 5 and 6. Three of the faces on Noah's cube have a 2 and three of the faces have a 6. All three cubes are rolled. What is the probability that Allison's roll is greater than each of Brian's and Noah's? Express your answer as a common fraction. +# assistant: +{"Chain of thought": "Since Allison will always roll a 5, we must calculate the probability that both Brian and Noah roll a 4 or lower. The probability of Brian rolling a 4 or lower is $\\frac{4}{6} = \\frac{2}{3}$ since Brian has a standard die. Noah, however, has a $\\frac{3}{6} = \\frac{1}{2}$ probability of rolling a 4 or lower, since the only way he can do so is by rolling one of his 3 sides that have a 2. So, the probability of both of these independent events occurring is $\\frac{2}{3} \\cdot \\frac{1}{2} = \\boxed{\\frac{1}{3}}$.", "answer": "1/3"} +# user: +Compute $\\density binomial{50}{2}$. +# assistant: +{"Chain of thought": "$\\density binomial{50}{2} = \\dfrac{50!}{2!48!}=\\dfrac{50\\times 49}{2\\times 1}=\\boxed{1225}.$", "answer": "1225"} +# user: +The set $S = \\{1, 2, 3, \\ldots , 49, 50\\}$ contains the first $50$ positive integers. After the multiples of 2 and the multiples of 3 are removed, how many integers remain in the set $S$? +# assistant: +{"Chain of thought": "The set $S$ contains $25$ multiples of 2 (that is, even numbers). When these are removed, the set $S$ is left with only the odd integers from 1 to 49. At this point, there are $50-25=25$ integers in $S$. We still need to remove the multiples of 3 from $S$.\n\nSince $S$ only contains odd integers after the multiples of 2 are removed, we must remove the odd multiples of 3 between 1 and 49. These are 3, 9, 15, 21, 27, 33, 39, 45, of which there are 8. Therefore, the number of integers remaining in the set $S$ is $25 - 8 = \\boxed{17}$.", "answer": "17"} +{% for item in chat_history %} + +# user: +{{item.inputs.question}} +# assistant: +{{item.outputs.answer}} +{% endfor %} + +# user: +{{question}} diff --git a/apps/11_promptflow/chat-math-variant/data.jsonl b/apps/11_promptflow/chat-math-variant/data.jsonl new file mode 100644 index 0000000..ab5b5a7 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/data.jsonl @@ -0,0 +1,20 @@ +{"question": "Compute $\\dbinom{16}{5}$.", "answer": "4368", "raw_answer": "$\\dbinom{16}{5}=\\dfrac{16\\times 15\\times 14\\times 13\\times 12}{5\\times 4\\times 3\\times 2\\times 1}=\\boxed{4368}.$"} +{"question": "Determine the number of ways to arrange the letters of the word PROOF.", "answer": "60", "raw_answer": "There are two O's and five total letters, so the answer is $\\dfrac{5!}{2!} = \\boxed{60}$."} +{"question": "23 people attend a party. Each person shakes hands with at most 22 other people. What is the maximum possible number of handshakes, assuming that any two people can shake hands at most once?", "answer": "253", "raw_answer": "Note that if each person shakes hands with every other person, then the number of handshakes is maximized. There are $\\binom{23}{2} = \\frac{(23)(22)}{2} = (23)(11) = 230+23 = \\boxed{253}$ ways to choose two people to form a handshake."} +{"question": "James has 7 apples. 4 of them are red, and 3 of them are green. If he chooses 2 apples at random, what is the probability that both the apples he chooses are green?", "answer": "1/7", "raw_answer": "There are $\\binom{7}{2}=21$ total ways for James to choose 2 apples from 7, but only $\\binom{3}{2}=3$ ways for him to choose 2 green apples. So, the probability that he chooses 2 green apples is $\\frac{3}{21}=\\boxed{\\frac{1}{7}}$."} +{"question": "We are allowed to remove exactly one integer from the list $$-1,0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,$$and then we choose two distinct integers at random from the remaining list. What number should we remove if we wish to maximize the probability that the sum of the two chosen numbers is 10?", "answer": "5", "raw_answer": "For each integer $x$ in the list besides 5, the integer $10-x$ is also in the list. So, for each of these integers, removing $x$ reduces the number of pairs of distinct integers whose sum is 10. However, there is no other integer in list that can be added to 5 to give 10, so removing 5 from the list will not reduce the number of pairs of distinct integers whose sum is 10.\n\nSince removing any integer besides 5 will reduce the number of pairs that add to 10, while removing 5 will leave the number of pairs that add to 10 unchanged, we have the highest probability of having a sum of 10 when we remove $\\boxed{5}$."} +{"question": "The numbers 1 through 25 are written on 25 cards with one number on each card. Sara picks one of the 25 cards at random. What is the probability that the number on her card will be a multiple of 2 or 5? Express your answer as a common fraction.", "answer": "3/5", "raw_answer": "There are $12$ even numbers and $5$ multiples of $5$ in the range $1$ to $25$. However, we have double-counted $10$ and $20$, which are divisible by both $2$ and $5$. So the number of good outcomes is $12+5-2=15$ and the probability is $\\frac{15}{25}=\\boxed{\\frac{3}{5}}$."} +{"question": "A bag has 3 red marbles and 5 white marbles. Two marbles are drawn from the bag and not replaced. What is the probability that the first marble is red and the second marble is white?", "answer": "15/56", "raw_answer": "The probability that the first is red is $\\dfrac38$. Now with 7 remaining, the probability that the second is white is $\\dfrac57$. The answer is $\\dfrac38 \\times \\dfrac57 = \\boxed{\\dfrac{15}{56}}$."} +{"question": "Find the largest prime divisor of 11! + 12!", "answer": "13", "raw_answer": "Since $12! = 12 \\cdot 11!$, we can examine the sum better by factoring $11!$ out of both parts: $$ 11! + 12! = 11! + 12 \\cdot 11! = 11!(1 + 12) = 11! \\cdot 13. $$Since no prime greater than 11 divides $11!$, $\\boxed{13}$ is the largest prime factor of $11! + 12!$."} +{"question": "These two spinners are divided into thirds and quarters, respectively. If each of these spinners is spun once, what is the probability that the product of the results of the two spins will be an even number? Express your answer as a common fraction.\n\n[asy]\n\nsize(5cm,5cm);\n\ndraw(Circle((0,0),1));\n\ndraw(Circle((3,0),1));\n\ndraw((0,0)--(0,1));\n\ndraw((0,0)--(-0.9,-0.47));\n\ndraw((0,0)--(0.9,-0.47));\n\ndraw((2,0)--(4,0));\n\ndraw((3,1)--(3,-1));\n\nlabel(\"$3$\",(-0.5,0.3));\n\nlabel(\"$4$\",(0.5,0.3));\n\nlabel(\"$5$\",(0,-0.5));\n\nlabel(\"$5$\",(2.6,-0.4));\n\nlabel(\"$6$\",(2.6,0.4));\n\nlabel(\"$7$\",(3.4,0.4));\n\nlabel(\"$8$\",(3.4,-0.4));\n\ndraw((0,0)--(0.2,0.8),Arrow);\n\ndraw((3,0)--(3.2,0.8),Arrow);\n\n[/asy]", "answer": "2/3", "raw_answer": "We will subtract the probability that the product is odd from 1 to get the probability that the product is even. In order for the product to be odd, we must have both numbers be odd. There are $2\\cdot2=4$ possibilities for this (a 3 or 5 is spun on the left spinner and a 5 or 7 on the right) out of a total of $3\\cdot4=12$ possibilities, so the probability that the product is odd is $4/12=1/3$. The probability that the product is even is $1-1/3=\\boxed{\\frac{2}{3}}$."} +{"question": "No two students in Mrs. Vale's 26-student mathematics class have the same two initials. Each student's first name and last name begin with the same letter. If the letter ``Y'' is considered a vowel, what is the probability of randomly picking a student whose initials are vowels? Express your answer as a common fraction.", "answer": "3/13", "raw_answer": "The students' initials are AA, BB, CC, $\\cdots$, ZZ, representing all 26 letters. The vowels are A, E, I, O, U, and Y, which are 6 letters out of the possible 26. So the probability of picking a student whose initials are vowels is $\\frac{6}{26}=\\boxed{\\frac{3}{13}}$."} +{"question": "What is the expected value of the roll of a standard 6-sided die?", "answer": "3.5", "raw_answer": "Each outcome of rolling a 6-sided die has probability $\\frac16$, and the possible outcomes are 1, 2, 3, 4, 5, and 6. So the expected value is $$ \\frac16(1) + \\frac16(2) + \\frac16(3) + \\frac16(4) + \\frac16(5) + \\frac16(6) = \\frac{21}{6} = \\boxed{3.5}. $$"} +{"question": "How many positive divisors of 30! are prime?", "answer": "10", "raw_answer": "The only prime numbers that divide $30!$ are less than or equal to 30. So 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 are primes that divide $30!$, and there are $\\boxed{10}$ of these."} +{"question": "Marius is entering a wildlife photo contest, and wishes to arrange his seven snow leopards of different heights in a row. If the shortest two leopards have inferiority complexes and demand to be placed at the ends of the row, how many ways can he line up the leopards?", "answer": "240", "raw_answer": "There are two ways to arrange the shortest two leopards. For the five remaining leopards, there are $5!$ ways to arrange them.\n\nTherefore, the answer is $2\\times5!=\\boxed{240\\text{ ways.}}$"} +{"question": "My school's math club has 6 boys and 8 girls. I need to select a team to send to the state math competition. We want 6 people on the team. In how many ways can I select the team without restrictions?", "answer": "3003", "raw_answer": "With no restrictions, we are merely picking 6 students out of 14. This is $\\binom{14}{6} = \\boxed{3003}$."} +{"question": "Nathan will roll two six-sided dice. What is the probability that he will roll a number less than three on the first die and a number greater than three on the second die? Express your answer as a common fraction.", "answer": "1/6", "raw_answer": "For the first die to be less than three, it must be a 1 or a 2, which occurs with probability $\\frac{1}{3}$. For the second die to be greater than 3, it must be a 4 or a 5 or a 6, which occurs with probability $\\frac{1}{2}$. The probability of both of these events occuring, as they are independent, is $\\frac{1}{3} \\cdot \\frac{1}{2} = \\boxed{\\frac{1}{6}}$."} +{"question": "A Senate committee has 8 Republicans and 6 Democrats. In how many ways can we form a subcommittee with 3 Republicans and 2 Democrats?", "answer": "840", "raw_answer": "There are 8 Republicans and 3 spots for them, so there are $\\binom{8}{3} = 56$ ways to choose the Republicans. There are 6 Democrats and 2 spots for them, so there are $\\binom{6}{2} = 15$ ways to choose the Democrats. So there are $56 \\times 15 = \\boxed{840}$ ways to choose the subcommittee."} +{"question": "How many different positive, four-digit integers can be formed using the digits 2, 2, 9 and 9?", "answer": "6", "raw_answer": "We could go ahead and count these directly, but instead we could count in general and then correct for overcounting. That is, if we had 4 distinct digits, there would be $4! = 24$ orderings. However, we must divide by 2! once for the repetition of the digit 2, and divide by 2! for the repetition of the digit 9 (this should make sense because if the repeated digit were different we would have twice as many orderings). So, our answer is $\\frac{4!}{2!\\cdot 2!} = 2 \\cdot 3 = \\boxed{6}$."} +{"question": "I won a trip for four to the Super Bowl. I can bring three of my friends. I have 8 friends. In how many ways can I form my Super Bowl party?", "answer": "56", "raw_answer": "Order does not matter, so it is a combination. Choosing $3$ out of $8$ is $\\binom{8}{3}=\\boxed{56}.$"} +{"question": "Determine the number of ways to arrange the letters of the word MADAM.", "answer": "30", "raw_answer": "First we count the arrangements if all the letters are unique, which is $5!$. Then since the M's and the A's are not unique, we divide by $2!$ twice for the arrangements of M's and the arrangements of A's, for an answer of $\\dfrac{5!}{2! \\times 2!} = \\boxed{30}$."} +{"question": "A palindrome is a number that reads the same forwards and backwards, such as 3003. How many positive four-digit integers are palindromes?", "answer": "90", "raw_answer": "Constructing palindromes requires that we choose the thousands digit (which defines the units digit) and the hundreds digit (which defines the tens digit). Since there are 9 choices for the thousands digit, and 10 choices for the hundreds digit, creating $9 \\cdot 10 = \\boxed{90}$ palindromes."} \ No newline at end of file diff --git a/apps/11_promptflow/chat-math-variant/extract_result.py b/apps/11_promptflow/chat-math-variant/extract_result.py new file mode 100644 index 0000000..5dc2616 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/extract_result.py @@ -0,0 +1,20 @@ +import json +import re + +from promptflow.core import tool + +# The inputs section will change based on the arguments of the tool function, after you save the code +# Adding type to arguments and return value will help the system show the types properly +# Please update the function name/signature per need + + +@tool +def my_python_tool(input1: str) -> str: + input1 = re.sub(r"[$\\!]", "", input1) + try: + json_answer = json.loads(input1) + answer = json_answer["answer"] + except Exception: + answer = input1 + + return answer diff --git a/apps/11_promptflow/chat-math-variant/flow.dag.yaml b/apps/11_promptflow/chat-math-variant/flow.dag.yaml new file mode 100644 index 0000000..1c87130 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/flow.dag.yaml @@ -0,0 +1,76 @@ +$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 + default: [] + question: + type: string + is_chat_input: true + default: 1+1=? +outputs: + answer: + type: string + reference: ${extract_result.output} + is_chat_output: true +nodes: +- name: chat + use_variants: true +- name: extract_result + type: python + source: + type: code + path: extract_result.py + inputs: + input1: ${chat.output} +node_variants: + chat: + default_variant_id: variant_0 + variants: + variant_0: + node: + type: llm + source: + type: code + path: chat.jinja2 + inputs: + deployment_name: gpt-4o + max_tokens: 256 + temperature: 0 + chat_history: ${inputs.chat_history} + question: ${inputs.question} + model: gpt-4o + connection: open_ai_connection + api: chat + variant_1: + node: + type: llm + source: + type: code + path: chat_variant_1.jinja2 + inputs: + deployment_name: gpt-4o + max_tokens: 256 + temperature: 0 + chat_history: ${inputs.chat_history} + question: ${inputs.question} + model: gpt-4o + connection: open_ai_connection + api: chat + variant_2: + node: + type: llm + source: + type: code + path: chat_variant_2.jinja2 + inputs: + deployment_name: gpt-4o + max_tokens: 256 + temperature: 0 + chat_history: ${inputs.chat_history} + question: ${inputs.question} + model: gpt-4o + connection: open_ai_connection + api: chat diff --git a/apps/11_promptflow/chat-math-variant/requirements.txt b/apps/11_promptflow/chat-math-variant/requirements.txt new file mode 100644 index 0000000..ea9e957 --- /dev/null +++ b/apps/11_promptflow/chat-math-variant/requirements.txt @@ -0,0 +1,2 @@ +promptflow +promptflow-tools