Skip to content

Commit 8a42860

Browse files
authored
using chat api for examples (#92)
1 parent 1b962d9 commit 8a42860

File tree

20 files changed

+134
-112
lines changed

20 files changed

+134
-112
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ cython_debug/
164164
# ignore
165165
# TODO: ignore when PFS supports submit without tools.json
166166
.promptflow
167+
!flow.tools.json
167168
.runs
168169
connection.json
169170
.env

examples/flows/standard/basic-with-builtin-llm/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pip install -r requirements.txt
1818
## Setup connection
1919
Prepare your Azure Open AI resource follow this [instruction](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal) and get your `api_key` if you don't have one.
2020

21+
Note in this example, we are using [chat api](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/chatgpt?pivots=programming-language-chat-completions), please use `gpt-35-turbo` or `gpt-4` model deployment.
22+
2123
Ensure you have created `azure_open_ai_connection` connection before.
2224
```bash
2325
pf connection show -n azure_open_ai_connection
@@ -39,7 +41,7 @@ pf connection create -f azure_openai.yml --set api_key=<your_api_key> api_base=<
3941
pf flow test --flow .
4042

4143
# test with inputs
42-
pf flow test --flow . --inputs text="Hello World!"
44+
pf flow test --flow . --inputs text="Python Hello World!"
4345
```
4446

4547
### run with multiple lines data
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
{"text": "Hello World!"}
2-
{"text": "Hello PromptFlow!"}
1+
{"text": "Python Hello World!"}
2+
{"text": "C Hello World!"}
3+
{"text": "C# Hello World!"}

examples/flows/standard/basic-with-builtin-llm/flow.dag.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
inputs:
22
text:
33
type: string
4-
default: Hello World!
4+
default: Python Hello World!
55
outputs:
66
output:
77
type: string
@@ -18,12 +18,12 @@ nodes:
1818
type: llm
1919
inputs:
2020
prompt: ${hello_prompt.output}
21-
deployment_name: text-davinci-003
21+
deployment_name: gpt-35-turbo
2222
max_tokens: '120'
2323
source:
2424
type: code
2525
path: hello.jinja2
2626
provider: AzureOpenAI
2727
connection: azure_open_ai_connection
28-
api: completion
28+
api: chat
2929
node_variants: {}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
{# Please replace the template with your own prompt. #}
1+
system:
2+
You are a assistant which can write code. Response should only contain code.
3+
4+
user:
25
Write a simple {{text}} program that displays the greeting message when executed.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
{"text": "Hello World!"}
2-
{"text": "Hello PromptFlow!"}
1+
{"text": "Python Hello World!"}
2+
{"text": "C Hello World!"}
3+
{"text": "C# Hello World!"}

examples/flows/standard/basic/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cat .env
3333
pf flow test --flow .
3434

3535
# test with flow inputs
36-
pf flow test --flow . --inputs text="Hello World!"
36+
pf flow test --flow . --inputs text="Java Hello World!"
3737

3838
# test node with inputs
3939
# pf flow test --flow . --node llm --inputs prompt="Write a simple Hello World program that displays the greeting message when executed."
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
{"text": "Hello World!"}
2-
{"text": "Hello PromptFlow!"}
1+
{"text": "Python Hello World!"}
2+
{"text": "C Hello World!"}
3+
{"text": "C# Hello World!"}

examples/flows/standard/flow-with-additional-includes/flow.dag.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ nodes:
3131
type: code
3232
path: classify_with_llm.jinja2
3333
inputs:
34-
deployment_name: text-davinci-003
34+
deployment_name: gpt-35-turbo
3535
max_tokens: '128'
3636
temperature: '0.2'
3737
url: ${inputs.url}
3838
text_content: ${summarize_text_content.output}
3939
examples: ${prepare_examples.output}
4040
provider: AzureOpenAI
4141
connection: azure_open_ai_connection
42-
api: completion
42+
api: chat
4343
- name: convert_to_dict
4444
type: python
4545
source:
@@ -69,13 +69,13 @@ node_variants:
6969
type: code
7070
path: summarize_text_content.jinja2
7171
inputs:
72-
deployment_name: text-davinci-003
72+
deployment_name: gpt-35-turbo
7373
max_tokens: '128'
7474
temperature: '0.2'
7575
text: ${fetch_text_content_from_url.output}
7676
provider: AzureOpenAI
7777
connection: azure_open_ai_connection
78-
api: completion
78+
api: chat
7979
module: promptflow.tools.aoai
8080
variant_1:
8181
node:
@@ -84,11 +84,11 @@ node_variants:
8484
type: code
8585
path: summarize_text_content__variant_1.jinja2
8686
inputs:
87-
deployment_name: text-davinci-003
87+
deployment_name: gpt-35-turbo
8888
max_tokens: '256'
8989
temperature: '0.3'
9090
text: ${fetch_text_content_from_url.output}
9191
provider: AzureOpenAI
9292
connection: azure_open_ai_connection
93-
api: completion
93+
api: chat
9494
module: promptflow.tools.aoai

examples/flows/standard/flow-with-symlinks/flow.dag.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ nodes:
3131
type: code
3232
path: classify_with_llm.jinja2
3333
inputs:
34-
deployment_name: text-davinci-003
34+
deployment_name: gpt-35-turbo
3535
max_tokens: 128
3636
temperature: 0.2
3737
url: ${inputs.url}
3838
text_content: ${summarize_text_content.output}
3939
examples: ${prepare_examples.output}
4040
provider: AzureOpenAI
4141
connection: azure_open_ai_connection
42-
api: completion
42+
api: chat
4343
- name: convert_to_dict
4444
type: python
4545
source:
@@ -58,13 +58,13 @@ node_variants:
5858
type: code
5959
path: summarize_text_content.jinja2
6060
inputs:
61-
deployment_name: text-davinci-003
61+
deployment_name: gpt-35-turbo
6262
max_tokens: 128
6363
temperature: 0.2
6464
text: ${fetch_text_content_from_url.output}
6565
provider: AzureOpenAI
6666
connection: azure_open_ai_connection
67-
api: completion
67+
api: chat
6868
module: promptflow.tools.aoai
6969
variant_1:
7070
node:
@@ -73,11 +73,11 @@ node_variants:
7373
type: code
7474
path: summarize_text_content__variant_1.jinja2
7575
inputs:
76-
deployment_name: text-davinci-003
76+
deployment_name: gpt-35-turbo
7777
max_tokens: 256
7878
temperature: 0.3
7979
text: ${fetch_text_content_from_url.output}
8080
provider: AzureOpenAI
8181
connection: azure_open_ai_connection
82-
api: completion
82+
api: chat
8383
module: promptflow.tools.aoai

0 commit comments

Comments
 (0)