Skip to content

Commit

Permalink
move prompt joke
Browse files Browse the repository at this point in the history
  • Loading branch information
silviabolanosp committed May 22, 2024
1 parent 2c5ed8f commit a674de5
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 0 deletions.
5 changes: 5 additions & 0 deletions standard-flow-from-zero/basic/joke_prompt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
__pycache__/
.promptflow/*
!.promptflow/flow.tools.json
.runs/
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
1 change: 1 addition & 0 deletions standard-flow-from-zero/basic/joke_prompt/data.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"text": "Hello World!"}
14 changes: 14 additions & 0 deletions standard-flow-from-zero/basic/joke_prompt/echo.py
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions standard-flow-from-zero/basic/joke_prompt/flow.dag.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions standard-flow-from-zero/basic/joke_prompt/flow.meta.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions standard-flow-from-zero/basic/joke_prompt/joke.jinja2
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions standard-flow-from-zero/basic/joke_prompt/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
promptflow
5 changes: 5 additions & 0 deletions standard-flow-from-zero/basic/joke_prompt/samples.jason
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{
"topic": "atom"
}
]

0 comments on commit a674de5

Please sign in to comment.