From a674de595d972aa6da3cbcf82de7843b90d0883c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Silvia=20Bola=C3=B1os=20Prada?= Date: Wed, 22 May 2024 11:51:13 +0200 Subject: [PATCH] move prompt joke --- .../basic/joke_prompt/.gitignore | 5 ++ .../joke_prompt/.promptflow/flow.tools.json | 53 +++++++++++++++++++ .../basic/joke_prompt/data.jsonl | 1 + .../basic/joke_prompt/echo.py | 14 +++++ .../basic/joke_prompt/flow.dag.yaml | 38 +++++++++++++ .../basic/joke_prompt/flow.meta.yaml | 10 ++++ .../basic/joke_prompt/joke.jinja2 | 9 ++++ .../basic/joke_prompt/requirements.txt | 1 + .../basic/joke_prompt/samples.jason | 5 ++ 9 files changed, 136 insertions(+) create mode 100644 standard-flow-from-zero/basic/joke_prompt/.gitignore create mode 100644 standard-flow-from-zero/basic/joke_prompt/.promptflow/flow.tools.json create mode 100644 standard-flow-from-zero/basic/joke_prompt/data.jsonl create mode 100644 standard-flow-from-zero/basic/joke_prompt/echo.py create mode 100644 standard-flow-from-zero/basic/joke_prompt/flow.dag.yaml create mode 100644 standard-flow-from-zero/basic/joke_prompt/flow.meta.yaml create mode 100644 standard-flow-from-zero/basic/joke_prompt/joke.jinja2 create mode 100644 standard-flow-from-zero/basic/joke_prompt/requirements.txt create mode 100644 standard-flow-from-zero/basic/joke_prompt/samples.jason diff --git a/standard-flow-from-zero/basic/joke_prompt/.gitignore b/standard-flow-from-zero/basic/joke_prompt/.gitignore new file mode 100644 index 00000000000..61bd7254f60 --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/.gitignore @@ -0,0 +1,5 @@ +.env +__pycache__/ +.promptflow/* +!.promptflow/flow.tools.json +.runs/ diff --git a/standard-flow-from-zero/basic/joke_prompt/.promptflow/flow.tools.json b/standard-flow-from-zero/basic/joke_prompt/.promptflow/flow.tools.json new file mode 100644 index 00000000000..24b306d7910 --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/.promptflow/flow.tools.json @@ -0,0 +1,53 @@ +{ + "package": {}, + "code": { + "hello.jinja2": { + "type": "prompt", + "inputs": { + "text": { + "type": [ + "string" + ] + } + }, + "description": "Please replace the template with your own prompt.", + "source": "hello.jinja2" + }, + "hello.py": { + "type": "python", + "inputs": { + "input1": { + "type": [ + "string" + ] + } + }, + "source": "hello.py", + "function": "my_python_tool" + }, + "joke.jinja2": { + "type": "llm", + "inputs": { + "topic": { + "type": [ + "string" + ] + } + }, + "description": "Prompt is a jinja2 template that generates prompt for LLM", + "source": "joke.jinja2" + }, + "echo.py": { + "type": "python", + "inputs": { + "input1": { + "type": [ + "string" + ] + } + }, + "source": "echo.py", + "function": "my_python_tool" + } + } +} \ No newline at end of file diff --git a/standard-flow-from-zero/basic/joke_prompt/data.jsonl b/standard-flow-from-zero/basic/joke_prompt/data.jsonl new file mode 100644 index 00000000000..15e3aa54262 --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/data.jsonl @@ -0,0 +1 @@ +{"text": "Hello World!"} diff --git a/standard-flow-from-zero/basic/joke_prompt/echo.py b/standard-flow-from-zero/basic/joke_prompt/echo.py new file mode 100644 index 00000000000..f533b2721cd --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/echo.py @@ -0,0 +1,14 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +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: + return "Prompt: " + input1 diff --git a/standard-flow-from-zero/basic/joke_prompt/flow.dag.yaml b/standard-flow-from-zero/basic/joke_prompt/flow.dag.yaml new file mode 100644 index 00000000000..1544eadb488 --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/flow.dag.yaml @@ -0,0 +1,38 @@ +id: template_standard_flow +name: Template Standard Flow +environment: + python_requirements_txt: requirements.txt +inputs: + topic: + type: string + is_chat_input: false + default: atom +outputs: + joke: + type: string + reference: ${echo.output} +nodes: +- name: echo + type: python + source: + type: code + path: echo.py + inputs: + input1: ${joke.output} + use_variants: false +- name: joke + type: llm + source: + type: code + path: joke.jinja2 + inputs: + deployment_name: gpt-4-32k + temperature: 1 + top_p: 1 + max_tokens: 256 + topic: ${inputs.topic} + response_format: + type: text + connection: connection_name + api: chat + use_variants: false diff --git a/standard-flow-from-zero/basic/joke_prompt/flow.meta.yaml b/standard-flow-from-zero/basic/joke_prompt/flow.meta.yaml new file mode 100644 index 00000000000..34699e1d902 --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/flow.meta.yaml @@ -0,0 +1,10 @@ +$schema: https://azuremlschemas.azureedge.net/latest/flow.schema.json +name: template_standard_flow +display_name: Template Standard Flow +type: standard +path: ./flow.dag.yaml +description: Template Standard Flow +properties: + promptflow.stage: prod + promptflow.section: template + promptflow.batch_inputs: samples.json \ No newline at end of file diff --git a/standard-flow-from-zero/basic/joke_prompt/joke.jinja2 b/standard-flow-from-zero/basic/joke_prompt/joke.jinja2 new file mode 100644 index 00000000000..0343bbe0fb4 --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/joke.jinja2 @@ -0,0 +1,9 @@ +{# 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 \ No newline at end of file diff --git a/standard-flow-from-zero/basic/joke_prompt/requirements.txt b/standard-flow-from-zero/basic/joke_prompt/requirements.txt new file mode 100644 index 00000000000..7a54870cad1 --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/requirements.txt @@ -0,0 +1 @@ +promptflow diff --git a/standard-flow-from-zero/basic/joke_prompt/samples.jason b/standard-flow-from-zero/basic/joke_prompt/samples.jason new file mode 100644 index 00000000000..a29686665b7 --- /dev/null +++ b/standard-flow-from-zero/basic/joke_prompt/samples.jason @@ -0,0 +1,5 @@ +[ + { + "topic": "atom" + } +]