Skip to content

tests: update react example #1001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 21, 2025
Merged
74 changes: 37 additions & 37 deletions examples/demo/9-react.pdl
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
description: Demonstrating a React program
defs:
Calc:
description: Calculator function
function:
expr:
type: string
description: Arithmetic expression to calculate
return:
lang: python
code: result = ${ expr }
Search:
description: Wikipedia search
function:
topic:
type: string
description: Topic to search
return:
lang: python
code: |
import warnings, wikipedia
warnings.simplefilter("ignore")
try:
result = wikipedia.summary("${ topic }")
except wikipedia.WikipediaException as e:
result = str(e)
tools:
data:
- type: function
function:
name: Calc
description: Calculator function
parameters:
type: object
properties:
expr:
type: string
description: Arithmetic expression to calculate
required:
- expr
- type: function
function:
name: Search
description: Wikipedia search
parameters:
type: object
properties:
topic:
type: string
description: Topic to search
required:
- topic
- ${ Calc.signature }
- ${ Search.signature }
text:
- role: system
text: You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.
Expand Down Expand Up @@ -77,19 +79,17 @@ text:
- "\nObservation: "
- match: ${ action[0].name }
with:
- case: 'Search'
- case: Search
then:
lang: python
code: |
import warnings, wikipedia
warnings.simplefilter("ignore")
try:
result = wikipedia.summary("${ action[0].arguments.topic }")
except wikipedia.WikipediaException as e:
result = str(e)
- case: 'Calc'
call: ${ Search }
args:
topic: ${ action[0].arguments.topic }
- case: Calc
then:
lang: python
code: result = ${ action[0].arguments.expr }
call: ${ Calc }
args:
expr: ${ action[0].arguments.expr }
- case: Finish
then: ${ action[0].arguments.topic }
- "\n"
until: ${ action[0].name == "Finish" }
until: ${ action[0].name == "Finish" }
75 changes: 38 additions & 37 deletions examples/demos/react.pdl
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
description: Demonstrating a React program
defs:
Calc:
description: Calculator function
function:
expr:
type: string
description: Arithmetic expression to calculate
return:
lang: python
code: result = ${ expr }
Search:
description: Wikipedia search
function:
topic:
type: string
description: Topic to search
return:
lang: python
code: |
import warnings, wikipedia
warnings.simplefilter("ignore")
try:
result = wikipedia.summary("${ topic }")
except wikipedia.WikipediaException as e:
result = str(e)
tools:
data:
- type: function
function:
name: Calc
description: Calculator function
parameters:
type: object
properties:
expr:
type: string
description: Arithmetic expression to calculate
required:
- expr
- type: function
function:
name: Search
description: Wikipedia search
parameters:
type: object
properties:
topic:
type: string
description: Topic to search
required:
- topic
- ${ Calc.signature }
- ${ Search.signature }
text:
- role: system
text: You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.
Expand Down Expand Up @@ -76,19 +79,17 @@ text:
- "\nObservation: "
- match: ${ action[0].name }
with:
- case: 'Search'
- case: Search
then:
lang: python
code: |
import warnings, wikipedia
warnings.simplefilter("ignore")
try:
result = wikipedia.summary("${ action[0].arguments.topic }")
except wikipedia.WikipediaException as e:
result = str(e)
- case: 'Calc'
call: ${ Search }
args:
topic: ${ action[0].arguments.topic }
- case: Calc
then:
lang: python
code: result = ${ action[0].arguments.expr }
call: ${ Calc }
args:
expr: ${ action[0].arguments.expr }
- case: Finish
then: ${ action[0].arguments.topic }
- "\n"
until: ${ action[0].name == "Finish" }
until: ${ action[0].name == "Finish" }
2 changes: 1 addition & 1 deletion tests/results/examples/demo/9-react.0.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Action:
Observation: 460
Henry Hudson was born around 1565, so he was approximately 460 years ago.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation:
Observation: 460
2 changes: 1 addition & 1 deletion tests/results/examples/demo/9-react.1.result
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Action:
Observation: 460
In the year 2025, it would be approximately 460 years ago that Henry Hudson was born.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation:
Observation: 460
2 changes: 1 addition & 1 deletion tests/results/examples/demo/9-react.2.result
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Action:
Observation: 460
In the year 2025, it would be approximately 460 years ago that Henry Hudson was born.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation:
Observation: 460
2 changes: 1 addition & 1 deletion tests/results/examples/demo/9-react.3.result
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Action:
Observation: 460
In the year 2025, it would be approximately 460 years ago that Henry Hudson was born.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation:
Observation: 460
2 changes: 1 addition & 1 deletion tests/results/examples/demo/9-react.4.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Action:
Observation: 460
Henry Hudson was born around 1565, so he was approximately 460 years ago.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation:
Observation: 460
2 changes: 1 addition & 1 deletion tests/results/examples/demo/9-react.5.result
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Henry Hudson was born around 1565. As of 2025, it has been approximately 470 yea
Observation: 460
Henry Hudson was born around 1565, which means he was born approximately 460 years ago as of 2025.Action:
[{"name": "Finish", "arguments": {"topic": ""}}]
Observation:
Observation: 460
2 changes: 1 addition & 1 deletion tests/results/examples/demo/9-react.6.result
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Henry Hudson was born around 1565. As of 2025, it has been approximately 470 yea
Observation: 460
It has been approximately 460 years since Henry Hudson was born.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation:
Observation: 460
13 changes: 13 additions & 0 deletions tests/results/examples/demo/9-react.7.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2025. When searching for a birthday for a person, simply ask for the name of that person.
Thought: I need to find out who discovered the Hudson River and then calculate how many years ago they were born based on the current year, 2025.
Action:
[{"name": "Search", "arguments": {"topic": "Henry Hudson"}}]
Observation: Henry Hudson (c. 1565 – disappeared 23 June 1611) was an English sea explorer and navigator during the early 17th century, best known for his explorations of present-day Canada and parts of the Northeastern United States.
In 1607 and 1608, Hudson made two attempts on behalf of English merchants to find a rumoured Northeast Passage to Cathay via a route above the Arctic Circle. In 1609, he landed in North America on behalf of the Dutch East India Company and explored the region around the modern New York metropolitan area. Looking for a Northwest Passage to Asia on his ship Halve Maen ("Half Moon"), he sailed up the Hudson River, which was later named after him, and thereby laid the foundation for Dutch colonization of the region. His contributions to the exploration of the New World were significant and lasting. His voyages helped to establish European contact with the native peoples of North America and contributed to the development of trade and commerce.
On his final expedition, while still searching for the Northwest Passage, Hudson became the first European to see Hudson Strait and the immense Hudson Bay. In 1611, after wintering on the shore of James Bay, Hudson wanted to press on to the west, but most of his crew mutinied. The mutineers cast Hudson, his son, and six others adrift; what then happened to the Hudsons and their companions is unknown.
Henry Hudson was born around 1565. As of 2025, it has been approximately 470 years since Henry Hudson's birth.Action:
[{"name": "Calc", "arguments": {"expr": "2025 - 1565"}}]
Observation: 460
It has been approximately 460 years since Henry Hudson was born.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation: 460
15 changes: 15 additions & 0 deletions tests/results/examples/demo/9-react.8.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2025. When searching for a birthday for a person, simply ask for the name of that person.
Thought: I need to find out who discovered the Hudson River and then calculate how many years ago they were born based on the current year, 2025.
Action:
[{"name": "Search", "arguments": {"topic": "Henry Hudson"}}]
Observation: Henry Hudson (c. 1565 – disappeared 23 June 1611) was an English sea explorer and navigator during the early 17th century, best known for his explorations of present-day Canada and parts of the Northeastern United States.
In 1607 and 1608, Hudson made two attempts on behalf of English merchants to find a rumoured Northeast Passage to Cathay via a route above the Arctic Circle. In 1609, he landed in North America on behalf of the Dutch East India Company and explored the region around the modern New York metropolitan area. Looking for a Northwest Passage to Asia on his ship Halve Maen ("Half Moon"), he sailed up the Hudson River, which was later named after him, and thereby laid the foundation for Dutch colonization of the region. His contributions to the exploration of the New World were significant and lasting. His voyages helped to establish European contact with the native peoples of North America and contributed to the development of trade and commerce.
On his final expedition, while still searching for the Northwest Passage, Hudson became the first European to see Hudson Strait and the immense Hudson Bay. In 1611, after wintering on the shore of James Bay, Hudson wanted to press on to the west, but most of his crew mutinied. The mutineers cast Hudson, his son, and six others adrift; what then happened to the Hudsons and their companions is unknown.


Henry Hudson was born around 1565. As of 2025, it has been approximately 470 years since Henry Hudson's birth.Action:
[{"name": "Calc", "arguments": {"expr": "2025 - 1565"}}]
Observation: 460
Henry Hudson was born around 1565, so in 2025, it has been approximately 460 years since his birth.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation: 460
2 changes: 1 addition & 1 deletion tests/results/examples/demos/react.0.result
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Henry Hudson was born around 1565. As of 2025, it has been approximately 470 yea
Observation: 460
Henry Hudson was born around 1565, which means he was born approximately 460 years ago as of 2025.Action:
[{"name": "Finish", "arguments": {"topic": ""}}]
Observation:
Observation: 460
15 changes: 8 additions & 7 deletions tests/results/examples/demos/react.1.result
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2025. When searching for a birthday for a person, simply ask for the name of that person.
Thought: I need to find out who discovered the Hudson River and then calculate how many years ago they were born based on the current year, 2025.
How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2025. When searching for a birthday for a person, simply ask for the name of that person.
Thought: I need to search who discovered the Hudson River.
Action:
[{"name": "Search", "arguments": {"topic": "Henry Hudson"}}]
Observation: Henry Hudson (c. 1565 – disappeared 23 June 1611) was an English sea explorer and navigator during the early 17th century, best known for his explorations of present-day Canada and parts of the Northeastern United States.
In 1607 and 1608, Hudson made two attempts on behalf of English merchants to find a rumoured Northeast Passage to Cathay via a route above the Arctic Circle. In 1609, he landed in North America on behalf of the Dutch East India Company and explored the region around the modern New York metropolitan area. Looking for a Northwest Passage to Asia on his ship Halve Maen ("Half Moon"), he sailed up the Hudson River, which was later named after him, and thereby laid the foundation for Dutch colonization of the region. His contributions to the exploration of the New World were significant and lasting. His voyages helped to establish European contact with the native peoples of North America and contributed to the development of trade and commerce.
On his final expedition, while still searching for the Northwest Passage, Hudson became the first European to see Hudson Strait and the immense Hudson Bay. In 1611, after wintering on the shore of James Bay, Hudson wanted to press on to the west, but most of his crew mutinied. The mutineers cast Hudson, his son, and six others adrift; what then happened to the Hudsons and their companions is unknown.


Henry Hudson was born around 1565. As of 2025, it has been approximately 470 years since Henry Hudson's birth.Action:
Thought: Henry Hudson was born around 1565. To find out how many years ago he was born from the year 2025, we subtract 2025 from 1565.
Calculation: 2025 - 1565 = 460
Action:
[{"name": "Calc", "arguments": {"expr": "2025 - 1565"}}]
Observation: 460
It has been approximately 460 years since Henry Hudson was born.Action:
Henry Hudson was born around 460 years before 2025.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation:
Observation: 460

13 changes: 13 additions & 0 deletions tests/results/examples/demos/react.2.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2025. When searching for a birthday for a person, simply ask for the name of that person.
Thought: I need to find out who discovered the Hudson River and then calculate how many years ago they were born based on the current year, 2025.
Action:
[{"name": "Search", "arguments": {"topic": "Henry Hudson"}}]
Observation: Henry Hudson (c. 1565 – disappeared 23 June 1611) was an English sea explorer and navigator during the early 17th century, best known for his explorations of present-day Canada and parts of the Northeastern United States.
In 1607 and 1608, Hudson made two attempts on behalf of English merchants to find a rumoured Northeast Passage to Cathay via a route above the Arctic Circle. In 1609, he landed in North America on behalf of the Dutch East India Company and explored the region around the modern New York metropolitan area. Looking for a Northwest Passage to Asia on his ship Halve Maen ("Half Moon"), he sailed up the Hudson River, which was later named after him, and thereby laid the foundation for Dutch colonization of the region. His contributions to the exploration of the New World were significant and lasting. His voyages helped to establish European contact with the native peoples of North America and contributed to the development of trade and commerce.
On his final expedition, while still searching for the Northwest Passage, Hudson became the first European to see Hudson Strait and the immense Hudson Bay. In 1611, after wintering on the shore of James Bay, Hudson wanted to press on to the west, but most of his crew mutinied. The mutineers cast Hudson, his son, and six others adrift; what then happened to the Hudsons and their companions is unknown.
Henry Hudson was born around 1565. As of 2025, it has been approximately 470 years since Henry Hudson's birth.Action:
[{"name": "Calc", "arguments": {"expr": "2025 - 1565"}}]
Observation: 460
It has been approximately 460 years since Henry Hudson was born.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation: 460
16 changes: 16 additions & 0 deletions tests/results/examples/demos/react.3.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2025. When searching for a birthday for a person, simply ask for the name of that person.
Thought: I need to search who discovered the Hudson River.
Action:
[{"name": "Search", "arguments": {"topic": "Henry Hudson"}}]
Observation: Henry Hudson (c. 1565 – disappeared 23 June 1611) was an English sea explorer and navigator during the early 17th century, best known for his explorations of present-day Canada and parts of the Northeastern United States.
In 1607 and 1608, Hudson made two attempts on behalf of English merchants to find a rumoured Northeast Passage to Cathay via a route above the Arctic Circle. In 1609, he landed in North America on behalf of the Dutch East India Company and explored the region around the modern New York metropolitan area. Looking for a Northwest Passage to Asia on his ship Halve Maen ("Half Moon"), he sailed up the Hudson River, which was later named after him, and thereby laid the foundation for Dutch colonization of the region. His contributions to the exploration of the New World were significant and lasting. His voyages helped to establish European contact with the native peoples of North America and contributed to the development of trade and commerce.
On his final expedition, while still searching for the Northwest Passage, Hudson became the first European to see Hudson Strait and the immense Hudson Bay. In 1611, after wintering on the shore of James Bay, Hudson wanted to press on to the west, but most of his crew mutinied. The mutineers cast Hudson, his son, and six others adrift; what then happened to the Hudsons and their companions is unknown.
Thought: Henry Hudson was born around 1565. To find out how many years ago he was born from the year 2025, we subtract 2025 from 1565.
Calculation: 2025 - 1565 = 460
Action:
[{"name": "Calc", "arguments": {"expr": "2025 - 1565"}}]
Observation: 460
Henry Hudson was born around 460 years before 2025.Action:
[{"name": "Finish", "arguments": {"topic": "460"}}]
Observation:

Loading