From 08766fbbc268ae7130cb1d44e4fa527354e3f21c Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Tue, 19 Nov 2024 15:11:20 -0500 Subject: [PATCH 01/17] All non deterministic programs in run examples test --- .../{chatbot.result => chatbot.0.result} | 0 .../{code-eval.result => code-eval.0.result} | 0 .../{code-json.result => code-json.0.result} | 0 .../code/{code.result => code.0.result} | 0 tests/results/examples/demo/3-weather.result | 1 - ...ranslator.result => 4-translator.0.result} | 0 .../fibonacci/{fib.result => fib.0.result} | 0 ...nite_defs.result => granite_defs.0.result} | 0 ..._chat.result => multi_round_chat.0.result} | 0 ...chat.result => single_round_chat.0.result} | 0 ...and.result => hello-code-command.0.result} | 0 ...jinja.result => hello-code-jinja.0.result} | 0 ...ode-pdl.result => hello-code-pdl.0.result} | 0 ...{hello-code.result => hello-code.0.result} | 0 ...{hello-data.result => hello-data.0.result} | 0 ...-def-use.result => hello-def-use.0.result} | 0 ...{hello-defs.result => hello-defs.0.result} | 0 ...or-loop.result => hello-for-loop.0.result} | 0 ...s.result => hello-function-alias.0.result} | 0 ...unction.result => hello-function.0.result} | 0 .../{hello-if.result => hello-if.0.result} | 0 ...ration.result => hello-iteration.0.result} | 0 ...g.result => hello-model-chaining.0.result} | 0 ...nput.result => hello-model-input.0.result} | 0 ...gex.result => hello-parser-regex.0.result} | 0 ...rray.result => hello-roles-array.0.result} | 0 .../hello/{hello.result => hello.0.result} | 0 ...{input_test.result => input_test.0.result} | 0 ...nput_test1.result => input_test1.0.result} | 0 ...nput_test2.result => input_test2.0.result} | 0 .../react/{demo.result => demo.0.result} | 0 .../{react_fun.result => react_fun.0.result} | 0 .../{wikipedia.result => wikipedia.0.result} | 0 .../sdk/{hello.result => hello.0.result} | 0 .../talk/{1-hello.result => 1-hello.0.result} | 0 .../{11-repeat.result => 11-repeat.0.result} | 0 ...ining.result => 2-model-chaining.0.result} | 0 .../{3-def-use.result => 3-def-use.0.result} | 0 ...{4-function.result => 4-function.0.result} | 0 ...-code-eval.result => 5-code-eval.0.result} | 0 ...-code-json.result => 6-code-json.0.result} | 0 ...-roles.result => 7-chatbot-roles.0.result} | 0 .../talk/{9-react.result => 9-react.0.result} | 0 ...ling_code.result => calling_code.0.result} | 0 ...alling_llm.result => calling_llm.0.result} | 0 ...result => calling_llm_with_input.0.result} | 0 ... calling_llm_with_input_messages.0.result} | 0 ...ops.result => conditionals_loops.0.result} | 0 ...{data_block.result => data_block.0.result} | 0 ...ock_raw.result => data_block_raw.0.result} | 0 .../tutorial/{for.result => for.0.result} | 0 .../{for_array.result => for_array.0.result} | 0 ...ts.result => for_multiplie_lists.0.result} | 0 .../{for_with.result => for_with.0.result} | 0 ...on.result => function_definition.0.result} | 0 ...s.result => grouping_definitions.0.result} | 0 .../{include.result => include.0.result} | 0 ...{input_file.result => input_file.0.result} | 0 ...e_json.result => input_file_json.0.result} | 0 ...nput_stdin.result => input_stdin.0.result} | 0 ....result => input_stdin_multiline.0.result} | 0 ...haining.result => model_chaining.0.result} | 0 ...ut.result => muting_block_output.0.result} | 0 ...program.result => simple_program.0.result} | 0 ...f_use.result => variable_def_use.0.result} | 0 .../results/examples/weather/weather.0.result | 1 + tests/results/examples/weather/weather.result | 1 - .../{function.result => function.0.result} | 0 .../data/{hello.result => hello.0.result} | 0 tests/test_examples_run.py | 20 +++++++++++-------- 70 files changed, 13 insertions(+), 10 deletions(-) rename tests/results/examples/chatbot/{chatbot.result => chatbot.0.result} (100%) rename tests/results/examples/code/{code-eval.result => code-eval.0.result} (100%) rename tests/results/examples/code/{code-json.result => code-json.0.result} (100%) rename tests/results/examples/code/{code.result => code.0.result} (100%) delete mode 100644 tests/results/examples/demo/3-weather.result rename tests/results/examples/demo/{4-translator.result => 4-translator.0.result} (100%) rename tests/results/examples/fibonacci/{fib.result => fib.0.result} (100%) rename tests/results/examples/granite/{granite_defs.result => granite_defs.0.result} (100%) rename tests/results/examples/granite/{multi_round_chat.result => multi_round_chat.0.result} (100%) rename tests/results/examples/granite/{single_round_chat.result => single_round_chat.0.result} (100%) rename tests/results/examples/hello/{hello-code-command.result => hello-code-command.0.result} (100%) rename tests/results/examples/hello/{hello-code-jinja.result => hello-code-jinja.0.result} (100%) rename tests/results/examples/hello/{hello-code-pdl.result => hello-code-pdl.0.result} (100%) rename tests/results/examples/hello/{hello-code.result => hello-code.0.result} (100%) rename tests/results/examples/hello/{hello-data.result => hello-data.0.result} (100%) rename tests/results/examples/hello/{hello-def-use.result => hello-def-use.0.result} (100%) rename tests/results/examples/hello/{hello-defs.result => hello-defs.0.result} (100%) rename tests/results/examples/hello/{hello-for-loop.result => hello-for-loop.0.result} (100%) rename tests/results/examples/hello/{hello-function-alias.result => hello-function-alias.0.result} (100%) rename tests/results/examples/hello/{hello-function.result => hello-function.0.result} (100%) rename tests/results/examples/hello/{hello-if.result => hello-if.0.result} (100%) rename tests/results/examples/hello/{hello-iteration.result => hello-iteration.0.result} (100%) rename tests/results/examples/hello/{hello-model-chaining.result => hello-model-chaining.0.result} (100%) rename tests/results/examples/hello/{hello-model-input.result => hello-model-input.0.result} (100%) rename tests/results/examples/hello/{hello-parser-regex.result => hello-parser-regex.0.result} (100%) rename tests/results/examples/hello/{hello-roles-array.result => hello-roles-array.0.result} (100%) rename tests/results/examples/hello/{hello.result => hello.0.result} (100%) rename tests/results/examples/input/{input_test.result => input_test.0.result} (100%) rename tests/results/examples/input/{input_test1.result => input_test1.0.result} (100%) rename tests/results/examples/input/{input_test2.result => input_test2.0.result} (100%) rename tests/results/examples/react/{demo.result => demo.0.result} (100%) rename tests/results/examples/react/{react_fun.result => react_fun.0.result} (100%) rename tests/results/examples/react/{wikipedia.result => wikipedia.0.result} (100%) rename tests/results/examples/sdk/{hello.result => hello.0.result} (100%) rename tests/results/examples/talk/{1-hello.result => 1-hello.0.result} (100%) rename tests/results/examples/talk/{11-repeat.result => 11-repeat.0.result} (100%) rename tests/results/examples/talk/{2-model-chaining.result => 2-model-chaining.0.result} (100%) rename tests/results/examples/talk/{3-def-use.result => 3-def-use.0.result} (100%) rename tests/results/examples/talk/{4-function.result => 4-function.0.result} (100%) rename tests/results/examples/talk/{5-code-eval.result => 5-code-eval.0.result} (100%) rename tests/results/examples/talk/{6-code-json.result => 6-code-json.0.result} (100%) rename tests/results/examples/talk/{7-chatbot-roles.result => 7-chatbot-roles.0.result} (100%) rename tests/results/examples/talk/{9-react.result => 9-react.0.result} (100%) rename tests/results/examples/tutorial/{calling_code.result => calling_code.0.result} (100%) rename tests/results/examples/tutorial/{calling_llm.result => calling_llm.0.result} (100%) rename tests/results/examples/tutorial/{calling_llm_with_input.result => calling_llm_with_input.0.result} (100%) rename tests/results/examples/tutorial/{calling_llm_with_input_messages.result => calling_llm_with_input_messages.0.result} (100%) rename tests/results/examples/tutorial/{conditionals_loops.result => conditionals_loops.0.result} (100%) rename tests/results/examples/tutorial/{data_block.result => data_block.0.result} (100%) rename tests/results/examples/tutorial/{data_block_raw.result => data_block_raw.0.result} (100%) rename tests/results/examples/tutorial/{for.result => for.0.result} (100%) rename tests/results/examples/tutorial/{for_array.result => for_array.0.result} (100%) rename tests/results/examples/tutorial/{for_multiplie_lists.result => for_multiplie_lists.0.result} (100%) rename tests/results/examples/tutorial/{for_with.result => for_with.0.result} (100%) rename tests/results/examples/tutorial/{function_definition.result => function_definition.0.result} (100%) rename tests/results/examples/tutorial/{grouping_definitions.result => grouping_definitions.0.result} (100%) rename tests/results/examples/tutorial/{include.result => include.0.result} (100%) rename tests/results/examples/tutorial/{input_file.result => input_file.0.result} (100%) rename tests/results/examples/tutorial/{input_file_json.result => input_file_json.0.result} (100%) rename tests/results/examples/tutorial/{input_stdin.result => input_stdin.0.result} (100%) rename tests/results/examples/tutorial/{input_stdin_multiline.result => input_stdin_multiline.0.result} (100%) rename tests/results/examples/tutorial/{model_chaining.result => model_chaining.0.result} (100%) rename tests/results/examples/tutorial/{muting_block_output.result => muting_block_output.0.result} (100%) rename tests/results/examples/tutorial/{simple_program.result => simple_program.0.result} (100%) rename tests/results/examples/tutorial/{variable_def_use.result => variable_def_use.0.result} (100%) create mode 100644 tests/results/examples/weather/weather.0.result delete mode 100644 tests/results/examples/weather/weather.result rename tests/results/tests/data/{function.result => function.0.result} (100%) rename tests/results/tests/data/{hello.result => hello.0.result} (100%) diff --git a/tests/results/examples/chatbot/chatbot.result b/tests/results/examples/chatbot/chatbot.0.result similarity index 100% rename from tests/results/examples/chatbot/chatbot.result rename to tests/results/examples/chatbot/chatbot.0.result diff --git a/tests/results/examples/code/code-eval.result b/tests/results/examples/code/code-eval.0.result similarity index 100% rename from tests/results/examples/code/code-eval.result rename to tests/results/examples/code/code-eval.0.result diff --git a/tests/results/examples/code/code-json.result b/tests/results/examples/code/code-json.0.result similarity index 100% rename from tests/results/examples/code/code-json.result rename to tests/results/examples/code/code-json.0.result diff --git a/tests/results/examples/code/code.result b/tests/results/examples/code/code.0.result similarity index 100% rename from tests/results/examples/code/code.result rename to tests/results/examples/code/code.0.result diff --git a/tests/results/examples/demo/3-weather.result b/tests/results/examples/demo/3-weather.result deleted file mode 100644 index 1812accfb..000000000 --- a/tests/results/examples/demo/3-weather.result +++ /dev/null @@ -1 +0,0 @@ -The current weather in Yorktown Heights, New York, USA is sunny with a temperature of 48.0°F (8.9°C). The wind is blowing at 4.0 mph (6.5 kph) from the southeast (ESE). The pressure is 30.55 inches of mercury (1035.0 mb). Humidity is at 46% and the dew point is 33.9°F (1.1°C). Visibility is 9.0 miles (16.0 km). The UV index is 1.9 and the wind gusts up to 5.2 mph (8.3 kph). diff --git a/tests/results/examples/demo/4-translator.result b/tests/results/examples/demo/4-translator.0.result similarity index 100% rename from tests/results/examples/demo/4-translator.result rename to tests/results/examples/demo/4-translator.0.result diff --git a/tests/results/examples/fibonacci/fib.result b/tests/results/examples/fibonacci/fib.0.result similarity index 100% rename from tests/results/examples/fibonacci/fib.result rename to tests/results/examples/fibonacci/fib.0.result diff --git a/tests/results/examples/granite/granite_defs.result b/tests/results/examples/granite/granite_defs.0.result similarity index 100% rename from tests/results/examples/granite/granite_defs.result rename to tests/results/examples/granite/granite_defs.0.result diff --git a/tests/results/examples/granite/multi_round_chat.result b/tests/results/examples/granite/multi_round_chat.0.result similarity index 100% rename from tests/results/examples/granite/multi_round_chat.result rename to tests/results/examples/granite/multi_round_chat.0.result diff --git a/tests/results/examples/granite/single_round_chat.result b/tests/results/examples/granite/single_round_chat.0.result similarity index 100% rename from tests/results/examples/granite/single_round_chat.result rename to tests/results/examples/granite/single_round_chat.0.result diff --git a/tests/results/examples/hello/hello-code-command.result b/tests/results/examples/hello/hello-code-command.0.result similarity index 100% rename from tests/results/examples/hello/hello-code-command.result rename to tests/results/examples/hello/hello-code-command.0.result diff --git a/tests/results/examples/hello/hello-code-jinja.result b/tests/results/examples/hello/hello-code-jinja.0.result similarity index 100% rename from tests/results/examples/hello/hello-code-jinja.result rename to tests/results/examples/hello/hello-code-jinja.0.result diff --git a/tests/results/examples/hello/hello-code-pdl.result b/tests/results/examples/hello/hello-code-pdl.0.result similarity index 100% rename from tests/results/examples/hello/hello-code-pdl.result rename to tests/results/examples/hello/hello-code-pdl.0.result diff --git a/tests/results/examples/hello/hello-code.result b/tests/results/examples/hello/hello-code.0.result similarity index 100% rename from tests/results/examples/hello/hello-code.result rename to tests/results/examples/hello/hello-code.0.result diff --git a/tests/results/examples/hello/hello-data.result b/tests/results/examples/hello/hello-data.0.result similarity index 100% rename from tests/results/examples/hello/hello-data.result rename to tests/results/examples/hello/hello-data.0.result diff --git a/tests/results/examples/hello/hello-def-use.result b/tests/results/examples/hello/hello-def-use.0.result similarity index 100% rename from tests/results/examples/hello/hello-def-use.result rename to tests/results/examples/hello/hello-def-use.0.result diff --git a/tests/results/examples/hello/hello-defs.result b/tests/results/examples/hello/hello-defs.0.result similarity index 100% rename from tests/results/examples/hello/hello-defs.result rename to tests/results/examples/hello/hello-defs.0.result diff --git a/tests/results/examples/hello/hello-for-loop.result b/tests/results/examples/hello/hello-for-loop.0.result similarity index 100% rename from tests/results/examples/hello/hello-for-loop.result rename to tests/results/examples/hello/hello-for-loop.0.result diff --git a/tests/results/examples/hello/hello-function-alias.result b/tests/results/examples/hello/hello-function-alias.0.result similarity index 100% rename from tests/results/examples/hello/hello-function-alias.result rename to tests/results/examples/hello/hello-function-alias.0.result diff --git a/tests/results/examples/hello/hello-function.result b/tests/results/examples/hello/hello-function.0.result similarity index 100% rename from tests/results/examples/hello/hello-function.result rename to tests/results/examples/hello/hello-function.0.result diff --git a/tests/results/examples/hello/hello-if.result b/tests/results/examples/hello/hello-if.0.result similarity index 100% rename from tests/results/examples/hello/hello-if.result rename to tests/results/examples/hello/hello-if.0.result diff --git a/tests/results/examples/hello/hello-iteration.result b/tests/results/examples/hello/hello-iteration.0.result similarity index 100% rename from tests/results/examples/hello/hello-iteration.result rename to tests/results/examples/hello/hello-iteration.0.result diff --git a/tests/results/examples/hello/hello-model-chaining.result b/tests/results/examples/hello/hello-model-chaining.0.result similarity index 100% rename from tests/results/examples/hello/hello-model-chaining.result rename to tests/results/examples/hello/hello-model-chaining.0.result diff --git a/tests/results/examples/hello/hello-model-input.result b/tests/results/examples/hello/hello-model-input.0.result similarity index 100% rename from tests/results/examples/hello/hello-model-input.result rename to tests/results/examples/hello/hello-model-input.0.result diff --git a/tests/results/examples/hello/hello-parser-regex.result b/tests/results/examples/hello/hello-parser-regex.0.result similarity index 100% rename from tests/results/examples/hello/hello-parser-regex.result rename to tests/results/examples/hello/hello-parser-regex.0.result diff --git a/tests/results/examples/hello/hello-roles-array.result b/tests/results/examples/hello/hello-roles-array.0.result similarity index 100% rename from tests/results/examples/hello/hello-roles-array.result rename to tests/results/examples/hello/hello-roles-array.0.result diff --git a/tests/results/examples/hello/hello.result b/tests/results/examples/hello/hello.0.result similarity index 100% rename from tests/results/examples/hello/hello.result rename to tests/results/examples/hello/hello.0.result diff --git a/tests/results/examples/input/input_test.result b/tests/results/examples/input/input_test.0.result similarity index 100% rename from tests/results/examples/input/input_test.result rename to tests/results/examples/input/input_test.0.result diff --git a/tests/results/examples/input/input_test1.result b/tests/results/examples/input/input_test1.0.result similarity index 100% rename from tests/results/examples/input/input_test1.result rename to tests/results/examples/input/input_test1.0.result diff --git a/tests/results/examples/input/input_test2.result b/tests/results/examples/input/input_test2.0.result similarity index 100% rename from tests/results/examples/input/input_test2.result rename to tests/results/examples/input/input_test2.0.result diff --git a/tests/results/examples/react/demo.result b/tests/results/examples/react/demo.0.result similarity index 100% rename from tests/results/examples/react/demo.result rename to tests/results/examples/react/demo.0.result diff --git a/tests/results/examples/react/react_fun.result b/tests/results/examples/react/react_fun.0.result similarity index 100% rename from tests/results/examples/react/react_fun.result rename to tests/results/examples/react/react_fun.0.result diff --git a/tests/results/examples/react/wikipedia.result b/tests/results/examples/react/wikipedia.0.result similarity index 100% rename from tests/results/examples/react/wikipedia.result rename to tests/results/examples/react/wikipedia.0.result diff --git a/tests/results/examples/sdk/hello.result b/tests/results/examples/sdk/hello.0.result similarity index 100% rename from tests/results/examples/sdk/hello.result rename to tests/results/examples/sdk/hello.0.result diff --git a/tests/results/examples/talk/1-hello.result b/tests/results/examples/talk/1-hello.0.result similarity index 100% rename from tests/results/examples/talk/1-hello.result rename to tests/results/examples/talk/1-hello.0.result diff --git a/tests/results/examples/talk/11-repeat.result b/tests/results/examples/talk/11-repeat.0.result similarity index 100% rename from tests/results/examples/talk/11-repeat.result rename to tests/results/examples/talk/11-repeat.0.result diff --git a/tests/results/examples/talk/2-model-chaining.result b/tests/results/examples/talk/2-model-chaining.0.result similarity index 100% rename from tests/results/examples/talk/2-model-chaining.result rename to tests/results/examples/talk/2-model-chaining.0.result diff --git a/tests/results/examples/talk/3-def-use.result b/tests/results/examples/talk/3-def-use.0.result similarity index 100% rename from tests/results/examples/talk/3-def-use.result rename to tests/results/examples/talk/3-def-use.0.result diff --git a/tests/results/examples/talk/4-function.result b/tests/results/examples/talk/4-function.0.result similarity index 100% rename from tests/results/examples/talk/4-function.result rename to tests/results/examples/talk/4-function.0.result diff --git a/tests/results/examples/talk/5-code-eval.result b/tests/results/examples/talk/5-code-eval.0.result similarity index 100% rename from tests/results/examples/talk/5-code-eval.result rename to tests/results/examples/talk/5-code-eval.0.result diff --git a/tests/results/examples/talk/6-code-json.result b/tests/results/examples/talk/6-code-json.0.result similarity index 100% rename from tests/results/examples/talk/6-code-json.result rename to tests/results/examples/talk/6-code-json.0.result diff --git a/tests/results/examples/talk/7-chatbot-roles.result b/tests/results/examples/talk/7-chatbot-roles.0.result similarity index 100% rename from tests/results/examples/talk/7-chatbot-roles.result rename to tests/results/examples/talk/7-chatbot-roles.0.result diff --git a/tests/results/examples/talk/9-react.result b/tests/results/examples/talk/9-react.0.result similarity index 100% rename from tests/results/examples/talk/9-react.result rename to tests/results/examples/talk/9-react.0.result diff --git a/tests/results/examples/tutorial/calling_code.result b/tests/results/examples/tutorial/calling_code.0.result similarity index 100% rename from tests/results/examples/tutorial/calling_code.result rename to tests/results/examples/tutorial/calling_code.0.result diff --git a/tests/results/examples/tutorial/calling_llm.result b/tests/results/examples/tutorial/calling_llm.0.result similarity index 100% rename from tests/results/examples/tutorial/calling_llm.result rename to tests/results/examples/tutorial/calling_llm.0.result diff --git a/tests/results/examples/tutorial/calling_llm_with_input.result b/tests/results/examples/tutorial/calling_llm_with_input.0.result similarity index 100% rename from tests/results/examples/tutorial/calling_llm_with_input.result rename to tests/results/examples/tutorial/calling_llm_with_input.0.result diff --git a/tests/results/examples/tutorial/calling_llm_with_input_messages.result b/tests/results/examples/tutorial/calling_llm_with_input_messages.0.result similarity index 100% rename from tests/results/examples/tutorial/calling_llm_with_input_messages.result rename to tests/results/examples/tutorial/calling_llm_with_input_messages.0.result diff --git a/tests/results/examples/tutorial/conditionals_loops.result b/tests/results/examples/tutorial/conditionals_loops.0.result similarity index 100% rename from tests/results/examples/tutorial/conditionals_loops.result rename to tests/results/examples/tutorial/conditionals_loops.0.result diff --git a/tests/results/examples/tutorial/data_block.result b/tests/results/examples/tutorial/data_block.0.result similarity index 100% rename from tests/results/examples/tutorial/data_block.result rename to tests/results/examples/tutorial/data_block.0.result diff --git a/tests/results/examples/tutorial/data_block_raw.result b/tests/results/examples/tutorial/data_block_raw.0.result similarity index 100% rename from tests/results/examples/tutorial/data_block_raw.result rename to tests/results/examples/tutorial/data_block_raw.0.result diff --git a/tests/results/examples/tutorial/for.result b/tests/results/examples/tutorial/for.0.result similarity index 100% rename from tests/results/examples/tutorial/for.result rename to tests/results/examples/tutorial/for.0.result diff --git a/tests/results/examples/tutorial/for_array.result b/tests/results/examples/tutorial/for_array.0.result similarity index 100% rename from tests/results/examples/tutorial/for_array.result rename to tests/results/examples/tutorial/for_array.0.result diff --git a/tests/results/examples/tutorial/for_multiplie_lists.result b/tests/results/examples/tutorial/for_multiplie_lists.0.result similarity index 100% rename from tests/results/examples/tutorial/for_multiplie_lists.result rename to tests/results/examples/tutorial/for_multiplie_lists.0.result diff --git a/tests/results/examples/tutorial/for_with.result b/tests/results/examples/tutorial/for_with.0.result similarity index 100% rename from tests/results/examples/tutorial/for_with.result rename to tests/results/examples/tutorial/for_with.0.result diff --git a/tests/results/examples/tutorial/function_definition.result b/tests/results/examples/tutorial/function_definition.0.result similarity index 100% rename from tests/results/examples/tutorial/function_definition.result rename to tests/results/examples/tutorial/function_definition.0.result diff --git a/tests/results/examples/tutorial/grouping_definitions.result b/tests/results/examples/tutorial/grouping_definitions.0.result similarity index 100% rename from tests/results/examples/tutorial/grouping_definitions.result rename to tests/results/examples/tutorial/grouping_definitions.0.result diff --git a/tests/results/examples/tutorial/include.result b/tests/results/examples/tutorial/include.0.result similarity index 100% rename from tests/results/examples/tutorial/include.result rename to tests/results/examples/tutorial/include.0.result diff --git a/tests/results/examples/tutorial/input_file.result b/tests/results/examples/tutorial/input_file.0.result similarity index 100% rename from tests/results/examples/tutorial/input_file.result rename to tests/results/examples/tutorial/input_file.0.result diff --git a/tests/results/examples/tutorial/input_file_json.result b/tests/results/examples/tutorial/input_file_json.0.result similarity index 100% rename from tests/results/examples/tutorial/input_file_json.result rename to tests/results/examples/tutorial/input_file_json.0.result diff --git a/tests/results/examples/tutorial/input_stdin.result b/tests/results/examples/tutorial/input_stdin.0.result similarity index 100% rename from tests/results/examples/tutorial/input_stdin.result rename to tests/results/examples/tutorial/input_stdin.0.result diff --git a/tests/results/examples/tutorial/input_stdin_multiline.result b/tests/results/examples/tutorial/input_stdin_multiline.0.result similarity index 100% rename from tests/results/examples/tutorial/input_stdin_multiline.result rename to tests/results/examples/tutorial/input_stdin_multiline.0.result diff --git a/tests/results/examples/tutorial/model_chaining.result b/tests/results/examples/tutorial/model_chaining.0.result similarity index 100% rename from tests/results/examples/tutorial/model_chaining.result rename to tests/results/examples/tutorial/model_chaining.0.result diff --git a/tests/results/examples/tutorial/muting_block_output.result b/tests/results/examples/tutorial/muting_block_output.0.result similarity index 100% rename from tests/results/examples/tutorial/muting_block_output.result rename to tests/results/examples/tutorial/muting_block_output.0.result diff --git a/tests/results/examples/tutorial/simple_program.result b/tests/results/examples/tutorial/simple_program.0.result similarity index 100% rename from tests/results/examples/tutorial/simple_program.result rename to tests/results/examples/tutorial/simple_program.0.result diff --git a/tests/results/examples/tutorial/variable_def_use.result b/tests/results/examples/tutorial/variable_def_use.0.result similarity index 100% rename from tests/results/examples/tutorial/variable_def_use.result rename to tests/results/examples/tutorial/variable_def_use.0.result diff --git a/tests/results/examples/weather/weather.0.result b/tests/results/examples/weather/weather.0.result new file mode 100644 index 000000000..f6daf54d8 --- /dev/null +++ b/tests/results/examples/weather/weather.0.result @@ -0,0 +1 @@ +The current weather in Yorktown Heights, New York, USA is partly cloudy with a temperature of 57.0°F (13.9°C). The wind is blowing at 4.9 mph (7.9 kph) from the north-northwest (NNW) direction. The pressure is 29.87 inches of mercury (1012.0 mb). Humidity is at 40% and the dew point is 40.3°F (4.6°C). Visibility is 9.0 miles (16.0 km). The UV index is 0.6 and the wind gusts up to 6.0 mph (9.6 kph). diff --git a/tests/results/examples/weather/weather.result b/tests/results/examples/weather/weather.result deleted file mode 100644 index 1812accfb..000000000 --- a/tests/results/examples/weather/weather.result +++ /dev/null @@ -1 +0,0 @@ -The current weather in Yorktown Heights, New York, USA is sunny with a temperature of 48.0°F (8.9°C). The wind is blowing at 4.0 mph (6.5 kph) from the southeast (ESE). The pressure is 30.55 inches of mercury (1035.0 mb). Humidity is at 46% and the dew point is 33.9°F (1.1°C). Visibility is 9.0 miles (16.0 km). The UV index is 1.9 and the wind gusts up to 5.2 mph (8.3 kph). diff --git a/tests/results/tests/data/function.result b/tests/results/tests/data/function.0.result similarity index 100% rename from tests/results/tests/data/function.result rename to tests/results/tests/data/function.0.result diff --git a/tests/results/tests/data/hello.result b/tests/results/tests/data/hello.0.result similarity index 100% rename from tests/results/tests/data/hello.result rename to tests/results/tests/data/hello.0.result diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index ff6569add..e57b00283 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -179,23 +179,27 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - result_dir_name = ( pathlib.Path(".") / "tests" / "results" / pdl_file_name.parent ) - result_file_name = pdl_file_name.stem + ".result" if UPDATE_RESULTS: + result_file_name_0 = pdl_file_name.stem + ".0.result" result_dir_name.mkdir(parents=True, exist_ok=True) with open( - result_dir_name / result_file_name, "w", encoding="utf-8" + result_dir_name / result_file_name_0, "w", encoding="utf-8" ) as result_file: print(str(result), file=result_file) if str(pdl_file_name) in NOT_DETERMINISTIC: continue - with open( - result_dir_name / result_file_name, "r", encoding="utf-8" - ) as result_file: - expected_result = str(result_file.read()) - if str(result).strip() != expected_result.strip(): + wrong_result = True + for result_file_name in result_dir_name.glob(pdl_file_name.stem + ".*.pdl"): + with open( + result_dir_name / result_file_name, "r", encoding="utf-8" + ) as result_file: + expected_result = str(result_file.read()) + if str(result).strip() == expected_result.strip(): + wrong_result = False + + if wrong_result: wrong_results[str(pdl_file_name)] = { "actual": str(result), - "expected": str(expected_result), } except PDLParseError: actual_parse_error |= {str(pdl_file_name)} From e784b3e36f28ead104fd082c262440a42858afdb Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 03:11:21 -0500 Subject: [PATCH 02/17] More results --- .../results/examples/code/code-eval.1.result | 24 ++++++++++ .../examples/tutorial/include.1.result | 15 +++++++ .../results/examples/weather/weather.0.result | 1 - tests/test_examples_run.py | 45 ++++++------------- 4 files changed, 52 insertions(+), 33 deletions(-) create mode 100644 tests/results/examples/code/code-eval.1.result create mode 100644 tests/results/examples/tutorial/include.1.result delete mode 100644 tests/results/examples/weather/weather.0.result diff --git a/tests/results/examples/code/code-eval.1.result b/tests/results/examples/code/code-eval.1.result new file mode 100644 index 000000000..a75571f1c --- /dev/null +++ b/tests/results/examples/code/code-eval.1.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object. +4. Finally, the method returns the `offsetMap`, which now contains the deserialized data. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. The compiler would normally warn about this, but the annotation suppresses that warning. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.3091666666666667 diff --git a/tests/results/examples/tutorial/include.1.result b/tests/results/examples/tutorial/include.1.result new file mode 100644 index 000000000..dac0e1932 --- /dev/null +++ b/tests/results/examples/tutorial/include.1.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells us what we'll pay, or earn, you see. +It's the annual rate, both simple and clear, +Including all fees, for loans and investments, near and far. + +It's the cost of borrowing, or the return we gain, +A figure that helps us make informed financial gain. +So, when you're comparing loans or investments, don't forget, +The APR is the number that you should always check. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your parents to buy a toy. Your parents will ask you to pay them back with some extra money, which is like interest. APR is the special number that tells you how much extra money you'll have to pay back, all in one year. It's like a special rule that helps you understand how much you'll have to pay back for borrowing money. diff --git a/tests/results/examples/weather/weather.0.result b/tests/results/examples/weather/weather.0.result deleted file mode 100644 index f6daf54d8..000000000 --- a/tests/results/examples/weather/weather.0.result +++ /dev/null @@ -1 +0,0 @@ -The current weather in Yorktown Heights, New York, USA is partly cloudy with a temperature of 57.0°F (13.9°C). The wind is blowing at 4.9 mph (7.9 kph) from the north-northwest (NNW) direction. The pressure is 29.87 inches of mercury (1012.0 mb). Humidity is at 40% and the dew point is 40.3°F (4.6°C). Visibility is 9.0 miles (16.0 km). The UV index is 0.6 and the wind gusts up to 6.0 mph (9.6 kph). diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index e57b00283..44c6c7864 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -38,25 +38,8 @@ NOT_DETERMINISTIC = { str(name) for name in [ - pathlib.Path("examples") / "granite" / "multi_round_chat.pdl", - pathlib.Path("examples") / "granite" / "single_round_chat.pdl", - pathlib.Path("examples") / "joke" / "Joke.pdl", - pathlib.Path("examples") / "react" / "multi-agent.pdl", - pathlib.Path("examples") / "react" / "wikipedia.pdl", - pathlib.Path("examples") / "talk" / "10-sdg.pdl", - pathlib.Path("examples") / "talk" / "7-chatbot-roles.pdl", - pathlib.Path("examples") / "chatbot" / "chatbot.pdl", - pathlib.Path("examples") / "talk" / "8-tools.pdl", - pathlib.Path("examples") / "talk" / "9-react.pdl", - pathlib.Path("examples") / "teacher" / "teacher.pdl", - pathlib.Path("examples") / "tools" / "calc.pdl", - pathlib.Path("examples") / "tutorial" / "include.pdl", - pathlib.Path("examples") / "hello" / "hello-roles-array.pdl", pathlib.Path("examples") / "weather" / "weather.pdl", pathlib.Path("examples") / "demo" / "3-weather.pdl", - pathlib.Path("examples") / "tutorial" / "conditionals_loops.pdl", - pathlib.Path("examples") / "chatbot" / "chatbot.pdl", - pathlib.Path("examples") / "fibonacci" / "fib.pdl", ] } @@ -179,28 +162,26 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - result_dir_name = ( pathlib.Path(".") / "tests" / "results" / pdl_file_name.parent ) - if UPDATE_RESULTS: - result_file_name_0 = pdl_file_name.stem + ".0.result" - result_dir_name.mkdir(parents=True, exist_ok=True) - with open( - result_dir_name / result_file_name_0, "w", encoding="utf-8" - ) as result_file: - print(str(result), file=result_file) if str(pdl_file_name) in NOT_DETERMINISTIC: continue wrong_result = True - for result_file_name in result_dir_name.glob(pdl_file_name.stem + ".*.pdl"): - with open( - result_dir_name / result_file_name, "r", encoding="utf-8" - ) as result_file: + for result_file_name in result_dir_name.glob(pdl_file_name.stem + ".*.result"): + with open(result_file_name, "r", encoding="utf-8") as result_file: expected_result = str(result_file.read()) if str(result).strip() == expected_result.strip(): wrong_result = False - if wrong_result: - wrong_results[str(pdl_file_name)] = { - "actual": str(result), - } + if UPDATE_RESULTS: + result_file_name_0 = pdl_file_name.stem + f".1.result" + result_dir_name.mkdir(parents=True, exist_ok=True) + with open( + result_dir_name / result_file_name_0, "w", encoding="utf-8" + ) as result_file: + print(str(result), file=result_file) + else: + wrong_results[str(pdl_file_name)] = { + "actual": str(result), + } except PDLParseError: actual_parse_error |= {str(pdl_file_name)} except PDLRuntimeError as exc: From ca9be70119c6ba8f52f9ee4124eda57d1d9025d8 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 03:23:05 -0500 Subject: [PATCH 03/17] Add possible result --- .../examples/granite/multi_round_chat.1.result | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/results/examples/granite/multi_round_chat.1.result diff --git a/tests/results/examples/granite/multi_round_chat.1.result b/tests/results/examples/granite/multi_round_chat.1.result new file mode 100644 index 000000000..61c3d8166 --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.1.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for you to install. +Whether borrowing or saving, APR is the guide, +To make informed decisions, with confidence, you'll abide. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank where you save your money. Now, if you want to borrow some money from a friend, they might ask you to pay them back with a little extra. This extra amount is like the APR. It's the extra money you have to pay back, on top of the amount you borrowed. It's like a small fee for using their money. \ No newline at end of file From 84b682e1e60f9c418ec8bf49090e0dea39ce5b2f Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 03:33:26 -0500 Subject: [PATCH 04/17] Formatting --- tests/test_examples_run.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index 44c6c7864..0ee28ec64 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -165,14 +165,16 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - if str(pdl_file_name) in NOT_DETERMINISTIC: continue wrong_result = True - for result_file_name in result_dir_name.glob(pdl_file_name.stem + ".*.result"): + for result_file_name in result_dir_name.glob( + pdl_file_name.stem + ".*.result" + ): with open(result_file_name, "r", encoding="utf-8") as result_file: expected_result = str(result_file.read()) if str(result).strip() == expected_result.strip(): wrong_result = False if wrong_result: if UPDATE_RESULTS: - result_file_name_0 = pdl_file_name.stem + f".1.result" + result_file_name_0 = pdl_file_name.stem + ".1.result" result_dir_name.mkdir(parents=True, exist_ok=True) with open( result_dir_name / result_file_name_0, "w", encoding="utf-8" From 0b0e01bd8c18a1d561764669b548201eb7abdb96 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 06:21:14 -0500 Subject: [PATCH 05/17] More results --- .../results/examples/code/code-eval.1.result | 4 +- .../results/examples/code/code-eval.2.result | 24 +++++++++++ .../results/examples/code/code-eval.3.result | 24 +++++++++++ tests/results/examples/code/code.1.result | 21 +++++++++ tests/results/examples/code/code.2.result | 20 +++++++++ tests/results/examples/fibonacci/fib.2.result | 43 +++++++++++++++++++ .../granite/multi_round_chat.2.result | 15 +++++++ .../granite/multi_round_chat.3.result | 26 +++++++++++ .../granite/multi_round_chat.4.result | 15 +++++++ .../examples/hello/hello-roles-array.1.result | 42 ++++++++++++++++++ .../examples/hello/hello-roles-array.2.result | 42 ++++++++++++++++++ .../examples/hello/hello-roles-array.3.result | 42 ++++++++++++++++++ .../examples/talk/5-code-eval.1.result | 24 +++++++++++ .../examples/talk/5-code-eval.2.result | 24 +++++++++++ .../examples/talk/5-code-eval.3.result | 24 +++++++++++ .../examples/talk/7-chatbot-roles.2.result | 8 ++++ .../tutorial/conditionals_loops.1.result | 4 ++ .../examples/tutorial/include.2.result | 15 +++++++ .../examples/tutorial/include.3.result | 15 +++++++ .../examples/tutorial/include.4.result | 24 +++++++++++ .../tutorial/muting_block_output.2.result | 1 + tests/test_examples_run.py | 11 +++-- 22 files changed, 460 insertions(+), 8 deletions(-) create mode 100644 tests/results/examples/code/code-eval.2.result create mode 100644 tests/results/examples/code/code-eval.3.result create mode 100644 tests/results/examples/code/code.1.result create mode 100644 tests/results/examples/code/code.2.result create mode 100644 tests/results/examples/fibonacci/fib.2.result create mode 100644 tests/results/examples/granite/multi_round_chat.2.result create mode 100644 tests/results/examples/granite/multi_round_chat.3.result create mode 100644 tests/results/examples/granite/multi_round_chat.4.result create mode 100644 tests/results/examples/hello/hello-roles-array.1.result create mode 100644 tests/results/examples/hello/hello-roles-array.2.result create mode 100644 tests/results/examples/hello/hello-roles-array.3.result create mode 100644 tests/results/examples/talk/5-code-eval.1.result create mode 100644 tests/results/examples/talk/5-code-eval.2.result create mode 100644 tests/results/examples/talk/5-code-eval.3.result create mode 100644 tests/results/examples/talk/7-chatbot-roles.2.result create mode 100644 tests/results/examples/tutorial/conditionals_loops.1.result create mode 100644 tests/results/examples/tutorial/include.2.result create mode 100644 tests/results/examples/tutorial/include.3.result create mode 100644 tests/results/examples/tutorial/include.4.result create mode 100644 tests/results/examples/tutorial/muting_block_output.2.result diff --git a/tests/results/examples/code/code-eval.1.result b/tests/results/examples/code/code-eval.1.result index a75571f1c..28676ea5b 100644 --- a/tests/results/examples/code/code-eval.1.result +++ b/tests/results/examples/code/code-eval.1.result @@ -17,8 +17,8 @@ This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string i 3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object. 4. Finally, the method returns the `offsetMap`, which now contains the deserialized data. -The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. The compiler would normally warn about this, but the annotation suppresses that warning. +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. Since the actual type of the map is not known at compile time, the compiler issues a warning. The `@SuppressWarnings` annotation is used to suppress this warning. EVALUATION: The similarity (Levenshtein) between this answer and the ground truth is: -0.3091666666666667 +0.34065934065934067 diff --git a/tests/results/examples/code/code-eval.2.result b/tests/results/examples/code/code-eval.2.result new file mode 100644 index 000000000..1c1a3fab1 --- /dev/null +++ b/tests/results/examples/code/code-eval.2.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object. +4. Finally, the method returns the `offsetMap`, which now contains the deserialized data. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. The compiler knows that the actual type of the `Map` is safe, but it still generates a warning. The `@SuppressWarnings` annotation is used to suppress this warning. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.32053291536050155 diff --git a/tests/results/examples/code/code-eval.3.result b/tests/results/examples/code/code-eval.3.result new file mode 100644 index 000000000..0805afcb4 --- /dev/null +++ b/tests/results/examples/code/code-eval.3.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes a new `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map` and assigns it to `offsetMap`. +4. Finally, it returns the `offsetMap`. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a compile-time warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the compiler doesn't know that it's safe to cast it to `Map`. However, since the method is designed to handle only `Map` objects, this warning can be safely ignored. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.3528336380255942 diff --git a/tests/results/examples/code/code.1.result b/tests/results/examples/code/code.1.result new file mode 100644 index 000000000..60f71984b --- /dev/null +++ b/tests/results/examples/code/code.1.result @@ -0,0 +1,21 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It initializes a `Map` called `offsetMap`. +3. If `lastSourceOffset` is either `null` or an empty string, it creates a new `HashMap` and assigns it to `offsetMap`. +4. If `lastSourceOffset` is not `null` or an empty string, it uses the `JSON_MAPPER` object (which is presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map` and assigns it to `offsetMap`. +5. Finally, it returns the `offsetMap`. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a compile-time warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the compiler doesn't know that this `Map` will be a `Map`. The `unchecked` warning is suppressed to avoid cluttering the output with this warning. diff --git a/tests/results/examples/code/code.2.result b/tests/results/examples/code/code.2.result new file mode 100644 index 000000000..b60f95d0e --- /dev/null +++ b/tests/results/examples/code/code.2.result @@ -0,0 +1,20 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object. +4. Finally, the method returns the `offsetMap`, which now contains the deserialized data. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. The compiler would normally warn about this, but the annotation suppresses that warning. diff --git a/tests/results/examples/fibonacci/fib.2.result b/tests/results/examples/fibonacci/fib.2.result new file mode 100644 index 000000000..6f1e1b112 --- /dev/null +++ b/tests/results/examples/fibonacci/fib.2.result @@ -0,0 +1,43 @@ +Here is a simple Python function to compute the Fibonacci sequence: + +```python +def fibonacci(n): + if n <= 0: + return "Input should be a positive integer." + elif n == 1: + return 0 + elif n == 2: + return 1 + else: + a, b = 0, 1 + for _ in range(n - 2): + a, b = b, a + b + return b +``` + +This function takes an integer `n` as input and returns the `n`th number in the Fibonacci sequence. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. +Find a random number between 1 and 20 +15 +Now computing fibonacci(15) + +def fibonacci(n): + if n <= 0: + return "Input should be a positive integer." + elif n == 1: + return 0 + elif n == 2: + return 1 + else: + a, b = 0, 1 + for _ in range(n - 2): + a, b = b, a + b + return b +The result is: 377 + +Explain what the above code does and what the result means + +The provided code is a Python function named `fibonacci(n)` that computes the `n`th number in the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. + +The function takes an integer `n` as input and returns the `n`th number in the Fibonacci sequence. It first checks if the input is a positive integer and returns an error message if it's not. If the input is 1, it returns 0 (the first number in the Fibonacci sequence). If the input is 2, it returns 1 (the second number in the Fibonacci sequence). For any other positive integer input, it uses a loop to calculate the `n`th number in the Fibonacci sequence and returns the result. + +In the given example, the function is called with the argument `15`, so it computes the 15th number in the Fibonacci sequence. The result is `377`, which means that the 15th number in the Fibonacci sequence is 377. diff --git a/tests/results/examples/granite/multi_round_chat.2.result b/tests/results/examples/granite/multi_round_chat.2.result new file mode 100644 index 000000000..bea2adf51 --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.2.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells us what we'll pay, or earn, you see. +It's the annual rate, both simple and clear, +Including all fees, for loans and investments, near and far. + +It's the cost of borrowing, or the return we get, +A number that helps us make informed financial bets. +So, when you're comparing loans, or investments to choose, +Remember APR, and make the right move. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your parents to buy a toy. Your parents will charge you a little bit of money each year to borrow that money. The APR is like a special number that tells you how much money you'll have to pay back each year, including any extra fees. It helps you understand how much the loan will really cost you. diff --git a/tests/results/examples/granite/multi_round_chat.3.result b/tests/results/examples/granite/multi_round_chat.3.result new file mode 100644 index 000000000..1835d6f35 --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.3.result @@ -0,0 +1,26 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or saving, it's a helpful tool, +To make informed decisions, and avoid a financial fool. + +So remember APR, when you're in the market, +For loans or investments, it's a vital factor. +It's the annual rate, that tells you the cost, +In the world of finance, it's a helpful host. +Now explain APR to me like I'm 5 years old +Sure! So, imagine you have a piggy bank and you want to borrow some money from your parents to buy a toy. Your parents might ask you to pay them back with a little extra money, like an extra dollar for every dollar you borrow. This extra money is like the interest you pay on a loan. + +Now, APR is like a special way to measure how much extra money you have to pay back. It tells you how much interest you'll pay each year, based on the amount you borrowed and the interest rate your parents set. + +So, if your parents say the APR is 10%, that means you'll have to pay back 10% more than you borrowed each year. For example, if you borrow $10, you'll have to pay back $11 at the end of the year. + +APR is important because it helps you understand how much you'll have to pay back when you borrow money, and it can help you make better decisions about loans and investments. diff --git a/tests/results/examples/granite/multi_round_chat.4.result b/tests/results/examples/granite/multi_round_chat.4.result new file mode 100644 index 000000000..a278adfad --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.4.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells us what we'll pay, or earn, you see. +It's the annual rate, both simple and clear, +Including all fees, for loans and investments, near and far. + +It's the cost of borrowing, or the return we gain, +A figure that helps us make informed financial gain. +So, when you're comparing loans, or investments to choose, +Remember APR, and make the right move. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your parents to buy a toy. Your parents will charge you a little bit of money each year to borrow that money. The APR is like a special number that tells you how much money you'll have to pay back each year, including any extra fees. It helps you understand how much the loan will cost you in the long run. diff --git a/tests/results/examples/hello/hello-roles-array.1.result b/tests/results/examples/hello/hello-roles-array.1.result new file mode 100644 index 000000000..b732c9f80 --- /dev/null +++ b/tests/results/examples/hello/hello-roles-array.1.result @@ -0,0 +1,42 @@ +Here is a Python function that implements the merge sort algorithm: + +```python +def merge_sort(arr): + # Base case: if the array has 1 or 0 elements, it's already sorted + if len(arr) <= 1: + return arr + + # Split the array into two halves + mid = len(arr) // 2 + left_half = arr[:mid] + right_half = arr[mid:] + + # Recursively sort both halves + left_half = merge_sort(left_half) + right_half = merge_sort(right_half) + + # Merge the sorted halves + return merge(left_half, right_half) + +def merge(left, right): + merged = [] + left_index = 0 + right_index = 0 + + # Merge the two halves, keeping them sorted + while left_index < len(left) and right_index < len(right): + if left[left_index] < right[right_index]: + merged.append(left[left_index]) + left_index += 1 + else: + merged.append(right[right_index]) + right_index += 1 + + # Add any remaining elements from the left and right halves + merged.extend(left[left_index:]) + merged.extend(right[right_index:]) + + return merged +``` + +This function first checks if the input array has 1 or 0 elements, in which case it's already sorted. If not, it splits the array into two halves and recursively sorts each half using the merge sort algorithm. Finally, it merges the two sorted halves back together. diff --git a/tests/results/examples/hello/hello-roles-array.2.result b/tests/results/examples/hello/hello-roles-array.2.result new file mode 100644 index 000000000..860dd65ed --- /dev/null +++ b/tests/results/examples/hello/hello-roles-array.2.result @@ -0,0 +1,42 @@ +Here is a Python function that implements the merge sort algorithm: + +```python +def merge_sort(arr): + # Base case: if the array has 1 or 0 elements, it's already sorted + if len(arr) <= 1: + return arr + + # Split the array into two halves + mid = len(arr) // 2 + left_half = arr[:mid] + right_half = arr[mid:] + + # Recursively sort both halves + left_sorted = merge_sort(left_half) + right_sorted = merge_sort(right_half) + + # Merge the sorted halves + return merge(left_sorted, right_sorted) + +def merge(left, right): + merged = [] + left_index = 0 + right_index = 0 + + # Merge the two halves, keeping the array sorted + while left_index < len(left) and right_index < len(right): + if left[left_index] < right[right_index]: + merged.append(left[left_index]) + left_index += 1 + else: + merged.append(right[right_index]) + right_index += 1 + + # Add any remaining elements from the left and right halves + merged.extend(left[left_index:]) + merged.extend(right[right_index:]) + + return merged +``` + +This function first checks if the input array has 1 or 0 elements, in which case it's already sorted. If not, it splits the array into two halves and recursively sorts each half using the merge sort algorithm. Finally, it merges the two sorted halves back together. diff --git a/tests/results/examples/hello/hello-roles-array.3.result b/tests/results/examples/hello/hello-roles-array.3.result new file mode 100644 index 000000000..aa2dc2102 --- /dev/null +++ b/tests/results/examples/hello/hello-roles-array.3.result @@ -0,0 +1,42 @@ +Here is a Python function that implements the merge sort algorithm: + +```python +def merge_sort(arr): + # Base case: if the array has 1 or 0 elements, it's already sorted + if len(arr) <= 1: + return arr + + # Split the array into two halves + mid = len(arr) // 2 + left_half = arr[:mid] + right_half = arr[mid:] + + # Recursively sort both halves + left_sorted = merge_sort(left_half) + right_sorted = merge_sort(right_half) + + # Merge the sorted halves + return merge(left_sorted, right_sorted) + +def merge(left, right): + merged = [] + left_index = 0 + right_index = 0 + + # Merge the two halves, keeping the array sorted + while left_index < len(left) and right_index < len(right): + if left[left_index] < right[right_index]: + merged.append(left[left_index]) + left_index += 1 + else: + merged.append(right[right_index]) + right_index += 1 + + # Add any remaining elements from the left and right halves + merged.extend(left[left_index:]) + merged.extend(right[right_index:]) + + return merged +``` + +This function first checks if the input array has 1 or 0 elements, in which case it's already sorted. If not, it splits the array into two halves and recursively sorts each half using the merge sort algorithm. Finally, it merges the two sorted halves back together, keeping the array sorted. diff --git a/tests/results/examples/talk/5-code-eval.1.result b/tests/results/examples/talk/5-code-eval.1.result new file mode 100644 index 000000000..afd312c1f --- /dev/null +++ b/tests/results/examples/talk/5-code-eval.1.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes a new `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map` and assigns it to `offsetMap`. +4. Finally, it returns the `offsetMap`. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a compile-time warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the compiler doesn't know that it's safe to cast it to `Map`. However, in this case, the method is designed to always return a `Map`, so the warning can be safely suppressed. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.3508612873980055 diff --git a/tests/results/examples/talk/5-code-eval.2.result b/tests/results/examples/talk/5-code-eval.2.result new file mode 100644 index 000000000..7473b9762 --- /dev/null +++ b/tests/results/examples/talk/5-code-eval.2.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object. +4. Finally, the method returns the `offsetMap`, which now contains the deserialized data. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. The compiler knows that the actual type of the `Map` is safe, but it still generates a warning. The `@SuppressWarnings` annotation is used to suppress this warning. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.32131661442006265 diff --git a/tests/results/examples/talk/5-code-eval.3.result b/tests/results/examples/talk/5-code-eval.3.result new file mode 100644 index 000000000..c8e03aef1 --- /dev/null +++ b/tests/results/examples/talk/5-code-eval.3.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object. +4. Finally, the method returns the `offsetMap`, which now contains the deserialized data. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. Since the actual type of the map is not known at compile time, the compiler issues a warning. The `@SuppressWarnings` annotation is used to suppress this warning. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.34144427001569855 diff --git a/tests/results/examples/talk/7-chatbot-roles.2.result b/tests/results/examples/talk/7-chatbot-roles.2.result new file mode 100644 index 000000000..2360b04f5 --- /dev/null +++ b/tests/results/examples/talk/7-chatbot-roles.2.result @@ -0,0 +1,8 @@ +Type `quit` to exit this chatbot. +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. APR is typically higher than the interest rate because it includes any fees or additional costs associated with the loan. + + + +I'm sorry to see you go. If you have any more questions in the future, feel free to come back. Have a great day! + + diff --git a/tests/results/examples/tutorial/conditionals_loops.1.result b/tests/results/examples/tutorial/conditionals_loops.1.result new file mode 100644 index 000000000..2d5076134 --- /dev/null +++ b/tests/results/examples/tutorial/conditionals_loops.1.result @@ -0,0 +1,4 @@ +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction.Say it as a poemAPR, a rate so grand, +Annual Percentage Rate, across the land. +It's the cost of borrowing, or earning, you see, +Including fees, for a year, it's the key. diff --git a/tests/results/examples/tutorial/include.2.result b/tests/results/examples/tutorial/include.2.result new file mode 100644 index 000000000..f0d7ee943 --- /dev/null +++ b/tests/results/examples/tutorial/include.2.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells us what we'll pay, or earn, you see. +It's the annual rate, both simple and clear, +Including all fees, for loans and investments, near and far. + +It's the cost of borrowing, or the return we get, +A number that helps us make informed financial bets. +So, when you're comparing loans, or investments to choose, +Look for the APR, and make your decision, with a clear view. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your parents to buy a toy. Your parents will charge you some money to borrow that toy, and that's like the APR. It's the amount of money you have to pay back, including any extra fees, every year. So, if you borrow $10 and the APR is 10%, you'll have to pay back $11 at the end of the year. diff --git a/tests/results/examples/tutorial/include.3.result b/tests/results/examples/tutorial/include.3.result new file mode 100644 index 000000000..a278adfad --- /dev/null +++ b/tests/results/examples/tutorial/include.3.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells us what we'll pay, or earn, you see. +It's the annual rate, both simple and clear, +Including all fees, for loans and investments, near and far. + +It's the cost of borrowing, or the return we gain, +A figure that helps us make informed financial gain. +So, when you're comparing loans, or investments to choose, +Remember APR, and make the right move. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your parents to buy a toy. Your parents will charge you a little bit of money each year to borrow that money. The APR is like a special number that tells you how much money you'll have to pay back each year, including any extra fees. It helps you understand how much the loan will cost you in the long run. diff --git a/tests/results/examples/tutorial/include.4.result b/tests/results/examples/tutorial/include.4.result new file mode 100644 index 000000000..34341b0d6 --- /dev/null +++ b/tests/results/examples/tutorial/include.4.result @@ -0,0 +1,24 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or saving, it's a helpful tool, +To make informed decisions, and avoid a financial fool. + +So remember APR, when you're in the market, +For loans or investments, it's a vital factor. +It's the annual rate, that tells you the cost, +In the world of finance, it's a helpful host. +Now explain APR to me like I'm 5 years old +Sure! So, imagine you have a piggy bank and you want to borrow some money from your parents to buy a toy. Your parents might ask you to pay them back with a little extra money, like an extra dollar for every dollar you borrow. This extra money is like the interest you pay on a loan. + +Now, APR is like a special way to measure how much extra money you have to pay back. It tells you how much interest you'll pay each year, based on the amount you borrowed and the interest rate your parents set. + +So, if your parents say the APR is 10%, it means you'll have to pay back 10% more than you borrowed each year. That way, you can understand how much you'll have to pay back and make sure you can afford it. diff --git a/tests/results/examples/tutorial/muting_block_output.2.result b/tests/results/examples/tutorial/muting_block_output.2.result new file mode 100644 index 000000000..e2af10175 --- /dev/null +++ b/tests/results/examples/tutorial/muting_block_output.2.result @@ -0,0 +1 @@ +The french sentence was: The translation of 'I love Paris!' in French is 'Je t'aime Paris!'. diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index 0ee28ec64..159fb2aa1 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -11,7 +11,7 @@ from pdl.pdl_interpreter import PDLRuntimeError from pdl.pdl_parser import PDLParseError -UPDATE_RESULTS = False +UPDATE_RESULTS = True TO_SKIP = { str(name) @@ -174,16 +174,15 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - wrong_result = False if wrong_result: if UPDATE_RESULTS: - result_file_name_0 = pdl_file_name.stem + ".1.result" + result_file_name_0 = pdl_file_name.stem + ".5.result" result_dir_name.mkdir(parents=True, exist_ok=True) with open( result_dir_name / result_file_name_0, "w", encoding="utf-8" ) as result_file: print(str(result), file=result_file) - else: - wrong_results[str(pdl_file_name)] = { - "actual": str(result), - } + wrong_results[str(pdl_file_name)] = { + "actual": str(result), + } except PDLParseError: actual_parse_error |= {str(pdl_file_name)} except PDLRuntimeError as exc: From 6607a9664cfb41925d529a246225e00ec7477e6c Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 06:28:13 -0500 Subject: [PATCH 06/17] Improve error message --- tests/test_examples_run.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index 159fb2aa1..1094a8c4d 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -192,13 +192,13 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - # Parse errors expected_parse_error = set(str(p) for p in EXPECTED_PARSE_ERROR) unexpected_parse_error = sorted(list(actual_parse_error - expected_parse_error)) - assert len(unexpected_parse_error) == 0, unexpected_parse_error + assert len(unexpected_parse_error) == 0, f"Unexpected parse error: {unexpected_parse_error}" # Runtime errors expected_runtime_error = set(str(p) for p in EXPECTED_RUNTIME_ERROR) unexpected_runtime_error = sorted( list(actual_runtime_error - expected_runtime_error) ) - assert len(unexpected_runtime_error) == 0, unexpected_runtime_error + assert len(unexpected_runtime_error) == 0, f"Unexpected runtime error: {unexpected_runtime_error}" # Unexpected valid unexpected_valid = sorted( list( @@ -207,6 +207,6 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - ) ) ) - assert len(unexpected_valid) == 0, unexpected_valid + assert len(unexpected_valid) == 0, f"Unexpected valid: {unexpected_valid}" # Unexpected results - assert len(wrong_results) == 0, wrong_results + assert len(wrong_results) == 0, f"Wrong results: {wrong_results}" From 659a84c2e6d35cd74976a5b1ebaa1618c8050729 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 06:38:32 -0500 Subject: [PATCH 07/17] More results --- tests/results/examples/code/code.5.result | 20 ++++++++++++++ .../granite/multi_round_chat.5.result | 15 +++++++++++ .../examples/talk/5-code-eval.5.result | 24 +++++++++++++++++ .../examples/tutorial/include.5.result | 26 +++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 tests/results/examples/code/code.5.result create mode 100644 tests/results/examples/granite/multi_round_chat.5.result create mode 100644 tests/results/examples/talk/5-code-eval.5.result create mode 100644 tests/results/examples/tutorial/include.5.result diff --git a/tests/results/examples/code/code.5.result b/tests/results/examples/code/code.5.result new file mode 100644 index 000000000..823254bea --- /dev/null +++ b/tests/results/examples/code/code.5.result @@ -0,0 +1,20 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes a new `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map` and assigns it to `offsetMap`. +4. Finally, it returns the `offsetMap`. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a compile-time warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the compiler doesn't know that it's safe to cast it to `Map`. However, in this case, the method is designed to always return a `Map`, so the warning can be safely suppressed. diff --git a/tests/results/examples/granite/multi_round_chat.5.result b/tests/results/examples/granite/multi_round_chat.5.result new file mode 100644 index 000000000..5d9f78e63 --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.5.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual cost of borrowing, or the return on your investment, +Including fees and charges, it's a number that's essential. + +So when you're taking out a loan, or investing your cash, +Be sure to look at the APR, and don't be in a rush. +It's a number that can save you money, or cost you more, +So make sure you understand it, before you sign that store. +Now explain APR to me like I'm 5 years old +Sure! So, imagine you borrowed some money from your friend to buy a toy. Your friend wants to know how much you'll pay back, including any extra fees. The APR is like a special number that helps you figure that out. It tells you how much you'll pay back each year, including any extra fees, so you can know exactly how much you'll owe. diff --git a/tests/results/examples/talk/5-code-eval.5.result b/tests/results/examples/talk/5-code-eval.5.result new file mode 100644 index 000000000..2552f2a3e --- /dev/null +++ b/tests/results/examples/talk/5-code-eval.5.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the type argument. +4. Finally, the method returns the deserialized `Map`. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential unchecked warning that might occur due to the raw `Map` type used in the `else` block. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.3015021459227468 diff --git a/tests/results/examples/tutorial/include.5.result b/tests/results/examples/tutorial/include.5.result new file mode 100644 index 000000000..1835d6f35 --- /dev/null +++ b/tests/results/examples/tutorial/include.5.result @@ -0,0 +1,26 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or saving, it's a helpful tool, +To make informed decisions, and avoid a financial fool. + +So remember APR, when you're in the market, +For loans or investments, it's a vital factor. +It's the annual rate, that tells you the cost, +In the world of finance, it's a helpful host. +Now explain APR to me like I'm 5 years old +Sure! So, imagine you have a piggy bank and you want to borrow some money from your parents to buy a toy. Your parents might ask you to pay them back with a little extra money, like an extra dollar for every dollar you borrow. This extra money is like the interest you pay on a loan. + +Now, APR is like a special way to measure how much extra money you have to pay back. It tells you how much interest you'll pay each year, based on the amount you borrowed and the interest rate your parents set. + +So, if your parents say the APR is 10%, that means you'll have to pay back 10% more than you borrowed each year. For example, if you borrow $10, you'll have to pay back $11 at the end of the year. + +APR is important because it helps you understand how much you'll have to pay back when you borrow money, and it can help you make better decisions about loans and investments. From 2b10cd34c59a4c84806f8a27c7867e46e3faa54a Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 08:26:20 -0500 Subject: [PATCH 08/17] Formatting --- tests/test_examples_run.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index 1094a8c4d..335f3fcc2 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -11,7 +11,7 @@ from pdl.pdl_interpreter import PDLRuntimeError from pdl.pdl_parser import PDLParseError -UPDATE_RESULTS = True +UPDATE_RESULTS = False TO_SKIP = { str(name) @@ -174,7 +174,7 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - wrong_result = False if wrong_result: if UPDATE_RESULTS: - result_file_name_0 = pdl_file_name.stem + ".5.result" + result_file_name_0 = pdl_file_name.stem + ".6.result" result_dir_name.mkdir(parents=True, exist_ok=True) with open( result_dir_name / result_file_name_0, "w", encoding="utf-8" @@ -192,13 +192,17 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - # Parse errors expected_parse_error = set(str(p) for p in EXPECTED_PARSE_ERROR) unexpected_parse_error = sorted(list(actual_parse_error - expected_parse_error)) - assert len(unexpected_parse_error) == 0, f"Unexpected parse error: {unexpected_parse_error}" + assert ( + len(unexpected_parse_error) == 0 + ), f"Unexpected parse error: {unexpected_parse_error}" # Runtime errors expected_runtime_error = set(str(p) for p in EXPECTED_RUNTIME_ERROR) unexpected_runtime_error = sorted( list(actual_runtime_error - expected_runtime_error) ) - assert len(unexpected_runtime_error) == 0, f"Unexpected runtime error: {unexpected_runtime_error}" + assert ( + len(unexpected_runtime_error) == 0 + ), f"Unexpected runtime error: {unexpected_runtime_error}" # Unexpected valid unexpected_valid = sorted( list( From c4211c9a39ba64f2e94ba017df38c4250d448928 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 13:56:56 -0500 Subject: [PATCH 09/17] More results --- .../granite/multi_round_chat.6.result | 15 ++++++ .../granite/multi_round_chat.7.result | 15 ++++++ .../results/examples/react/wikipedia.6.result | 51 +++++++++++++++++++ .../examples/talk/7-chatbot-roles.6.result | 8 +++ tests/results/examples/talk/9-react.6.result | 51 +++++++++++++++++++ .../examples/tutorial/include.6.result | 24 +++++++++ .../examples/tutorial/include.7.result | 15 ++++++ 7 files changed, 179 insertions(+) create mode 100644 tests/results/examples/granite/multi_round_chat.6.result create mode 100644 tests/results/examples/granite/multi_round_chat.7.result create mode 100644 tests/results/examples/react/wikipedia.6.result create mode 100644 tests/results/examples/talk/7-chatbot-roles.6.result create mode 100644 tests/results/examples/talk/9-react.6.result create mode 100644 tests/results/examples/tutorial/include.6.result create mode 100644 tests/results/examples/tutorial/include.7.result diff --git a/tests/results/examples/granite/multi_round_chat.6.result b/tests/results/examples/granite/multi_round_chat.6.result new file mode 100644 index 000000000..9b5f6ff29 --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.6.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or investing, APR is the guide, +To make informed decisions, with confidence, you'll abide. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your friend to buy a toy. Your friend says you can borrow the money, but you have to pay them back with a little extra. The extra is like the interest, and the APR is the special number that tells you how much extra you have to pay back each year. It's like a rule that helps you understand how much you'll owe your friend for borrowing their money. diff --git a/tests/results/examples/granite/multi_round_chat.7.result b/tests/results/examples/granite/multi_round_chat.7.result new file mode 100644 index 000000000..c18b8247c --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.7.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells us what we'll pay, or earn, you see. +It's the annual rate, both simple and clear, +Including all fees, for loans and investments, near and far. + +It's the cost of borrowing, or the return we get, +A number that helps us make informed financial bets. +So, when you're comparing loans, or investments to choose, +Remember APR, and make the right move. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your parents to buy a toy. Your parents will charge you a little bit of money each year to borrow that money. The APR is like a special number that tells you how much money you'll have to pay back each year, including any extra fees. It helps you understand how much the loan will cost you in the long run. diff --git a/tests/results/examples/react/wikipedia.6.result b/tests/results/examples/react/wikipedia.6.result new file mode 100644 index 000000000..603a3e912 --- /dev/null +++ b/tests/results/examples/react/wikipedia.6.result @@ -0,0 +1,51 @@ +What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into? +Tho: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado ... +Act: {"name": "Search", "arguments": {"topic": "Colorado orogeny"}} +Obs: The Colorado orogeny was an episode of mountain building (an orogeny) ... +Tho: It does not mention the eastern sector. So I need to look up eastern sector. +Tho: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft. +Act: {"name": "Finish", "arguments": {"topic": "1,800 to 7,000 ft"}} + +What profession does Nicholas Ray and Elia Kazan have in common? +Tho: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common. +Act: {"name": "Search", "arguments": {"topic": "Nicholas Ray"}} +Obs: Nicholas Ray (born Raymond Nicholas Kienzle Jr., August 7, 1911 - June 16, 1979) was an American film director, screenwriter, and actor best known for the 1955 film Rebel Without a Cause. +Tho: Professions of Nicholas Ray are director, screenwriter, and actor. I need to search Elia Kazan next and find his professions. +Act: {"name": "Search", "arguments": {"topic": "Elia Kazan"}} +Obs: Elia Kazan was an American film and theatre director, producer, screenwriter and actor. +Tho: Professions of Elia Kazan are director, producer, screenwriter, and actor. So profession Nicholas Ray and Elia Kazan have in common is director, screenwriter, and actor. +Act: {"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + + +when was the discoverer of the Hudson River born? +Tho: I need to search Henry Hudson. +Act: {"name": "Search", "arguments": {"topic": "Henry Hudson"}} +Obs: 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. +Tho: Henry Hudson was born around 1565. +Act: {"name": "Finish", "arguments": {"topic": "around 1565"}} diff --git a/tests/results/examples/talk/7-chatbot-roles.6.result b/tests/results/examples/talk/7-chatbot-roles.6.result new file mode 100644 index 000000000..5169efa4b --- /dev/null +++ b/tests/results/examples/talk/7-chatbot-roles.6.result @@ -0,0 +1,8 @@ +Type `quit` to exit this chatbot. +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned on an investment, expressed as a single percentage number that represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. + + + +I'm sorry to see you go. If you have any more questions in the future, feel free to come back. Have a great day! + + diff --git a/tests/results/examples/talk/9-react.6.result b/tests/results/examples/talk/9-react.6.result new file mode 100644 index 000000000..603a3e912 --- /dev/null +++ b/tests/results/examples/talk/9-react.6.result @@ -0,0 +1,51 @@ +What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into? +Tho: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado ... +Act: {"name": "Search", "arguments": {"topic": "Colorado orogeny"}} +Obs: The Colorado orogeny was an episode of mountain building (an orogeny) ... +Tho: It does not mention the eastern sector. So I need to look up eastern sector. +Tho: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft. +Act: {"name": "Finish", "arguments": {"topic": "1,800 to 7,000 ft"}} + +What profession does Nicholas Ray and Elia Kazan have in common? +Tho: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common. +Act: {"name": "Search", "arguments": {"topic": "Nicholas Ray"}} +Obs: Nicholas Ray (born Raymond Nicholas Kienzle Jr., August 7, 1911 - June 16, 1979) was an American film director, screenwriter, and actor best known for the 1955 film Rebel Without a Cause. +Tho: Professions of Nicholas Ray are director, screenwriter, and actor. I need to search Elia Kazan next and find his professions. +Act: {"name": "Search", "arguments": {"topic": "Elia Kazan"}} +Obs: Elia Kazan was an American film and theatre director, producer, screenwriter and actor. +Tho: Professions of Elia Kazan are director, producer, screenwriter, and actor. So profession Nicholas Ray and Elia Kazan have in common is director, screenwriter, and actor. +Act: {"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + + +when was the discoverer of the Hudson River born? +Tho: I need to search Henry Hudson. +Act: {"name": "Search", "arguments": {"topic": "Henry Hudson"}} +Obs: 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. +Tho: Henry Hudson was born around 1565. +Act: {"name": "Finish", "arguments": {"topic": "around 1565"}} diff --git a/tests/results/examples/tutorial/include.6.result b/tests/results/examples/tutorial/include.6.result new file mode 100644 index 000000000..67900d6c8 --- /dev/null +++ b/tests/results/examples/tutorial/include.6.result @@ -0,0 +1,24 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or saving, it's a helpful tool, +To make informed decisions, and avoid a financial fool. + +So remember APR, when you're in the market, +For loans or investments, it's a vital factor. +It's the annual rate, that tells you the cost, +In the world of finance, it's a helpful host. +Now explain APR to me like I'm 5 years old +Sure! So, imagine you have a piggy bank and you want to borrow some money from your parents to buy a toy. Your parents might ask you to pay them back with a little extra money, like an extra dollar for every dollar you borrow. This extra money is like the interest you pay on a loan. + +Now, APR is like a special way to calculate how much extra money you'll have to pay back. It takes into account not just the interest rate, but also any extra fees or costs that might be added on. So, if you know the APR, you can figure out exactly how much you'll have to pay back in a whole year, not just for one month or one day. + +It's like a special tool that helps you understand how much something will really cost you, so you can make smart decisions about borrowing or saving money. diff --git a/tests/results/examples/tutorial/include.7.result b/tests/results/examples/tutorial/include.7.result new file mode 100644 index 000000000..c18b8247c --- /dev/null +++ b/tests/results/examples/tutorial/include.7.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells us what we'll pay, or earn, you see. +It's the annual rate, both simple and clear, +Including all fees, for loans and investments, near and far. + +It's the cost of borrowing, or the return we get, +A number that helps us make informed financial bets. +So, when you're comparing loans, or investments to choose, +Remember APR, and make the right move. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your parents to buy a toy. Your parents will charge you a little bit of money each year to borrow that money. The APR is like a special number that tells you how much money you'll have to pay back each year, including any extra fees. It helps you understand how much the loan will cost you in the long run. From 3e90e3069f3bbde6956c0fbb97dc27a36ec6c949 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 22:04:06 -0500 Subject: [PATCH 10/17] More results --- .../granite/multi_round_chat.8.result | 26 +++++++++++++++++++ .../examples/talk/6-code-json.9.result | 1 + .../examples/tutorial/data_block.7.result | 1 + .../examples/tutorial/include.8.result | 15 +++++++++++ 4 files changed, 43 insertions(+) create mode 100644 tests/results/examples/granite/multi_round_chat.8.result create mode 100644 tests/results/examples/talk/6-code-json.9.result create mode 100644 tests/results/examples/tutorial/data_block.7.result create mode 100644 tests/results/examples/tutorial/include.8.result diff --git a/tests/results/examples/granite/multi_round_chat.8.result b/tests/results/examples/granite/multi_round_chat.8.result new file mode 100644 index 000000000..c74e2ed6f --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.8.result @@ -0,0 +1,26 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or saving, it's a helpful tool, +To make informed decisions, and avoid a financial fool. + +So remember APR, when you're in the market, +For loans or investments, it's a vital factor. +It's the annual rate, that tells you the cost, +In the world of finance, it's a helpful host. +Now explain APR to me like I'm 5 years old +Sure! So, imagine you have a piggy bank and you want to borrow some money from your parents to buy a toy. Your parents might ask you to pay them back with a little extra money, like an extra dollar for every dollar you borrow. This extra money is like the interest you pay on a loan. + +Now, APR is like a special way to measure how much extra money you have to pay back. It tells you how much interest you'll pay each year, based on the amount you borrowed and the interest rate your parents set. + +So, if your parents say the APR is 10%, that means you'll have to pay back 10% more than you borrowed each year. For example, if you borrow $10, you'll have to pay back $11 each year. + +APR is important because it helps you understand how much you'll have to pay back when you borrow money, and it can help you make better decisions about loans and investments. diff --git a/tests/results/examples/talk/6-code-json.9.result b/tests/results/examples/talk/6-code-json.9.result new file mode 100644 index 000000000..39beb6e1c --- /dev/null +++ b/tests/results/examples/talk/6-code-json.9.result @@ -0,0 +1 @@ +{"input": {"source_code": "@SuppressWarnings(\"unchecked\")\npublic static Map deserializeOffsetMap(String lastSourceOffset) throws IOException {\n Map offsetMap;\n if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { \n offsetMap = new HashMap<>(); \n } else {\n offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); \n }\n return offsetMap;\n}\n", "repo_info": {"repo": "streamsets/datacollector", "path": "stagesupport/src/main/java/com/.../OffsetUtil.java", "function_name": "OffsetUtil.deserializeOffsetMap"}}, "output": "This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code:\n\n1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.\n2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes a new `HashMap` and assigns it to `offsetMap`.\n3. If `lastSourceOffset` is not `null` or an empty string, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map` and assigns it to `offsetMap`.\n4. Finally, it returns the `offsetMap`.\n\nThe `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a compile-time warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the compiler doesn't know that it's safe to cast it to `Map`. However, in this case, the method is designed to always return a `Map`, so the warning can be safely ignored.", "metric": 0.34864864864864864} diff --git a/tests/results/examples/tutorial/data_block.7.result b/tests/results/examples/tutorial/data_block.7.result new file mode 100644 index 000000000..764f26067 --- /dev/null +++ b/tests/results/examples/tutorial/data_block.7.result @@ -0,0 +1 @@ +{'input': {'source_code': '@SuppressWarnings("unchecked")\npublic static Map deserializeOffsetMap(String lastSourceOffset) throws IOException {\n Map offsetMap;\n if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { \n offsetMap = new HashMap<>(); \n } else {\n offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); \n }\n return offsetMap;\n}\n', 'repo_info': {'repo': 'streamsets/datacollector', 'path': 'stagesupport/src/main/java/com/.../OffsetUtil.java', 'function_name': 'OffsetUtil.deserializeOffsetMap'}}, 'output': 'This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here\'s a breakdown of the code:\n\n1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.\n2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`.\n3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object.\n4. Finally, the method returns the `offsetMap`, which now contains the deserialized data.\n\nThe `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. Since the actual type of the map is not known at compile time, the compiler issues a warning. The `@SuppressWarnings` annotation is used to suppress this warning.', 'metric': 0.34065934065934067} diff --git a/tests/results/examples/tutorial/include.8.result b/tests/results/examples/tutorial/include.8.result new file mode 100644 index 000000000..9b5f6ff29 --- /dev/null +++ b/tests/results/examples/tutorial/include.8.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or investing, APR is the guide, +To make informed decisions, with confidence, you'll abide. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your friend to buy a toy. Your friend says you can borrow the money, but you have to pay them back with a little extra. The extra is like the interest, and the APR is the special number that tells you how much extra you have to pay back each year. It's like a rule that helps you understand how much you'll owe your friend for borrowing their money. From b81b7444d28933206513efe38293edc94289597f Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 20 Nov 2024 22:09:47 -0500 Subject: [PATCH 11/17] More results --- .../results/examples/code/code-eval.9.result | 24 +++++++++++ .../results/examples/code/code-json.9.result | 1 + .../examples/hello/hello-roles-array.9.result | 42 +++++++++++++++++++ .../tutorial/grouping_definitions.9.result | 2 + 4 files changed, 69 insertions(+) create mode 100644 tests/results/examples/code/code-eval.9.result create mode 100644 tests/results/examples/code/code-json.9.result create mode 100644 tests/results/examples/hello/hello-roles-array.9.result create mode 100644 tests/results/examples/tutorial/grouping_definitions.9.result diff --git a/tests/results/examples/code/code-eval.9.result b/tests/results/examples/code/code-eval.9.result new file mode 100644 index 000000000..3b32e615f --- /dev/null +++ b/tests/results/examples/code/code-eval.9.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object. +4. Finally, the method returns the `offsetMap`, which now contains the deserialized data. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. The compiler knows that the actual type of the `Map` object will be a `Map`, but the annotation is used to suppress the warning. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.31687898089171973 diff --git a/tests/results/examples/code/code-json.9.result b/tests/results/examples/code/code-json.9.result new file mode 100644 index 000000000..aa4dbd202 --- /dev/null +++ b/tests/results/examples/code/code-json.9.result @@ -0,0 +1 @@ +{"input": {"source_code": "@SuppressWarnings(\"unchecked\")\npublic static Map deserializeOffsetMap(String lastSourceOffset) throws IOException {\n Map offsetMap;\n if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { \n offsetMap = new HashMap<>(); \n } else {\n offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); \n }\n return offsetMap;\n}\n", "repo_info": {"repo": "streamsets/datacollector", "path": "stagesupport/src/main/java/com/.../OffsetUtil.java", "function_name": "OffsetUtil.deserializeOffsetMap"}}, "output": "This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code:\n\n1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.\n2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`.\n3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the type argument.\n4. Finally, the method returns the deserialized `Map`.\n\nThe `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a potential unchecked warning that might occur due to the raw type `Map.class` being used as the type argument for `JSON_MAPPER.readValue`.", "metric": 0.2929085303186023} diff --git a/tests/results/examples/hello/hello-roles-array.9.result b/tests/results/examples/hello/hello-roles-array.9.result new file mode 100644 index 000000000..73863d618 --- /dev/null +++ b/tests/results/examples/hello/hello-roles-array.9.result @@ -0,0 +1,42 @@ +Here is a Python function that implements the merge sort algorithm: + +```python +def merge_sort(arr): + # Base case: if the array has 1 or 0 elements, it's already sorted + if len(arr) <= 1: + return arr + + # Split the array into two halves + mid = len(arr) // 2 + left_half = arr[:mid] + right_half = arr[mid:] + + # Recursively sort both halves + left_sorted = merge_sort(left_half) + right_sorted = merge_sort(right_half) + + # Merge the sorted halves + return merge(left_sorted, right_sorted) + +def merge(left, right): + merged = [] + left_index = 0 + right_index = 0 + + # Merge the two halves, keeping them sorted + while left_index < len(left) and right_index < len(right): + if left[left_index] < right[right_index]: + merged.append(left[left_index]) + left_index += 1 + else: + merged.append(right[right_index]) + right_index += 1 + + # Add any remaining elements from the left and right halves + merged.extend(left[left_index:]) + merged.extend(right[right_index:]) + + return merged +``` + +This function first checks if the input array has 1 or 0 elements, in which case it's already sorted. If not, it splits the array into two halves and recursively sorts each half using merge sort. Finally, it merges the two sorted halves back together. diff --git a/tests/results/examples/tutorial/grouping_definitions.9.result b/tests/results/examples/tutorial/grouping_definitions.9.result new file mode 100644 index 000000000..2ebf72ec1 --- /dev/null +++ b/tests/results/examples/tutorial/grouping_definitions.9.result @@ -0,0 +1,2 @@ +The translation of 'I love Paris!' in French is 'Je t'aime Paris!'. +The translation of 'I love Madrid!' in Spanish is 'Me encanta Madrid!'. From 407c66763e3c98f44367b8a52bdcb9de381b08ae Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Thu, 21 Nov 2024 09:30:07 -0500 Subject: [PATCH 12/17] More results --- .../examples/granite/multi_round_chat.10.result | 15 +++++++++++++++ tests/results/examples/talk/6-code-json.10.result | 1 + tests/results/examples/tutorial/include.10.result | 15 +++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 tests/results/examples/granite/multi_round_chat.10.result create mode 100644 tests/results/examples/talk/6-code-json.10.result create mode 100644 tests/results/examples/tutorial/include.10.result diff --git a/tests/results/examples/granite/multi_round_chat.10.result b/tests/results/examples/granite/multi_round_chat.10.result new file mode 100644 index 000000000..5550a9194 --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.10.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +So you can make informed decisions, standing tall. +Whether borrowing or investing, APR is your guide, +To understand the true cost, or the reward you'll glide. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank, and you want to borrow some money from your friend to buy a toy. Your friend says you can borrow $10, but you have to pay back $11 at the end of the year. The $1 is the interest, and the APR is the way we show how much interest you'll pay for the year. In this case, the APR is 10%, because you're paying 10% of the amount you borrowed as interest. diff --git a/tests/results/examples/talk/6-code-json.10.result b/tests/results/examples/talk/6-code-json.10.result new file mode 100644 index 000000000..4b9ac828b --- /dev/null +++ b/tests/results/examples/talk/6-code-json.10.result @@ -0,0 +1 @@ +{"input": {"source_code": "@SuppressWarnings(\"unchecked\")\npublic static Map deserializeOffsetMap(String lastSourceOffset) throws IOException {\n Map offsetMap;\n if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { \n offsetMap = new HashMap<>(); \n } else {\n offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); \n }\n return offsetMap;\n}\n", "repo_info": {"repo": "streamsets/datacollector", "path": "stagesupport/src/main/java/com/.../OffsetUtil.java", "function_name": "OffsetUtil.deserializeOffsetMap"}}, "output": "This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code:\n\n1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.\n2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`.\n3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object.\n4. Finally, the method returns the `offsetMap`, which now contains the deserialized data.\n\nThe `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map`. Since the actual type of the map is not known at compile time, the compiler issues a warning. The `@SuppressWarnings` annotation is used to suppress this warning.", "metric": 0.34144427001569855} diff --git a/tests/results/examples/tutorial/include.10.result b/tests/results/examples/tutorial/include.10.result new file mode 100644 index 000000000..86014a70d --- /dev/null +++ b/tests/results/examples/tutorial/include.10.result @@ -0,0 +1,15 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells us what we'll pay, or earn, you see. +It's the annual rate, both simple and clear, +Including all fees, for those who lend or invest, it's near. + +It's the cost of borrowing, or the return we gain, +In the world of loans and investments, it's a vital chain. +So, when you're making decisions, about money and such, +Remember APR, and make sure it's within your budget's touch. +Now explain APR to me like I'm 5 years old +Sure! Imagine you have a piggy bank and you want to borrow some money from your parents to buy a toy. Your parents will ask you to pay them back with some extra money, which is like interest. APR is the special number that tells you how much extra money you have to pay back each year, including any extra fees. It helps you understand how much the toy really costs. From 01781df742f001c234a95d93853ccac80d844984 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Thu, 21 Nov 2024 09:34:45 -0500 Subject: [PATCH 13/17] More results --- .../results/examples/code/code-eval.11.result | 24 +++++++++ .../results/examples/fibonacci/fib.11.result | 43 +++++++++++++++ .../granite/multi_round_chat.11.result | 24 +++++++++ tests/results/examples/react/demo.11.result | 44 +++++++++++++++ .../examples/react/wikipedia.11.result | 53 +++++++++++++++++++ .../examples/talk/5-code-eval.11.result | 24 +++++++++ tests/results/examples/talk/9-react.11.result | 53 +++++++++++++++++++ .../examples/tutorial/include.11.result | 24 +++++++++ 8 files changed, 289 insertions(+) create mode 100644 tests/results/examples/code/code-eval.11.result create mode 100644 tests/results/examples/fibonacci/fib.11.result create mode 100644 tests/results/examples/granite/multi_round_chat.11.result create mode 100644 tests/results/examples/react/demo.11.result create mode 100644 tests/results/examples/react/wikipedia.11.result create mode 100644 tests/results/examples/talk/5-code-eval.11.result create mode 100644 tests/results/examples/talk/9-react.11.result create mode 100644 tests/results/examples/tutorial/include.11.result diff --git a/tests/results/examples/code/code-eval.11.result b/tests/results/examples/code/code-eval.11.result new file mode 100644 index 000000000..69b1c49de --- /dev/null +++ b/tests/results/examples/code/code-eval.11.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object. +4. Finally, the method returns the `offsetMap`, which now contains the deserialized data. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential unchecked warning that might occur due to the raw `Map` type used in the `else` block. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.3044334975369458 diff --git a/tests/results/examples/fibonacci/fib.11.result b/tests/results/examples/fibonacci/fib.11.result new file mode 100644 index 000000000..d0a2775e5 --- /dev/null +++ b/tests/results/examples/fibonacci/fib.11.result @@ -0,0 +1,43 @@ +Here is a simple Python function to compute the Fibonacci sequence: + +```python +def fibonacci(n): + if n <= 0: + return "Input should be a positive integer." + elif n == 1: + return 0 + elif n == 2: + return 1 + else: + a, b = 0, 1 + for _ in range(n - 2): + a, b = b, a + b + return b +``` + +This function takes an integer `n` as input and returns the `n`th number in the Fibonacci sequence. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. +Find a random number between 1 and 20 +15 +Now computing fibonacci(15) + +def fibonacci(n): + if n <= 0: + return "Input should be a positive integer." + elif n == 1: + return 0 + elif n == 2: + return 1 + else: + a, b = 0, 1 + for _ in range(n - 2): + a, b = b, a + b + return b +The result is: 377 + +Explain what the above code does and what the result means + +The provided code is a Python function named `fibonacci(n)` that computes the `n`th number in the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. + +The function takes an integer `n` as input and returns the `n`th number in the Fibonacci sequence. It first checks if the input is a positive integer and returns an error message if it's not. If the input is 1, it returns 0, and if the input is 2, it returns 1. For any other positive integer input, it uses a loop to calculate the `n`th Fibonacci number by repeatedly adding the last two numbers in the sequence until it reaches the `n`th number. + +In this case, the function is called with the argument `15`, so it computes the 15th number in the Fibonacci sequence. The result is `377`, which means that the 15th number in the Fibonacci sequence is 377. diff --git a/tests/results/examples/granite/multi_round_chat.11.result b/tests/results/examples/granite/multi_round_chat.11.result new file mode 100644 index 000000000..6d54bbaff --- /dev/null +++ b/tests/results/examples/granite/multi_round_chat.11.result @@ -0,0 +1,24 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or saving, it's a helpful tool, +To make informed decisions, and avoid a financial fool. + +So remember APR, when you're in the market, +For loans or investments, it's a vital factor. +It's the annual rate, that tells you the cost, +In the world of finance, it's a helpful host. +Now explain APR to me like I'm 5 years old +Sure! So, imagine you have a piggy bank and you want to borrow some money from your parents to buy a toy. Your parents might ask you to pay them back with a little extra money, like an extra dollar for every dollar you borrow. This extra money is like the interest you pay on a loan. + +Now, APR is like a special way to measure how much extra money you have to pay back. It tells you how much interest you'll pay each year, based on the amount you borrowed and the interest rate your parents set. + +So, if you borrow $10 from your parents and they charge you 10% interest per year, your APR would be 10%. This means you'll have to pay back $11 at the end of the year to your parents. diff --git a/tests/results/examples/react/demo.11.result b/tests/results/examples/react/demo.11.result new file mode 100644 index 000000000..9f14d084a --- /dev/null +++ b/tests/results/examples/react/demo.11.result @@ -0,0 +1,44 @@ +What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into? +Tho: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado ... +Act: {"name": "Search", "arguments": {"topic": "Colorado orogeny"}} +Obs: The Colorado orogeny was an episode of mountain building (an orogeny) ... +Tho: It does not mention the eastern sector. So I need to look up eastern sector. +Tho: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft. +Act: {"name": "Finish", "arguments": {"topic": "1,800 to 7,000 ft"}} + +What profession does Nicholas Ray and Elia Kazan have in common? +Tho: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common. +Act: {"name": "Search", "arguments": {"topic": "Nicholas Ray"}} +Obs: Nicholas Ray (born Raymond Nicholas Kienzle Jr., August 7, 1911 - June 16, 1979) was an American film director, screenwriter, and actor best known for the 1955 film Rebel Without a Cause. +Tho: Professions of Nicholas Ray are director, screenwriter, and actor. I need to search Elia Kazan next and find his professions. +Act: {"name": "Search", "arguments": {"topic": "Elia Kazan"}} +Obs: Elia Kazan was an American film and theatre director, producer, screenwriter and actor. +Tho: Professions of Elia Kazan are director, producer, screenwriter, and actor. So profession Nicholas Ray and Elia Kazan have in common is director, screenwriter, and actor. +Act: {"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + + +How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2024. +Tho: I need to search Henry Hudson, find out when he was born, and then calculate how many years ago that was. +Act: {"name": "Search", "arguments": {"topic": "Henry Hudson"}} +Obs: 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. + + +Tho: Henry Hudson was born around 1565. To find out how many years ago that was, I need to subtract his birth year from the current year, which is 2024. + +Act: {"name": "Calc", "arguments": {"expr": "2024 - 1565"}} +Obs: 459 + diff --git a/tests/results/examples/react/wikipedia.11.result b/tests/results/examples/react/wikipedia.11.result new file mode 100644 index 000000000..28f046f5b --- /dev/null +++ b/tests/results/examples/react/wikipedia.11.result @@ -0,0 +1,53 @@ +What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into? +Tho: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado ... +Act: {"name": "Search", "arguments": {"topic": "Colorado orogeny"}} +Obs: The Colorado orogeny was an episode of mountain building (an orogeny) ... +Tho: It does not mention the eastern sector. So I need to look up eastern sector. +Tho: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft. +Act: {"name": "Finish", "arguments": {"topic": "1,800 to 7,000 ft"}} + +What profession does Nicholas Ray and Elia Kazan have in common? +Tho: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common. +Act: {"name": "Search", "arguments": {"topic": "Nicholas Ray"}} +Obs: Nicholas Ray (born Raymond Nicholas Kienzle Jr., August 7, 1911 - June 16, 1979) was an American film director, screenwriter, and actor best known for the 1955 film Rebel Without a Cause. +Tho: Professions of Nicholas Ray are director, screenwriter, and actor. I need to search Elia Kazan next and find his professions. +Act: {"name": "Search", "arguments": {"topic": "Elia Kazan"}} +Obs: Elia Kazan was an American film and theatre director, producer, screenwriter and actor. +Tho: Professions of Elia Kazan are director, producer, screenwriter, and actor. So profession Nicholas Ray and Elia Kazan have in common is director, screenwriter, and actor. +Act: {"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + + +when was the discoverer of the Hudson River born? +Tho: I need to search Henry Hudson, find out when he was born. +Act: {"name": "Search", "arguments": {"topic": "Henry Hudson"}} +Obs: 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. + + +Tho: Henry Hudson was born around 1565. +Act: {"name": "Finish", "arguments": {"topic": "around 1565"}} diff --git a/tests/results/examples/talk/5-code-eval.11.result b/tests/results/examples/talk/5-code-eval.11.result new file mode 100644 index 000000000..6f1f61b17 --- /dev/null +++ b/tests/results/examples/talk/5-code-eval.11.result @@ -0,0 +1,24 @@ + +@SuppressWarnings("unchecked") +public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException { + Map offsetMap; + if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { + offsetMap = new HashMap<>(); + } else { + offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); + } + return offsetMap; +} + +This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map`. Here's a breakdown of the code: + +1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string. +2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes a new `HashMap` and assigns it to `offsetMap`. +3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map` and assigns it to `offsetMap`. +4. Finally, it returns the `offsetMap`. + +The `@SuppressWarnings("unchecked")` annotation is used to suppress a compile-time warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the compiler doesn't know that it's safe to cast it to `Map`. However, since the method is designed to handle JSON strings that should always deserialize into a `Map`, this warning can be safely ignored. + +EVALUATION: +The similarity (Levenshtein) between this answer and the ground truth is: +0.3507067137809188 diff --git a/tests/results/examples/talk/9-react.11.result b/tests/results/examples/talk/9-react.11.result new file mode 100644 index 000000000..28f046f5b --- /dev/null +++ b/tests/results/examples/talk/9-react.11.result @@ -0,0 +1,53 @@ +What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into? +Tho: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado ... +Act: {"name": "Search", "arguments": {"topic": "Colorado orogeny"}} +Obs: The Colorado orogeny was an episode of mountain building (an orogeny) ... +Tho: It does not mention the eastern sector. So I need to look up eastern sector. +Tho: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft. +Act: {"name": "Finish", "arguments": {"topic": "1,800 to 7,000 ft"}} + +What profession does Nicholas Ray and Elia Kazan have in common? +Tho: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common. +Act: {"name": "Search", "arguments": {"topic": "Nicholas Ray"}} +Obs: Nicholas Ray (born Raymond Nicholas Kienzle Jr., August 7, 1911 - June 16, 1979) was an American film director, screenwriter, and actor best known for the 1955 film Rebel Without a Cause. +Tho: Professions of Nicholas Ray are director, screenwriter, and actor. I need to search Elia Kazan next and find his professions. +Act: {"name": "Search", "arguments": {"topic": "Elia Kazan"}} +Obs: Elia Kazan was an American film and theatre director, producer, screenwriter and actor. +Tho: Professions of Elia Kazan are director, producer, screenwriter, and actor. So profession Nicholas Ray and Elia Kazan have in common is director, screenwriter, and actor. +Act: {"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + +What is 18 + 12 x 3? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "18 + 12 * 3"}} +Obs: 54 +Act: {"name": "Finish", "arguments": {"topic": "54"}} + +A total of 252 qualifying matches were played, and 723 goals were scored. What was the average number of goals per match? +Tho: I need to call a calculator. +Act: {"name": "Calc", "arguments": {"expr": "723 / 252"}} +Obs: 2.869047619047619 +Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}} + + +when was the discoverer of the Hudson River born? +Tho: I need to search Henry Hudson, find out when he was born. +Act: {"name": "Search", "arguments": {"topic": "Henry Hudson"}} +Obs: 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. + + +Tho: Henry Hudson was born around 1565. +Act: {"name": "Finish", "arguments": {"topic": "around 1565"}} diff --git a/tests/results/examples/tutorial/include.11.result b/tests/results/examples/tutorial/include.11.result new file mode 100644 index 000000000..25e063525 --- /dev/null +++ b/tests/results/examples/tutorial/include.11.result @@ -0,0 +1,24 @@ + +What is APR? +APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction. +Can you write a poem about APR? +In the world of finance, APR is the key, +A number that tells you what you'll pay, or earn, you see. +It's the annual rate, not just a one-time fee, +In loans and investments, it's a crucial decree. + +It includes all fees, no matter how small, +A clear picture of cost, for one and all. +Whether borrowing or saving, it's a helpful tool, +To make informed decisions, and avoid a financial fool. + +So remember APR, when you're in the market, +For loans or investments, it's a vital factor. +It's the annual rate, that tells you the cost, +In the world of finance, it's a helpful host. +Now explain APR to me like I'm 5 years old +Sure! So, imagine you have a piggy bank and you want to borrow some money from your parents to buy a toy. Your parents might ask you to pay them back with a little extra money, like an extra dollar for every dollar you borrow. This extra money is like the interest you pay on a loan. + +Now, APR is like a special way to tell you how much extra money you'll have to pay back, all in one year. It includes any extra fees or costs, like a small fee for taking out the loan. So, if your parents say the APR is 5%, it means you'll have to pay back 5% more than you borrowed, all in one year. + +It's like a special rule that helps you understand how much you'll have to pay back, so you can make a good decision about whether to borrow the money or not. From 8fca66aff5d010a3a8bfe6f73a699016559bdd16 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Thu, 21 Nov 2024 11:06:30 -0500 Subject: [PATCH 14/17] Mark some tests non-deterministic --- tests/test_examples_run.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index 335f3fcc2..00b8d4ed3 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -40,6 +40,9 @@ for name in [ pathlib.Path("examples") / "weather" / "weather.pdl", pathlib.Path("examples") / "demo" / "3-weather.pdl", + pathlib.Path("examples") / "granite" / "multi_round_chat.pdl", + pathlib.Path("examples") / "react" / "demo.pdl", + pathlib.Path("examples") / "code" / "code-eval.pdl", ] } @@ -174,7 +177,7 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - wrong_result = False if wrong_result: if UPDATE_RESULTS: - result_file_name_0 = pdl_file_name.stem + ".6.result" + result_file_name_0 = pdl_file_name.stem + ".12.result" result_dir_name.mkdir(parents=True, exist_ok=True) with open( result_dir_name / result_file_name_0, "w", encoding="utf-8" From ff93a7817d593f50b133ba755969322e492e7fe4 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Thu, 21 Nov 2024 11:13:46 -0500 Subject: [PATCH 15/17] Mark more tests non-deterministic --- tests/test_examples_run.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index 00b8d4ed3..3ecdad369 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -43,6 +43,11 @@ pathlib.Path("examples") / "granite" / "multi_round_chat.pdl", pathlib.Path("examples") / "react" / "demo.pdl", pathlib.Path("examples") / "code" / "code-eval.pdl", + pathlib.Path("examples") / "code" / "code-json.pdl", + pathlib.Path("examples") / "talk" / "6-code-json.pdl", + pathlib.Path("examples") / "talk" / "9-react.pdl", + pathlib.Path("examples") / "tutorial" / "include.pdl", + pathlib.Path("examples") / "tutorial" / "data_block.pdl", ] } From 9efd73dfa7dc20f62a26f29ae567e18f932f4243 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Thu, 21 Nov 2024 11:33:59 -0500 Subject: [PATCH 16/17] Mark more tests non-deterministic --- tests/results/examples/tutorial/function_definition.1.result | 2 ++ tests/test_examples_run.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 tests/results/examples/tutorial/function_definition.1.result diff --git a/tests/results/examples/tutorial/function_definition.1.result b/tests/results/examples/tutorial/function_definition.1.result new file mode 100644 index 000000000..801cebbc0 --- /dev/null +++ b/tests/results/examples/tutorial/function_definition.1.result @@ -0,0 +1,2 @@ +The translation of 'I love Paris!' in French is 'Je t'aime Paris!'. +The translation of 'I love Madrid!' in Spanish is 'Me encanta Madrid!'. \ No newline at end of file diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index 3ecdad369..4e247d9ec 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -42,6 +42,8 @@ pathlib.Path("examples") / "demo" / "3-weather.pdl", pathlib.Path("examples") / "granite" / "multi_round_chat.pdl", pathlib.Path("examples") / "react" / "demo.pdl", + pathlib.Path("examples") / "react" / "wikipedia.pdl", + pathlib.Path("examples") / "code" / "code.pdl", pathlib.Path("examples") / "code" / "code-eval.pdl", pathlib.Path("examples") / "code" / "code-json.pdl", pathlib.Path("examples") / "talk" / "6-code-json.pdl", From 12ede74cba68eebb627eb3d08a87d24a6c82076b Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Thu, 21 Nov 2024 11:40:00 -0500 Subject: [PATCH 17/17] Mark more tests non-deterministic --- tests/test_examples_run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_examples_run.py b/tests/test_examples_run.py index 4e247d9ec..74da81533 100644 --- a/tests/test_examples_run.py +++ b/tests/test_examples_run.py @@ -46,6 +46,7 @@ pathlib.Path("examples") / "code" / "code.pdl", pathlib.Path("examples") / "code" / "code-eval.pdl", pathlib.Path("examples") / "code" / "code-json.pdl", + pathlib.Path("examples") / "talk" / "5-code-eval.pdl", pathlib.Path("examples") / "talk" / "6-code-json.pdl", pathlib.Path("examples") / "talk" / "9-react.pdl", pathlib.Path("examples") / "tutorial" / "include.pdl",