From e66e0dea8f8db7cf0159d49ceceed65aaf585024 Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Wed, 5 Mar 2025 21:38:54 -0500 Subject: [PATCH] Update examples to ollama_chat (#691) * Change examples to use ollama_chat Signed-off-by: Jing Chen * Update error.pdl Signed-off-by: Jing Chen * More updates Signed-off-by: Jing Chen * Use granite3.2:2b Signed-off-by: Jing Chen * Update pdl-live demo traces Signed-off-by: Jing Chen * Update results Signed-off-by: Jing Chen * Update res Signed-off-by: Jing Chen --------- Signed-off-by: Jing Chen --- .github/workflows/run-examples.yml | 7 +- examples/callback/repair_prompt.pdl | 2 +- examples/chatbot/chatbot.pdl | 4 +- examples/code/code-eval.pdl | 2 +- examples/code/code-json.pdl | 2 +- examples/code/code.pdl | 2 +- examples/demo/3-weather.pdl | 4 +- examples/demo/4-translator.pdl | 4 +- examples/fibonacci/fib.pdl | 4 +- examples/granite/multi_round_chat.pdl | 2 +- examples/hello/hello-code-pdl.pdl | 2 +- examples/hello/hello-def-use.pdl | 2 +- examples/hello/hello-model-chaining.pdl | 4 +- examples/hello/hello-model-input.pdl | 2 +- examples/hello/hello-parser-json.pdl | 2 +- examples/hello/hello-parser-regex.pdl | 2 +- examples/hello/hello-roles-array.pdl | 2 +- examples/hello/hello-type.pdl | 2 +- examples/hello/hello.pdl | 2 +- examples/intrinsics/demo-hallucination.pdl | 82 +++++++++---------- examples/rag/pdf_query.pdl | 4 +- examples/rag/tfidf_rag.pdl | 2 +- examples/sdk/hello.pdl | 2 +- examples/talk/1-hello.pdl | 2 +- examples/talk/2-model-chaining.pdl | 4 +- examples/talk/3-def-use.pdl | 4 +- examples/talk/4-function.pdl | 4 +- examples/talk/5-code-eval.pdl | 2 +- examples/talk/6-code-json.pdl | 2 +- examples/talk/7-chatbot-roles.pdl | 4 +- examples/talk/8-tools.pdl | 2 +- examples/tfidf_rag/rag.pdl | 2 +- examples/tutorial/calling_apis.pdl | 4 +- examples/tutorial/calling_llm.pdl | 2 +- examples/tutorial/calling_llm_with_input.pdl | 2 +- .../calling_llm_with_input_messages.pdl | 2 +- examples/tutorial/conditionals_loops.pdl | 4 +- examples/tutorial/data_block.pdl | 2 +- examples/tutorial/data_block_raw.pdl | 2 +- examples/tutorial/for_array.pdl | 2 +- examples/tutorial/for_lastOf.pdl | 2 +- examples/tutorial/function_definition.pdl | 4 +- examples/tutorial/grouping_definitions.pdl | 4 +- examples/tutorial/model_chaining.pdl | 4 +- examples/tutorial/muting_block_output.pdl | 4 +- examples/tutorial/parser_regex.pdl | 4 +- examples/tutorial/variable_def_use.pdl | 2 +- examples/weather/weather.pdl | 4 +- pdl-live-react/demos/demo1.pdl | 2 +- pdl-live-react/demos/demo2.pdl | 4 +- pdl-live-react/demos/error.pdl | 8 +- pdl-live-react/demos/run.sh | 8 +- pdl-live-react/src/demos/demo1.json | 2 +- pdl-live-react/src/demos/demo2.json | 2 +- pdl-live-react/src/demos/demo3.json | 2 +- pdl-live-react/src/demos/demo4.json | 2 +- pdl-live-react/src/demos/demo5.json | 2 +- pdl-live-react/src/demos/demo6.json | 2 +- pdl-live-react/src/demos/demo7.json | 2 +- .../examples/hello/hello-code-pdl.0.result | 2 +- .../results/examples/talk/4-function.0.result | 4 +- .../results/examples/talk/4-function.1.result | 2 + .../examples/talk/4-function.12.result | 2 - .../examples/tutorial/parser_regex.0.result | 4 +- .../examples/tutorial/parser_regex.1.result | 4 +- .../examples/tutorial/parser_regex.2.result | 4 +- .../examples/tutorial/parser_regex.3.result | 9 +- 67 files changed, 138 insertions(+), 146 deletions(-) create mode 100644 tests/results/examples/talk/4-function.1.result delete mode 100644 tests/results/examples/talk/4-function.12.result diff --git a/.github/workflows/run-examples.yml b/.github/workflows/run-examples.yml index 6af370cb5..e8ab7797c 100644 --- a/.github/workflows/run-examples.yml +++ b/.github/workflows/run-examples.yml @@ -33,19 +33,14 @@ jobs: - name: Pull models in examples/ shell: bash run: | - ollama pull granite-code:8b - ollama pull granite3-dense:8b - ollama pull granite3.1-dense ollama pull granite3.2:2b - ollama pull granite3.2 - ollama pull granite3.2:8b ollama pull mxbai-embed-large ollama list - name: Check that all required models are available shell: bash run: | - models=("granite-code" "granite3-dense" "granite3.1-dense" "mxbai-embed-large" "granite3.2:2b" "granite3.2" "granite3.2:8b") + models=("mxbai-embed-large" "granite3.2:2b") missing=0 for model in "${models[@]}"; do if ! ollama list | awk 'NR>1 {print $1}' | grep -q "$model"; then diff --git a/examples/callback/repair_prompt.pdl b/examples/callback/repair_prompt.pdl index e3ec4bfdc..bc795842e 100644 --- a/examples/callback/repair_prompt.pdl +++ b/examples/callback/repair_prompt.pdl @@ -9,7 +9,7 @@ lastOf: Please repair the code! - def: raw_output - model: ollama/granite-code:8b + model: ollama_chat/granite3.2:2b parameters: #stop_sequences: "\n\n" temperature: 0 diff --git a/examples/chatbot/chatbot.pdl b/examples/chatbot/chatbot.pdl index e9c744155..ceb378672 100644 --- a/examples/chatbot/chatbot.pdl +++ b/examples/chatbot/chatbot.pdl @@ -1,4 +1,4 @@ -description: chatbot +description: Chatbot text: # Allow the user to type any question, implicitly adding the question to the context. - read: @@ -6,7 +6,7 @@ text: - repeat: text: # Send context to Granite model hosted at replicate.com - - model: ollama_chat/granite3.2:8b + - model: ollama_chat/granite3.2:2b # Allow the user to type 'yes', 'no', or anything else, storing # the input into a variable named `eval`. The input is also implicitly # added to the context. diff --git a/examples/code/code-eval.pdl b/examples/code/code-eval.pdl index c503feb8c..01cd1a191 100644 --- a/examples/code/code-eval.pdl +++ b/examples/code/code-eval.pdl @@ -12,7 +12,7 @@ text: - "\n${ CODE.source_code }\n" # Use ollama to invoke a Granite model with a prompt. Output AND # set the variable `EXPLANATION` to the output. -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b def: EXPLANATION input: | Here is some info about the location of the function in the repo. diff --git a/examples/code/code-json.pdl b/examples/code/code-json.pdl index 516206f1b..b24945831 100644 --- a/examples/code/code-json.pdl +++ b/examples/code/code-json.pdl @@ -6,7 +6,7 @@ defs: TRUTH: read: ./ground_truth.txt text: -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b def: EXPLANATION contribute: [] input: diff --git a/examples/code/code.pdl b/examples/code/code.pdl index bdabd8386..4c6771899 100644 --- a/examples/code/code.pdl +++ b/examples/code/code.pdl @@ -8,7 +8,7 @@ text: # Output the `source_code:` of the YAML to the console - "\n${ CODE.source_code }\n" # Use ollama to invoke a Granite model with a prompt -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: | Here is some info about the location of the function in the repo. repo: diff --git a/examples/demo/3-weather.pdl b/examples/demo/3-weather.pdl index 14aa6a5b5..9a5e1e89a 100644 --- a/examples/demo/3-weather.pdl +++ b/examples/demo/3-weather.pdl @@ -2,7 +2,7 @@ description: Using a weather API and LLM to make a small weather app text: - def: QUERY text: "What is the weather in Madrid?\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: | Extract the location from the question. Question: What is the weather in London? @@ -25,7 +25,7 @@ text: def: WEATHER parser: json contribute: [] -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: | Explain the weather from the following JSON: ${ WEATHER } diff --git a/examples/demo/4-translator.pdl b/examples/demo/4-translator.pdl index f360fe228..7431cb43e 100644 --- a/examples/demo/4-translator.pdl +++ b/examples/demo/4-translator.pdl @@ -1,7 +1,7 @@ description: PDL program text: - "What is APR?\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b - repeat: text: - read: @@ -11,5 +11,5 @@ text: then: text: - "\n\nTranslate the above to ${ language }\n" - - model: ollama/granite-code:8b + - model: ollama_chat/granite3.2:2b until: ${ language == 'stop' } diff --git a/examples/fibonacci/fib.pdl b/examples/fibonacci/fib.pdl index bf64c3b6e..893da414b 100644 --- a/examples/fibonacci/fib.pdl +++ b/examples/fibonacci/fib.pdl @@ -6,7 +6,7 @@ text: # Use IBM Granite to author a program that computes the Nth Fibonacci number, # storing the generated program into the variable `CODE`. - def: CODE - model: ollama/granite-code:8b + model: ollama_chat/granite3.2:2b input: "Write a Python function to compute the Fibonacci sequence. Do not include a doc string.\n\n" parameters: # Request no randomness when generating code @@ -42,4 +42,4 @@ text: # Invoke the LLM again to explain the PDL context - "\n\nExplain what the above code does and what the result means\n\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b diff --git a/examples/granite/multi_round_chat.pdl b/examples/granite/multi_round_chat.pdl index 43cb2e307..b8d0f39af 100644 --- a/examples/granite/multi_round_chat.pdl +++ b/examples/granite/multi_round_chat.pdl @@ -18,7 +18,7 @@ text: ${ prompt } # Use replicate.com to run the Granite model on the context, outputting the result - - model: ollama/granite3.1-dense + - model: ollama_chat/granite3.2:2b parameters: # Use no LLM model creativity (0 is the default) temperature: 0 diff --git a/examples/hello/hello-code-pdl.pdl b/examples/hello/hello-code-pdl.pdl index a83865910..a2f9a6958 100644 --- a/examples/hello/hello-code-pdl.pdl +++ b/examples/hello/hello-code-pdl.pdl @@ -4,6 +4,6 @@ code: | description: Hello world text: - "Hello\n" - - model: ollama/granite-code:8b + - model: ollama_chat/granite3.2:2b parameters: temperature: 0 diff --git a/examples/hello/hello-def-use.pdl b/examples/hello/hello-def-use.pdl index 11bca13c5..59b75260f 100644 --- a/examples/hello/hello-def-use.pdl +++ b/examples/hello/hello-def-use.pdl @@ -2,7 +2,7 @@ description: Hello world with variable use text: - "Hello\n" # Define GEN to be the result of a Granite LLM using ollama -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b parameters: # Tell the LLM to stop after generating an exclamation point. stop: ['!'] diff --git a/examples/hello/hello-model-chaining.pdl b/examples/hello/hello-model-chaining.pdl index 18d84faf5..1bc11886f 100644 --- a/examples/hello/hello-model-chaining.pdl +++ b/examples/hello/hello-model-chaining.pdl @@ -1,7 +1,7 @@ description: Hello world showing model chaining text: - "Hello\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b parameters: # "greedy" sampling tells the LLM to use the most likely token at each step # decoding_method: greedy # Not used by Ollama @@ -9,7 +9,7 @@ text: stop: ['!'] def: GEN - "\nDid you say ${ GEN }?\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b parameters: # decoding_method: greedy stop: ['.'] diff --git a/examples/hello/hello-model-input.pdl b/examples/hello/hello-model-input.pdl index 70d39ec5b..73b39e1b5 100644 --- a/examples/hello/hello-model-input.pdl +++ b/examples/hello/hello-model-input.pdl @@ -1,6 +1,6 @@ description: Hello world with model input text: -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: "Hello," parameters: # Tell the LLM to stop after generating an exclamation point. diff --git a/examples/hello/hello-parser-json.pdl b/examples/hello/hello-parser-json.pdl index 110874c0e..4c3898c00 100644 --- a/examples/hello/hello-parser-json.pdl +++ b/examples/hello/hello-parser-json.pdl @@ -6,7 +6,7 @@ defs: parser: yaml spec: { questions: [str], answers: [obj] } text: - - model: ollama/granite-code:8b + - model: ollama_chat/granite3.2:2b def: model_output spec: {name: str, age: int} input: diff --git a/examples/hello/hello-parser-regex.pdl b/examples/hello/hello-parser-regex.pdl index 84eeea0d3..cf14dcbfd 100644 --- a/examples/hello/hello-parser-regex.pdl +++ b/examples/hello/hello-parser-regex.pdl @@ -1,6 +1,6 @@ description: Hello world with parser using regex text: -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: "Hello," parameters: # Tell the LLM to stop after generating an exclamation point. diff --git a/examples/hello/hello-roles-array.pdl b/examples/hello/hello-roles-array.pdl index 0494113c5..b846e3c33 100644 --- a/examples/hello/hello-roles-array.pdl +++ b/examples/hello/hello-roles-array.pdl @@ -7,6 +7,6 @@ text: - role: user content: Write a Python function that implement merge sort. contribute: [] -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: ${ prompt } diff --git a/examples/hello/hello-type.pdl b/examples/hello/hello-type.pdl index fa23ab94f..e8ec68657 100644 --- a/examples/hello/hello-type.pdl +++ b/examples/hello/hello-type.pdl @@ -11,7 +11,7 @@ text: return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }.\n" - - model: ollama/granite-code:8b + - model: ollama_chat/granite3.2:2b parameters: stop: ["\n"] - call: ${ translate } diff --git a/examples/hello/hello.pdl b/examples/hello/hello.pdl index dbf3032c4..38d3f7fd9 100644 --- a/examples/hello/hello.pdl +++ b/examples/hello/hello.pdl @@ -1,4 +1,4 @@ description: Hello world text: - "Hello\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b diff --git a/examples/intrinsics/demo-hallucination.pdl b/examples/intrinsics/demo-hallucination.pdl index b8d23809e..3749fd681 100644 --- a/examples/intrinsics/demo-hallucination.pdl +++ b/examples/intrinsics/demo-hallucination.pdl @@ -1,6 +1,6 @@ # Granite.runtime Intrinsics Demo with PDL -# Provide document(s) to Granite3-rag model with hallucination_tag +# Provide document(s) to Granite3-rag model with hallucination_tag # Granite3-rag model: Base model granite3-dense:8b setup with Granite RAG LoRA (Low-Rank Adaption) on ollama # The model responds to a query providing a hallucination score @@ -8,51 +8,51 @@ text: - role: system contribute: [context] - text: + text: data: instruction: | - Respond to the user's latest question based solely on the information provided - in the documents. Ensure that your response is strictly aligned with the facts - in the provided documents. If the information needed to answer the question is - not available in the documents, inform the user that the question cannot be - answered based on the available data. Make sure that your response follows + Respond to the user's latest question based solely on the information provided + in the documents. Ensure that your response is strictly aligned with the facts + in the provided documents. If the information needed to answer the question is + not available in the documents, inform the user that the question cannot be + answered based on the available data. Make sure that your response follows the attributes mentioned in the 'meta' field. - documents: + documents: - doc_id: 1 text: | - Audrey Faith McGraw (born September 21, 1967) is an American singer - and record producer. She is one of the most successful country artists - of all time, having sold more than 40 million albums worldwide. Hill is - married to American singer Tim McGraw, with whom she has recorded several duets. - Hill's first two albums, Take Me as I Am (1993) and It Matters to Me (1995), - were major successes and placed a combined three number ones on Billboard's - country charts. Hill's debut album was Take Me as I Am (1993); sales were strong, - buoyed by the chart success of "Wild One". Hill became the first female country - singer in 30 years to hold Billboard's number one position for four consecutive - weeks when "Wild One" managed the feat in 1994. Her version of "Piece of My Heart", - also went to the top of the country charts in 1994. The album sold a total of - 3 million copies. Other singles from the album include "Take Me as I Am". The recording - of Faith's second album was delayed by surgery to repair a ruptured blood vessel on - her vocal cords. It Matters to Me finally appeared in 1995 and was another - success, with the title track becoming her third number-one country single. - Several other top 10 singles followed, and more than 3 million copies of the - album were sold. The fifth single from the album, "I Can't Do That Anymore", - was written by country music artist Alan Jackson. Other singles from the album - include "You Can't Lose Me", "Someone Else's Dream", and "Let's Go to Vegas". - During this period, Hill appeared on the acclaimed PBS music program Austin City Limits. - In spring 1996, Hill began the Spontaneous Combustion Tour with country singer Tim McGraw. - At that time, Hill had recently become engaged to her former producer, Scott Hendricks, - and McGraw had recently broken an engagement. McGraw and Hill were quickly - attracted to each other and began an affair. After discovering that Hill was - pregnant with their first child, the couple married on October 6, 1996. The - couple have three daughters together: Gracie Katherine (born 1997), Maggie Elizabeth (born 1998) - and Audrey Caroline (born 2001). Since their marriage, Hill and McGraw have endeavored - never to be apart for more than three consecutive days. After the release of It Matters to Me, + Audrey Faith McGraw (born September 21, 1967) is an American singer + and record producer. She is one of the most successful country artists + of all time, having sold more than 40 million albums worldwide. Hill is + married to American singer Tim McGraw, with whom she has recorded several duets. + Hill's first two albums, Take Me as I Am (1993) and It Matters to Me (1995), + were major successes and placed a combined three number ones on Billboard's + country charts. Hill's debut album was Take Me as I Am (1993); sales were strong, + buoyed by the chart success of "Wild One". Hill became the first female country + singer in 30 years to hold Billboard's number one position for four consecutive + weeks when "Wild One" managed the feat in 1994. Her version of "Piece of My Heart", + also went to the top of the country charts in 1994. The album sold a total of + 3 million copies. Other singles from the album include "Take Me as I Am". The recording + of Faith's second album was delayed by surgery to repair a ruptured blood vessel on + her vocal cords. It Matters to Me finally appeared in 1995 and was another + success, with the title track becoming her third number-one country single. + Several other top 10 singles followed, and more than 3 million copies of the + album were sold. The fifth single from the album, "I Can't Do That Anymore", + was written by country music artist Alan Jackson. Other singles from the album + include "You Can't Lose Me", "Someone Else's Dream", and "Let's Go to Vegas". + During this period, Hill appeared on the acclaimed PBS music program Austin City Limits. + In spring 1996, Hill began the Spontaneous Combustion Tour with country singer Tim McGraw. + At that time, Hill had recently become engaged to her former producer, Scott Hendricks, + and McGraw had recently broken an engagement. McGraw and Hill were quickly + attracted to each other and began an affair. After discovering that Hill was + pregnant with their first child, the couple married on October 6, 1996. The + couple have three daughters together: Gracie Katherine (born 1997), Maggie Elizabeth (born 1998) + and Audrey Caroline (born 2001). Since their marriage, Hill and McGraw have endeavored + never to be apart for more than three consecutive days. After the release of It Matters to Me, Hill took a three-year break from recording to give herself a rest from four years of touring - and to begin a family with McGraw. During her break, she joined forces with her husband - for their first duet, "It's Your Love". The song stayed at number one for six weeks, - and won awards from both the Academy of Country Music and the Country Music Association. - Hill has remarked that sometimes when they perform the song together, + and to begin a family with McGraw. During her break, she joined forces with her husband + for their first duet, "It's Your Love". The song stayed at number one for six weeks, + and won awards from both the Academy of Country Music and the Country Music Association. + Hill has remarked that sometimes when they perform the song together, "it [doesn't] feel like anybody else was really watching." meta: hallucination_tags: true @@ -70,7 +70,7 @@ text: - defs: # Store the results of making the LLM invocation in a JSON variable named 'out' out: - model: ollama/granite3-rag:8b + model: ollama_chat/granite3.2:2b parameters: temperature: 0 parser: json diff --git a/examples/rag/pdf_query.pdl b/examples/rag/pdf_query.pdl index 1c2929f2c..9769cf6a7 100644 --- a/examples/rag/pdf_query.pdl +++ b/examples/rag/pdf_query.pdl @@ -22,7 +22,7 @@ lastOf: inp: ${ question } encoder_model: "ollama/mxbai-embed-large" limit: 3 - collection_name: "pdl_rag_collection" + collection_name: "pdl_rag_collection" database_name: "./pdl-rag-demo.db" # debug: # lang: python @@ -30,7 +30,7 @@ lastOf: # print(f"MATCHING_PASSAGES='{MATCHING_PASSAGES}'") # result = None CONCLUSION: - model: ollama/granite-code:8b + model: ollama_chat/granite3.2:2b input: > Here is some information: ${ MATCHING_PASSAGES } diff --git a/examples/rag/tfidf_rag.pdl b/examples/rag/tfidf_rag.pdl index 2b5bbccec..6c2acd74b 100644 --- a/examples/rag/tfidf_rag.pdl +++ b/examples/rag/tfidf_rag.pdl @@ -42,6 +42,6 @@ text: Q: ${ TEST_PROMPT } A: -- model: ollama/granite3.2:8b +- model: ollama_chat/granite3.2:2b parameters: temperature: 0 \ No newline at end of file diff --git a/examples/sdk/hello.pdl b/examples/sdk/hello.pdl index 302f6b12c..abff23236 100644 --- a/examples/sdk/hello.pdl +++ b/examples/sdk/hello.pdl @@ -1,5 +1,5 @@ text: - "Hello\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b parameters: stop: ['!'] diff --git a/examples/talk/1-hello.pdl b/examples/talk/1-hello.pdl index 0277fd6b1..8f0a85019 100644 --- a/examples/talk/1-hello.pdl +++ b/examples/talk/1-hello.pdl @@ -1,7 +1,7 @@ description: Model call text: - "Hello\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b parameters: stop: ["!"] # include_stop_sequence: true diff --git a/examples/talk/2-model-chaining.pdl b/examples/talk/2-model-chaining.pdl index d909eee82..39f692d02 100644 --- a/examples/talk/2-model-chaining.pdl +++ b/examples/talk/2-model-chaining.pdl @@ -1,10 +1,10 @@ description: Model chaining text: - "Hello\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b parameters: stop: ["!"] - "\nDid you just say Hello?\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b parameters: stop: ["!"] diff --git a/examples/talk/3-def-use.pdl b/examples/talk/3-def-use.pdl index cd0148097..bf6c73cbc 100644 --- a/examples/talk/3-def-use.pdl +++ b/examples/talk/3-def-use.pdl @@ -1,12 +1,12 @@ description: Variable def and use, model input text: - "Hello\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b def: name parameters: stop: ["!"] - "\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: "Translate the word ${ name | trim } to French\n" parameters: stop: ["\n"] diff --git a/examples/talk/4-function.pdl b/examples/talk/4-function.pdl index a22703e5c..553aae6f0 100644 --- a/examples/talk/4-function.pdl +++ b/examples/talk/4-function.pdl @@ -1,4 +1,4 @@ -description: function def and call +description: Function def and call text: - def: translate function: @@ -7,7 +7,7 @@ text: return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }.\n" - - model: ollama/granite-code:8b + - model: ollama_chat/granite3.2:2b parameters: stop: ["\n"] temperature: 0 diff --git a/examples/talk/5-code-eval.pdl b/examples/talk/5-code-eval.pdl index c503feb8c..01cd1a191 100644 --- a/examples/talk/5-code-eval.pdl +++ b/examples/talk/5-code-eval.pdl @@ -12,7 +12,7 @@ text: - "\n${ CODE.source_code }\n" # Use ollama to invoke a Granite model with a prompt. Output AND # set the variable `EXPLANATION` to the output. -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b def: EXPLANATION input: | Here is some info about the location of the function in the repo. diff --git a/examples/talk/6-code-json.pdl b/examples/talk/6-code-json.pdl index 516206f1b..b24945831 100644 --- a/examples/talk/6-code-json.pdl +++ b/examples/talk/6-code-json.pdl @@ -6,7 +6,7 @@ defs: TRUTH: read: ./ground_truth.txt text: -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b def: EXPLANATION contribute: [] input: diff --git a/examples/talk/7-chatbot-roles.pdl b/examples/talk/7-chatbot-roles.pdl index 88238c136..cd35c4948 100644 --- a/examples/talk/7-chatbot-roles.pdl +++ b/examples/talk/7-chatbot-roles.pdl @@ -1,4 +1,4 @@ -description: chatbot, control structures, roles, contribute +description: Chatbot, control structures, roles, contribute text: - role: system contribute: [context] @@ -10,7 +10,7 @@ text: message: ">>> " def: query contribute: [context] - - model: ollama/granite-code:8b + - model: ollama_chat/granite3.2:2b - "\n\n" until: ${ query == 'quit'} join: diff --git a/examples/talk/8-tools.pdl b/examples/talk/8-tools.pdl index 7ec3c7ab6..5dff6ae4e 100644 --- a/examples/talk/8-tools.pdl +++ b/examples/talk/8-tools.pdl @@ -1,4 +1,4 @@ -description: tool use +description: Tool use defs: tools: data: diff --git a/examples/tfidf_rag/rag.pdl b/examples/tfidf_rag/rag.pdl index 939493126..cf7f78c9f 100644 --- a/examples/tfidf_rag/rag.pdl +++ b/examples/tfidf_rag/rag.pdl @@ -42,4 +42,4 @@ text: Q: ${ TEST_PROMPT } A: -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b diff --git a/examples/tutorial/calling_apis.pdl b/examples/tutorial/calling_apis.pdl index 9cb7323dd..29ff395ac 100644 --- a/examples/tutorial/calling_apis.pdl +++ b/examples/tutorial/calling_apis.pdl @@ -2,7 +2,7 @@ description: Using a weather API and LLM to make a small weather app text: - def: QUERY text: "What is the weather in Madrid?\n" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b input: | Extract the location from the question. Question: What is the weather in London? @@ -25,7 +25,7 @@ text: def: WEATHER parser: json contribute: [] -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b input: | Explain the weather from the following JSON: ${ WEATHER } diff --git a/examples/tutorial/calling_llm.pdl b/examples/tutorial/calling_llm.pdl index b11181710..00d09ccdd 100644 --- a/examples/tutorial/calling_llm.pdl +++ b/examples/tutorial/calling_llm.pdl @@ -1,6 +1,6 @@ description: Hello world calling a model text: - "Hello\n" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b parameters: stop: ['!'] \ No newline at end of file diff --git a/examples/tutorial/calling_llm_with_input.pdl b/examples/tutorial/calling_llm_with_input.pdl index 8f8f68f8c..f16648849 100644 --- a/examples/tutorial/calling_llm_with_input.pdl +++ b/examples/tutorial/calling_llm_with_input.pdl @@ -1,6 +1,6 @@ description: Hello world calling a model text: - "Hello\n" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b input: Translate the word 'Hello' to French diff --git a/examples/tutorial/calling_llm_with_input_messages.pdl b/examples/tutorial/calling_llm_with_input_messages.pdl index be7bf15b4..c994d7788 100644 --- a/examples/tutorial/calling_llm_with_input_messages.pdl +++ b/examples/tutorial/calling_llm_with_input_messages.pdl @@ -1,7 +1,7 @@ description: Hello world calling a model text: - "Hello\n" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b input: array: - role: system diff --git a/examples/tutorial/conditionals_loops.pdl b/examples/tutorial/conditionals_loops.pdl index 7e86496d8..59d3be27f 100644 --- a/examples/tutorial/conditionals_loops.pdl +++ b/examples/tutorial/conditionals_loops.pdl @@ -1,11 +1,11 @@ -description: chatbot +description: Chatbot text: - read: message: "What is your query?\n" contribute: [context] - repeat: text: - - model: ollama/granite3.2:2b + - model: ollama_chat/granite3.2:2b - read: def: eval message: "\nIs this a good answer[yes/no]?\n" diff --git a/examples/tutorial/data_block.pdl b/examples/tutorial/data_block.pdl index 038c1e56b..1f1c7632b 100644 --- a/examples/tutorial/data_block.pdl +++ b/examples/tutorial/data_block.pdl @@ -6,7 +6,7 @@ defs: TRUTH: read: ./ground_truth.txt lastOf: -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b def: EXPLANATION input: | diff --git a/examples/tutorial/data_block_raw.pdl b/examples/tutorial/data_block_raw.pdl index f52e73d6b..5a814f813 100644 --- a/examples/tutorial/data_block_raw.pdl +++ b/examples/tutorial/data_block_raw.pdl @@ -1,4 +1,4 @@ -description: raw data block +description: Raw data block data: name: ${ name } phone: ${ phone } diff --git a/examples/tutorial/for_array.pdl b/examples/tutorial/for_array.pdl index 40c07c7ef..6d14b09bd 100644 --- a/examples/tutorial/for_array.pdl +++ b/examples/tutorial/for_array.pdl @@ -1,4 +1,4 @@ -description: array comprehension +description: Array comprehension for: i: [1, 2, 3, 4] repeat: diff --git a/examples/tutorial/for_lastOf.pdl b/examples/tutorial/for_lastOf.pdl index b091f7ac4..5a5cf7814 100644 --- a/examples/tutorial/for_lastOf.pdl +++ b/examples/tutorial/for_lastOf.pdl @@ -1,4 +1,4 @@ -description: loop where the result is the result of the last iteration +description: Loop where the result is the result of the last iteration for: i: [1, 2, 3, 4] repeat: diff --git a/examples/tutorial/function_definition.pdl b/examples/tutorial/function_definition.pdl index 9a8700699..553aae6f0 100644 --- a/examples/tutorial/function_definition.pdl +++ b/examples/tutorial/function_definition.pdl @@ -1,4 +1,4 @@ -description: function def and call +description: Function def and call text: - def: translate function: @@ -7,7 +7,7 @@ text: return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }.\n" - - model: ollama/granite3.2:2b + - model: ollama_chat/granite3.2:2b parameters: stop: ["\n"] temperature: 0 diff --git a/examples/tutorial/grouping_definitions.pdl b/examples/tutorial/grouping_definitions.pdl index 5f212840e..a3cf2e9f8 100644 --- a/examples/tutorial/grouping_definitions.pdl +++ b/examples/tutorial/grouping_definitions.pdl @@ -1,4 +1,4 @@ -description: function def and call +description: Function def and call defs: translate: function: @@ -7,7 +7,7 @@ defs: return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }.\n" - - model: ollama/granite3.2:2b + - model: ollama_chat/granite3.2:2b parameters: stop: ["\n"] text: diff --git a/examples/tutorial/model_chaining.pdl b/examples/tutorial/model_chaining.pdl index 6c3997c70..39f692d02 100644 --- a/examples/tutorial/model_chaining.pdl +++ b/examples/tutorial/model_chaining.pdl @@ -1,10 +1,10 @@ description: Model chaining text: - "Hello\n" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b parameters: stop: ["!"] - "\nDid you just say Hello?\n" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b parameters: stop: ["!"] diff --git a/examples/tutorial/muting_block_output.pdl b/examples/tutorial/muting_block_output.pdl index 948e8aa93..613b84671 100644 --- a/examples/tutorial/muting_block_output.pdl +++ b/examples/tutorial/muting_block_output.pdl @@ -1,4 +1,4 @@ -description: function def and call +description: Function def and call defs: translate: function: @@ -8,7 +8,7 @@ defs: text: - text: "\nTranslate the sentence '${ sentence }' to ${ language }.\n" contribute: [context] - - model: ollama/granite3.2:2b + - model: ollama_chat/granite3.2:2b parameters: stop: ["\n"] text: diff --git a/examples/tutorial/parser_regex.pdl b/examples/tutorial/parser_regex.pdl index 51f781e8f..3e64598af 100644 --- a/examples/tutorial/parser_regex.pdl +++ b/examples/tutorial/parser_regex.pdl @@ -1,7 +1,9 @@ description: Parse a block output using a regex defs: output: - model: ollama/granite-code:8b + model: ollama_chat/granite3.2:2b + parameters: + temperature: 0 input: Write a Python function that perform the addition of two numbers. parser: spec: diff --git a/examples/tutorial/variable_def_use.pdl b/examples/tutorial/variable_def_use.pdl index c60836310..fea5ac9e9 100644 --- a/examples/tutorial/variable_def_use.pdl +++ b/examples/tutorial/variable_def_use.pdl @@ -1,7 +1,7 @@ description: Hello world with variable def and use text: - "Hello\n" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b def: GEN parameters: stop: ['!'] diff --git a/examples/weather/weather.pdl b/examples/weather/weather.pdl index 20fcdd8fd..82857d72e 100644 --- a/examples/weather/weather.pdl +++ b/examples/weather/weather.pdl @@ -2,7 +2,7 @@ description: Using a weather API and LLM to make a small weather app text: - def: QUERY text: "What is the weather in Madrid?\n" -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: | Extract the location from the question. Question: What is the weather in London? @@ -25,7 +25,7 @@ text: def: WEATHER parser: json contribute: [] -- model: ollama/granite-code:8b +- model: ollama_chat/granite3.2:2b input: | Explain the weather from the following JSON: ${ WEATHER } diff --git a/pdl-live-react/demos/demo1.pdl b/pdl-live-react/demos/demo1.pdl index 3c60ecc8d..f2461c4a5 100644 --- a/pdl-live-react/demos/demo1.pdl +++ b/pdl-live-react/demos/demo1.pdl @@ -1,4 +1,4 @@ description: Simple LLM interaction text: - "write a hello world example, and explain to me how to run it" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b diff --git a/pdl-live-react/demos/demo2.pdl b/pdl-live-react/demos/demo2.pdl index e4d0f1870..9fd4f5314 100644 --- a/pdl-live-react/demos/demo2.pdl +++ b/pdl-live-react/demos/demo2.pdl @@ -1,10 +1,10 @@ description: Model chaining text: - "write a hello world example, and explain to me how to run it" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b parameters: temperature: 0 - "how about in Rust?" -- model: ollama/granite3.2:2b +- model: ollama_chat/granite3.2:2b parameters: temperature: 0 diff --git a/pdl-live-react/demos/error.pdl b/pdl-live-react/demos/error.pdl index 34f562aa9..0dcaa9450 100644 --- a/pdl-live-react/demos/error.pdl +++ b/pdl-live-react/demos/error.pdl @@ -5,19 +5,19 @@ defs: parser: yaml spec: { questions: [str], answers: [obj] } text: - - model: ollama/llama3.1:8b + - model: ollama_chat/granite3.2:2b def: model_output spec: {name: str, age: int} input: text: - - for: + - for: question: ${ data.questions } answer: ${ data.answers } repeat: | ${ question } ${ answer } - - > - Question: Create a JSON object with fields 'name' and 'age' + - > + Question: Create a JSON object with fields 'name' and 'age' and set them appropriately. Write the age in letters. parser: yaml parameters: diff --git a/pdl-live-react/demos/run.sh b/pdl-live-react/demos/run.sh index 616ebbc13..cdca67eaf 100755 --- a/pdl-live-react/demos/run.sh +++ b/pdl-live-react/demos/run.sh @@ -7,15 +7,15 @@ T="$UI"/src/demos # place to store traces pdl --trace "$T"/demo1.json "$UI"/demos/demo1.pdl pdl --trace "$T"/demo2.json "$UI"/demos/demo2.pdl -pdl --trace "$T"/demo3.json <(cat "$TOP"/examples/fibonacci/fib.pdl | sed -E 's#(model: )(.+)#\1ollama/llama3.1:8b#g') -pdl --trace "$T"/demo4.json <(cat "$TOP"/examples/chatbot/chatbot.pdl | sed -E 's#(model: )(.+)#\1ollama/llama3.1:8b#g') < "$TOP"/examples/talk/6-code-json.pdl.tmp \ +cat "$TOP"/examples/talk/6-code-json.pdl | sed -E 's#(model: )(.+)#\1ollama_chat/granite3.2:2b#g' > "$TOP"/examples/talk/6-code-json.pdl.tmp \ && pdl --trace "$T"/demo5.json "$TOP"/examples/talk/6-code-json.pdl.tmp \ && rm "$TOP"/examples/talk/6-code-json.pdl.tmp pdl --trace "$T"/demo6.json "$UI"/demos/error.pdl || true -pdl --trace "$T"/demo7.json <(cat "$TOP"/examples/talk/4-function.pdl | sed -E 's#(model: )(.+)#\1ollama/llama3.1:8b#g') +pdl --trace "$T"/demo7.json <(cat "$TOP"/examples/talk/4-function.pdl | sed -E 's#(model: )(.+)#\1ollama_chat/granite3.2:2b#g') diff --git a/pdl-live-react/src/demos/demo1.json b/pdl-live-react/src/demos/demo1.json index 2d8a77739..ef884d991 100644 --- a/pdl-live-react/src/demos/demo1.json +++ b/pdl-live-react/src/demos/demo1.json @@ -1 +1 @@ -{"kind": "text", "pdl__id": "text", "pdl__timing": {"start_nanos": 1741032563184740000, "end_nanos": 1741032594764885000, "timezone": "EST"}, "description": "Simple LLM interaction", "defs": {}, "text": [{"kind": "data", "pdl__id": "text.0", "pdl__timing": {"start_nanos": 1741032563184833000, "end_nanos": 1741032563185866000, "timezone": "EST"}, "defs": {}, "data": "write a hello world example, and explain to me how to run it", "pdl__result": "write a hello world example, and explain to me how to run it"}, {"kind": "model", "pdl__id": "text.1.model", "context": [{"role": "user", "content": "write a hello world example, and explain to me how to run it", "defsite": "text.0"}], "pdl__timing": {"start_nanos": 1741032563299199000, "end_nanos": 1741032594764778000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama/granite3.2:2b", "pdl__result": "**Hello World Example in Python:**\n\nHere's a simple \"Hello, World!\" program written in Python:\n\n```python\nprint(\"Hello, World!\")\n```\n\nThis code does exactly what its name suggests\u2014it prints the text \"Hello, World!\" to the console.\n\n**How to Run It:**\n\n1. **Using an Integrated Development Environment (IDE) or a Text Editor:**\n - Open your preferred Python IDE (like PyCharm, Visual Studio Code with Python extension, or Jupyter Notebook).\n - Create a new Python file by clicking on \"File\" > \"New File\" in most IDEs, or simply create a `.py` file in the text editor.\n - Copy and paste the above code into this newly created file.\n - Save the file with a `.py` extension, for example, `hello_world.py`.\n\n2. **Using Command Line Interface (CLI):**\n - Open your terminal or command prompt.\n - Navigate to the directory where you saved your Python file using the `cd` command. For instance, if you saved it in a folder named \"PythonProjects\" on your desktop:\n ```\n cd Desktop/PythonProjects\n ```\n - Once you're in the correct directory, run the Python script by typing:\n ```\n python hello_world.py\n ```\n\n3. **Using an Online Python Compiler:**\n - Go to websites like Repl.it (repl.it/languages/python), Jupyter Notebook for free online (nbviewer.jupyter.org), or any other online Python compiler.\n - Copy and paste the code into their editor.\n - Click \"Run\" or press `Shift + Enter` to execute the code.\n\nAfter running, you should see the output:\n\n```\nHello, World!\n```\n\nThis confirms that your \"Hello, World!\" program has executed successfully in Python."}], "pdl__result": "write a hello world example, and explain to me how to run it**Hello World Example in Python:**\n\nHere's a simple \"Hello, World!\" program written in Python:\n\n```python\nprint(\"Hello, World!\")\n```\n\nThis code does exactly what its name suggests\u2014it prints the text \"Hello, World!\" to the console.\n\n**How to Run It:**\n\n1. **Using an Integrated Development Environment (IDE) or a Text Editor:**\n - Open your preferred Python IDE (like PyCharm, Visual Studio Code with Python extension, or Jupyter Notebook).\n - Create a new Python file by clicking on \"File\" > \"New File\" in most IDEs, or simply create a `.py` file in the text editor.\n - Copy and paste the above code into this newly created file.\n - Save the file with a `.py` extension, for example, `hello_world.py`.\n\n2. **Using Command Line Interface (CLI):**\n - Open your terminal or command prompt.\n - Navigate to the directory where you saved your Python file using the `cd` command. For instance, if you saved it in a folder named \"PythonProjects\" on your desktop:\n ```\n cd Desktop/PythonProjects\n ```\n - Once you're in the correct directory, run the Python script by typing:\n ```\n python hello_world.py\n ```\n\n3. **Using an Online Python Compiler:**\n - Go to websites like Repl.it (repl.it/languages/python), Jupyter Notebook for free online (nbviewer.jupyter.org), or any other online Python compiler.\n - Copy and paste the code into their editor.\n - Click \"Run\" or press `Shift + Enter` to execute the code.\n\nAfter running, you should see the output:\n\n```\nHello, World!\n```\n\nThis confirms that your \"Hello, World!\" program has executed successfully in Python."} \ No newline at end of file +{"kind": "text", "id": "text", "pdl__timing": {"start_nanos": 1741203490424620000, "end_nanos": 1741203498003834000, "timezone": "EST"}, "description": "Simple LLM interaction", "defs": {}, "text": [{"kind": "data", "id": "text.0", "pdl__timing": {"start_nanos": 1741203490424655000, "end_nanos": 1741203490425246000, "timezone": "EST"}, "defs": {}, "data": "write a hello world example, and explain to me how to run it", "result": "write a hello world example, and explain to me how to run it"}, {"kind": "model", "id": "text.1.model", "context": [{"role": "user", "content": "write a hello world example, and explain to me how to run it", "defsite": "text.0"}], "pdl__timing": {"start_nanos": 1741203490468365000, "end_nanos": 1741203498003775000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "result": "Sure, here's a simple \"Hello, World!\" program in three popular programming languages: Python, JavaScript (using Node.js), and C.\n\n**Python:**\n\n```python\nprint(\"Hello, World!\")\n```\n\nTo run this Python code, follow these steps:\n\n1. Save the text above in a file with a `.py` extension, for example, `hello_world.py`.\n2. Open your terminal or command prompt.\n3. Navigate to the directory where you saved `hello_world.py` using the `cd` command (e.g., `cd /path/to/your/directory`).\n4. Run the Python script by typing `python hello_world.py` and pressing Enter. You should see \"Hello, World!\" printed in the terminal.\n\n**JavaScript (Node.js):**\n\n```javascript\nconsole.log(\"Hello, World!\");\n```\n\nTo run this JavaScript code using Node.js:\n\n1. Install Node.js from https://nodejs.org/ if you haven't already (make sure to read their instructions carefully for your operating system).\n2. Open a terminal or command prompt.\n3. Create a new file, `index.js`, and add the JavaScript code above.\n4. Change to the directory containing `index.js` using `cd /path/to/your/directory`.\n5. Run the script by typing `node index.js` and pressing Enter. You should see \"Hello, World!\" printed in your terminal.\n\n**C:**\n\n```c\n#include \n\nint main() {\n printf(\"Hello, World!\\n\");\n return 0;\n}\n```\n\nTo compile and run this C program:\n\n1. Save the code above to a file with a `.c` extension, for example, `hello_world.c`.\n2. Open your terminal or command prompt.\n3. Install the GNU Compiler Collection (GCC) if it's not already installed on your system; otherwise, you can use an IDE like Visual Studio Code which supports C directly.\n4. Compile the C program by typing `gcc hello_world.c -o hello_world` and pressing Enter. This will generate an executable file called `hello_world`.\n5. Run the compiled program with `./hello_world` (on Unix-based systems) or `hello_world.exe` (on Windows), and you should see \"Hello, World!\" printed in your terminal.\n\nEach example prints \"Hello, World!\" as a simple greeting, demonstrating that each language can execute basic text output to the console."}], "result": "write a hello world example, and explain to me how to run itSure, here's a simple \"Hello, World!\" program in three popular programming languages: Python, JavaScript (using Node.js), and C.\n\n**Python:**\n\n```python\nprint(\"Hello, World!\")\n```\n\nTo run this Python code, follow these steps:\n\n1. Save the text above in a file with a `.py` extension, for example, `hello_world.py`.\n2. Open your terminal or command prompt.\n3. Navigate to the directory where you saved `hello_world.py` using the `cd` command (e.g., `cd /path/to/your/directory`).\n4. Run the Python script by typing `python hello_world.py` and pressing Enter. You should see \"Hello, World!\" printed in the terminal.\n\n**JavaScript (Node.js):**\n\n```javascript\nconsole.log(\"Hello, World!\");\n```\n\nTo run this JavaScript code using Node.js:\n\n1. Install Node.js from https://nodejs.org/ if you haven't already (make sure to read their instructions carefully for your operating system).\n2. Open a terminal or command prompt.\n3. Create a new file, `index.js`, and add the JavaScript code above.\n4. Change to the directory containing `index.js` using `cd /path/to/your/directory`.\n5. Run the script by typing `node index.js` and pressing Enter. You should see \"Hello, World!\" printed in your terminal.\n\n**C:**\n\n```c\n#include \n\nint main() {\n printf(\"Hello, World!\\n\");\n return 0;\n}\n```\n\nTo compile and run this C program:\n\n1. Save the code above to a file with a `.c` extension, for example, `hello_world.c`.\n2. Open your terminal or command prompt.\n3. Install the GNU Compiler Collection (GCC) if it's not already installed on your system; otherwise, you can use an IDE like Visual Studio Code which supports C directly.\n4. Compile the C program by typing `gcc hello_world.c -o hello_world` and pressing Enter. This will generate an executable file called `hello_world`.\n5. Run the compiled program with `./hello_world` (on Unix-based systems) or `hello_world.exe` (on Windows), and you should see \"Hello, World!\" printed in your terminal.\n\nEach example prints \"Hello, World!\" as a simple greeting, demonstrating that each language can execute basic text output to the console."} \ No newline at end of file diff --git a/pdl-live-react/src/demos/demo2.json b/pdl-live-react/src/demos/demo2.json index 29d0b0134..a853ada64 100644 --- a/pdl-live-react/src/demos/demo2.json +++ b/pdl-live-react/src/demos/demo2.json @@ -1 +1 @@ -{"kind": "text", "pdl__id": "text", "pdl__timing": {"start_nanos": 1741032596702026000, "end_nanos": 1741032689306693000, "timezone": "EST"}, "description": "Model chaining", "defs": {}, "text": [{"kind": "data", "pdl__id": "text.0", "pdl__timing": {"start_nanos": 1741032596702145000, "end_nanos": 1741032596703380000, "timezone": "EST"}, "defs": {}, "data": "write a hello world example, and explain to me how to run it", "pdl__result": "write a hello world example, and explain to me how to run it"}, {"kind": "model", "pdl__id": "text.1.model", "context": [{"role": "user", "content": "write a hello world example, and explain to me how to run it", "defsite": "text.0"}], "pdl__timing": {"start_nanos": 1741032596827745000, "end_nanos": 1741032639543234000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama/granite3.2:2b", "parameters": {"temperature": 0.0}, "pdl__result": "**Hello World Example in Python:**\n\nHere's a simple \"Hello, World!\" program written in Python:\n\n```python\nprint(\"Hello, World!\")\n```\n\nThis code does the following:\n1. `print()` is a built-in function in Python used to display output.\n2. The string `\"Hello, World!\"` is passed as an argument to this function. When executed, it will print \"Hello, World!\" to the console or terminal.\n\n**How to Run a Hello World Example:**\n\n1. **Using an Integrated Development Environment (IDE) like PyCharm, Visual Studio Code, or Jupyter Notebook:**\n\n - Open your preferred IDE.\n - Create a new Python file (e.g., `hello_world.py`).\n - Copy and paste the code above into this file.\n - Save the file with a `.py` extension (e.g., `hello_world.py`).\n - To run the script, you can either:\n - Right-click within the editor and select \"Run 'hello_world' with Python\" (in PyCharm or Visual Studio Code).\n - Use the terminal/command prompt in your IDE to navigate to the directory containing `hello_world.py`, then type `python hello_world.py` and press Enter.\n\n2. **Using a Text Editor:**\n\n - Open a text editor like Notepad (on Windows), TextEdit (on macOS), or Visual Studio Code on any platform.\n - Copy and paste the code into this file.\n - Save the file with a `.py` extension, e.g., `hello_world.py`.\n - To run it:\n - Open your terminal/command prompt.\n - Navigate to the directory containing `hello_world.py` using the `cd` command (e.g., `cd Documents`).\n - Type `python hello_world.py` and press Enter.\n\n3. **Online Python Compilers:**\n\n If you don't want to install any software, you can use online compilers like Repl.it or JDoodle:\n - Go to the website (repl.it for example).\n - Create a new Python file by clicking on \"New Notebook\" or similar.\n - Copy and paste the code into this file.\n - Save it with a `.py` extension, e.g., `hello_world.py`.\n - Click on the \"Run\" button (usually represented by a play icon) to execute the code.\n\nAfter running any of these examples, you should see the output:\n```\nHello, World!\n```"}, {"kind": "data", "pdl__id": "text.2", "pdl__timing": {"start_nanos": 1741032639543347000, "end_nanos": 1741032639543491000, "timezone": "EST"}, "defs": {}, "data": "how about in Rust?", "pdl__result": "how about in Rust?"}, {"kind": "model", "pdl__id": "text.3.model", "context": [{"role": "user", "content": "write a hello world example, and explain to me how to run it", "defsite": "text.0"}, {"content": "**Hello World Example in Python:**\n\nHere's a simple \"Hello, World!\" program written in Python:\n\n```python\nprint(\"Hello, World!\")\n```\n\nThis code does the following:\n1. `print()` is a built-in function in Python used to display output.\n2. The string `\"Hello, World!\"` is passed as an argument to this function. When executed, it will print \"Hello, World!\" to the console or terminal.\n\n**How to Run a Hello World Example:**\n\n1. **Using an Integrated Development Environment (IDE) like PyCharm, Visual Studio Code, or Jupyter Notebook:**\n\n - Open your preferred IDE.\n - Create a new Python file (e.g., `hello_world.py`).\n - Copy and paste the code above into this file.\n - Save the file with a `.py` extension (e.g., `hello_world.py`).\n - To run the script, you can either:\n - Right-click within the editor and select \"Run 'hello_world' with Python\" (in PyCharm or Visual Studio Code).\n - Use the terminal/command prompt in your IDE to navigate to the directory containing `hello_world.py`, then type `python hello_world.py` and press Enter.\n\n2. **Using a Text Editor:**\n\n - Open a text editor like Notepad (on Windows), TextEdit (on macOS), or Visual Studio Code on any platform.\n - Copy and paste the code into this file.\n - Save the file with a `.py` extension, e.g., `hello_world.py`.\n - To run it:\n - Open your terminal/command prompt.\n - Navigate to the directory containing `hello_world.py` using the `cd` command (e.g., `cd Documents`).\n - Type `python hello_world.py` and press Enter.\n\n3. **Online Python Compilers:**\n\n If you don't want to install any software, you can use online compilers like Repl.it or JDoodle:\n - Go to the website (repl.it for example).\n - Create a new Python file by clicking on \"New Notebook\" or similar.\n - Copy and paste the code into this file.\n - Save it with a `.py` extension, e.g., `hello_world.py`.\n - Click on the \"Run\" button (usually represented by a play icon) to execute the code.\n\nAfter running any of these examples, you should see the output:\n```\nHello, World!\n```", "role": "assistant", "defsite": "text.1.model"}, {"role": "user", "content": "how about in Rust?", "defsite": "text.2"}], "pdl__timing": {"start_nanos": 1741032639543745000, "end_nanos": 1741032689306576000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama/granite3.2:2b", "parameters": {"temperature": 0.0}, "pdl__result": "**Hello World Example in Rust:**\n\nHere's how to write and run a \"Hello, World!\" program in Rust:\n\n1. **Using `cargo new` command (recommended for beginners):**\n\n - Open your terminal or command prompt.\n - Create a new Rust project by typing the following command and pressing Enter:\n\n ```\n cargo new hello_world\n cd hello_world\n ```\n\n - This will create a new directory named `hello_world` with a basic project structure, including a `Cargo.toml` file for package management and a `src` folder containing an initial `main.rs` file.\n\n2. **Edit the `main.rs` file:**\n\n Open the `src/main.rs` file in your favorite text editor or IDE (e.g., Visual Studio Code with the Rust extension). Replace its content with:\n\n ```rust\n fn main() {\n println!(\"Hello, World!\");\n }\n ```\n\n3. **Compile and run the program:**\n\n - In the terminal/command prompt, navigate to the project directory by typing:\n\n ```\n cd hello_world\n ```\n\n - Compile the Rust code using `cargo`:\n\n ```\n cargo build --release\n ```\n\n - After successful compilation (which should be indicated with no error messages), you can run the program directly from the compiled binary:\n\n ```\n ./target/release/hello_world\n ```\n\n Or, if you prefer to use an IDE like Visual Studio Code with the Rust extension:\n\n - Open your project in VS Code.\n - Run the `main` function by right-clicking on it and selecting \"Run 'main' without debugging\" (or press `F5`).\n\nAfter running this Rust code, you should see the output:\n\n```\nHello, World!\n```\n\nThis demonstrates how to write a simple \"Hello, World!\" program in Rust and execute it using both command-line tools and an IDE."}], "pdl__result": "write a hello world example, and explain to me how to run it**Hello World Example in Python:**\n\nHere's a simple \"Hello, World!\" program written in Python:\n\n```python\nprint(\"Hello, World!\")\n```\n\nThis code does the following:\n1. `print()` is a built-in function in Python used to display output.\n2. The string `\"Hello, World!\"` is passed as an argument to this function. When executed, it will print \"Hello, World!\" to the console or terminal.\n\n**How to Run a Hello World Example:**\n\n1. **Using an Integrated Development Environment (IDE) like PyCharm, Visual Studio Code, or Jupyter Notebook:**\n\n - Open your preferred IDE.\n - Create a new Python file (e.g., `hello_world.py`).\n - Copy and paste the code above into this file.\n - Save the file with a `.py` extension (e.g., `hello_world.py`).\n - To run the script, you can either:\n - Right-click within the editor and select \"Run 'hello_world' with Python\" (in PyCharm or Visual Studio Code).\n - Use the terminal/command prompt in your IDE to navigate to the directory containing `hello_world.py`, then type `python hello_world.py` and press Enter.\n\n2. **Using a Text Editor:**\n\n - Open a text editor like Notepad (on Windows), TextEdit (on macOS), or Visual Studio Code on any platform.\n - Copy and paste the code into this file.\n - Save the file with a `.py` extension, e.g., `hello_world.py`.\n - To run it:\n - Open your terminal/command prompt.\n - Navigate to the directory containing `hello_world.py` using the `cd` command (e.g., `cd Documents`).\n - Type `python hello_world.py` and press Enter.\n\n3. **Online Python Compilers:**\n\n If you don't want to install any software, you can use online compilers like Repl.it or JDoodle:\n - Go to the website (repl.it for example).\n - Create a new Python file by clicking on \"New Notebook\" or similar.\n - Copy and paste the code into this file.\n - Save it with a `.py` extension, e.g., `hello_world.py`.\n - Click on the \"Run\" button (usually represented by a play icon) to execute the code.\n\nAfter running any of these examples, you should see the output:\n```\nHello, World!\n```how about in Rust?**Hello World Example in Rust:**\n\nHere's how to write and run a \"Hello, World!\" program in Rust:\n\n1. **Using `cargo new` command (recommended for beginners):**\n\n - Open your terminal or command prompt.\n - Create a new Rust project by typing the following command and pressing Enter:\n\n ```\n cargo new hello_world\n cd hello_world\n ```\n\n - This will create a new directory named `hello_world` with a basic project structure, including a `Cargo.toml` file for package management and a `src` folder containing an initial `main.rs` file.\n\n2. **Edit the `main.rs` file:**\n\n Open the `src/main.rs` file in your favorite text editor or IDE (e.g., Visual Studio Code with the Rust extension). Replace its content with:\n\n ```rust\n fn main() {\n println!(\"Hello, World!\");\n }\n ```\n\n3. **Compile and run the program:**\n\n - In the terminal/command prompt, navigate to the project directory by typing:\n\n ```\n cd hello_world\n ```\n\n - Compile the Rust code using `cargo`:\n\n ```\n cargo build --release\n ```\n\n - After successful compilation (which should be indicated with no error messages), you can run the program directly from the compiled binary:\n\n ```\n ./target/release/hello_world\n ```\n\n Or, if you prefer to use an IDE like Visual Studio Code with the Rust extension:\n\n - Open your project in VS Code.\n - Run the `main` function by right-clicking on it and selecting \"Run 'main' without debugging\" (or press `F5`).\n\nAfter running this Rust code, you should see the output:\n\n```\nHello, World!\n```\n\nThis demonstrates how to write a simple \"Hello, World!\" program in Rust and execute it using both command-line tools and an IDE."} \ No newline at end of file +{"kind": "text", "id": "text", "pdl__timing": {"start_nanos": 1741203499305879000, "end_nanos": 1741203512418986000, "timezone": "EST"}, "description": "Model chaining", "defs": {}, "text": [{"kind": "data", "id": "text.0", "pdl__timing": {"start_nanos": 1741203499305918000, "end_nanos": 1741203499306499000, "timezone": "EST"}, "defs": {}, "data": "write a hello world example, and explain to me how to run it", "result": "write a hello world example, and explain to me how to run it"}, {"kind": "model", "id": "text.1.model", "context": [{"role": "user", "content": "write a hello world example, and explain to me how to run it", "defsite": "text.0"}], "pdl__timing": {"start_nanos": 1741203499348122000, "end_nanos": 1741203505777560000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "parameters": {"temperature": 0.0}, "result": "Sure, I'd be happy to help with that! Here's a simple \"Hello, World!\" program in Python, which is one of the most popular programming languages:\n\n```python\nprint(\"Hello, World!\")\n```\n\nTo run this code, follow these steps:\n\n1. **Install Python**: If you haven't already installed Python on your computer, download it from the official website (https://www.python.org/downloads/). Choose the latest version of Python 3 for Windows, macOS, or Linux. During installation, make sure to check the box that says \"Add Python to PATH\" (for Windows) or ensure that the correct interpreter is selected during setup (for macOS and Linux).\n\n2. **Open a Text Editor**: Use any text editor like Notepad (for Windows), TextEdit (for macOS), or Visual Studio Code, Sublime Text, Atom, etc. for writing your Python code.\n\n3. **Write the Code**: Copy and paste the following line into your text editor:\n\n ```python\n print(\"Hello, World!\")\n ```\n\n4. **Save the File**: Save this file with a `.py` extension, such as `hello_world.py`. For example, if you're using Notepad on Windows, save it as `hello_world.py`.\n\n5. **Open Command Prompt/Terminal**: On Windows, press `Win + R`, type `cmd`, and hit Enter. On macOS or Linux, open Terminal from the Applications > Utilities folder or by searching for \"Terminal\" in Spotlight.\n\n6. **Navigate to Your File's Location**: Use the `cd` command (for Command Prompt on Windows) or `cd` followed by your file path (for Terminal on macOS and Linux). For instance, if you saved the file in the Desktop folder:\n\n ```\n cd Desktop\n ```\n\n7. **Run the Python Script**: Type `python hello_world.py` (for Command Prompt on Windows) or `python3 hello_world.py` (for Terminal on macOS and Linux), then press Enter. You should see the output \"Hello, World!\" displayed in your terminal window.\n\nThat's it! You've just run a simple Python program. This example demonstrates how to print text using the built-in `print()` function."}, {"kind": "data", "id": "text.2", "pdl__timing": {"start_nanos": 1741203505777592000, "end_nanos": 1741203505777646000, "timezone": "EST"}, "defs": {}, "data": "how about in Rust?", "result": "how about in Rust?"}, {"kind": "model", "id": "text.3.model", "context": [{"role": "user", "content": "write a hello world example, and explain to me how to run it", "defsite": "text.0"}, {"content": "Sure, I'd be happy to help with that! Here's a simple \"Hello, World!\" program in Python, which is one of the most popular programming languages:\n\n```python\nprint(\"Hello, World!\")\n```\n\nTo run this code, follow these steps:\n\n1. **Install Python**: If you haven't already installed Python on your computer, download it from the official website (https://www.python.org/downloads/). Choose the latest version of Python 3 for Windows, macOS, or Linux. During installation, make sure to check the box that says \"Add Python to PATH\" (for Windows) or ensure that the correct interpreter is selected during setup (for macOS and Linux).\n\n2. **Open a Text Editor**: Use any text editor like Notepad (for Windows), TextEdit (for macOS), or Visual Studio Code, Sublime Text, Atom, etc. for writing your Python code.\n\n3. **Write the Code**: Copy and paste the following line into your text editor:\n\n ```python\n print(\"Hello, World!\")\n ```\n\n4. **Save the File**: Save this file with a `.py` extension, such as `hello_world.py`. For example, if you're using Notepad on Windows, save it as `hello_world.py`.\n\n5. **Open Command Prompt/Terminal**: On Windows, press `Win + R`, type `cmd`, and hit Enter. On macOS or Linux, open Terminal from the Applications > Utilities folder or by searching for \"Terminal\" in Spotlight.\n\n6. **Navigate to Your File's Location**: Use the `cd` command (for Command Prompt on Windows) or `cd` followed by your file path (for Terminal on macOS and Linux). For instance, if you saved the file in the Desktop folder:\n\n ```\n cd Desktop\n ```\n\n7. **Run the Python Script**: Type `python hello_world.py` (for Command Prompt on Windows) or `python3 hello_world.py` (for Terminal on macOS and Linux), then press Enter. You should see the output \"Hello, World!\" displayed in your terminal window.\n\nThat's it! You've just run a simple Python program. This example demonstrates how to print text using the built-in `print()` function.", "role": "assistant", "defsite": "text.1.model"}, {"role": "user", "content": "how about in Rust?", "defsite": "text.2"}], "pdl__timing": {"start_nanos": 1741203505777740000, "end_nanos": 1741203512418939000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "parameters": {"temperature": 0.0}, "result": "Certainly! Here's an equivalent \"Hello, World!\" program in Rust:\n\n```rust\nfn main() {\n println!(\"Hello, World!\");\n}\n```\n\nTo run this code, follow these steps:\n\n1. **Install Rust**: If you haven't installed Rust yet, download it from the official website (https://www.rust-lang.org/tools/install). Follow the instructions for your operating system to install Rust and its package manager, Cargo.\n\n2. **Open a Text Editor**: Use any text editor like Visual Studio Code, Sublime Text, Atom, or even a simple tool like Notepad (for Windows) or TextEdit (for macOS).\n\n3. **Write the Code**: Copy and paste the following line into your text editor:\n\n ```rust\n fn main() {\n println!(\"Hello, World!\");\n }\n ```\n\n4. **Save the File**: Save this file with a `.rs` extension, such as `hello_world.rs`. For example, if you're using Visual Studio Code on Windows, save it as `hello_world.rs`.\n\n5. **Open Terminal/Command Prompt**: On Windows, press `Win + R`, type `cmd`, and hit Enter. On macOS or Linux, open Terminal from the Applications > Utilities folder or by searching for \"Terminal\" in Spotlight.\n\n6. **Navigate to Your File's Location**: Use the `cd` command (for Command Prompt on Windows) or `cd` followed by your file path (for Terminal on macOS and Linux). For instance, if you saved the file in the Desktop folder:\n\n ```\n cd Desktop\n ```\n\n7. **Run Rust Code**: Type `cargo run` (for Command Prompt on Windows), `cargo run` (for Terminal on macOS or Linux), then press Enter. This command tells Cargo to build and run your Rust program. You should see \"Hello, World!\" printed in the terminal window.\n\nThat's it! You've just run a simple Rust program. In Rust, you define functions with `fn`, and the `main` function is where the execution begins. The `println!` macro (or simply `println`) is used for printing text to the console."}], "result": "write a hello world example, and explain to me how to run itSure, I'd be happy to help with that! Here's a simple \"Hello, World!\" program in Python, which is one of the most popular programming languages:\n\n```python\nprint(\"Hello, World!\")\n```\n\nTo run this code, follow these steps:\n\n1. **Install Python**: If you haven't already installed Python on your computer, download it from the official website (https://www.python.org/downloads/). Choose the latest version of Python 3 for Windows, macOS, or Linux. During installation, make sure to check the box that says \"Add Python to PATH\" (for Windows) or ensure that the correct interpreter is selected during setup (for macOS and Linux).\n\n2. **Open a Text Editor**: Use any text editor like Notepad (for Windows), TextEdit (for macOS), or Visual Studio Code, Sublime Text, Atom, etc. for writing your Python code.\n\n3. **Write the Code**: Copy and paste the following line into your text editor:\n\n ```python\n print(\"Hello, World!\")\n ```\n\n4. **Save the File**: Save this file with a `.py` extension, such as `hello_world.py`. For example, if you're using Notepad on Windows, save it as `hello_world.py`.\n\n5. **Open Command Prompt/Terminal**: On Windows, press `Win + R`, type `cmd`, and hit Enter. On macOS or Linux, open Terminal from the Applications > Utilities folder or by searching for \"Terminal\" in Spotlight.\n\n6. **Navigate to Your File's Location**: Use the `cd` command (for Command Prompt on Windows) or `cd` followed by your file path (for Terminal on macOS and Linux). For instance, if you saved the file in the Desktop folder:\n\n ```\n cd Desktop\n ```\n\n7. **Run the Python Script**: Type `python hello_world.py` (for Command Prompt on Windows) or `python3 hello_world.py` (for Terminal on macOS and Linux), then press Enter. You should see the output \"Hello, World!\" displayed in your terminal window.\n\nThat's it! You've just run a simple Python program. This example demonstrates how to print text using the built-in `print()` function.how about in Rust?Certainly! Here's an equivalent \"Hello, World!\" program in Rust:\n\n```rust\nfn main() {\n println!(\"Hello, World!\");\n}\n```\n\nTo run this code, follow these steps:\n\n1. **Install Rust**: If you haven't installed Rust yet, download it from the official website (https://www.rust-lang.org/tools/install). Follow the instructions for your operating system to install Rust and its package manager, Cargo.\n\n2. **Open a Text Editor**: Use any text editor like Visual Studio Code, Sublime Text, Atom, or even a simple tool like Notepad (for Windows) or TextEdit (for macOS).\n\n3. **Write the Code**: Copy and paste the following line into your text editor:\n\n ```rust\n fn main() {\n println!(\"Hello, World!\");\n }\n ```\n\n4. **Save the File**: Save this file with a `.rs` extension, such as `hello_world.rs`. For example, if you're using Visual Studio Code on Windows, save it as `hello_world.rs`.\n\n5. **Open Terminal/Command Prompt**: On Windows, press `Win + R`, type `cmd`, and hit Enter. On macOS or Linux, open Terminal from the Applications > Utilities folder or by searching for \"Terminal\" in Spotlight.\n\n6. **Navigate to Your File's Location**: Use the `cd` command (for Command Prompt on Windows) or `cd` followed by your file path (for Terminal on macOS and Linux). For instance, if you saved the file in the Desktop folder:\n\n ```\n cd Desktop\n ```\n\n7. **Run Rust Code**: Type `cargo run` (for Command Prompt on Windows), `cargo run` (for Terminal on macOS or Linux), then press Enter. This command tells Cargo to build and run your Rust program. You should see \"Hello, World!\" printed in the terminal window.\n\nThat's it! You've just run a simple Rust program. In Rust, you define functions with `fn`, and the `main` function is where the execution begins. The `println!` macro (or simply `println`) is used for printing text to the console."} \ No newline at end of file diff --git a/pdl-live-react/src/demos/demo3.json b/pdl-live-react/src/demos/demo3.json index 2d7aaa076..aca4e7529 100644 --- a/pdl-live-react/src/demos/demo3.json +++ b/pdl-live-react/src/demos/demo3.json @@ -1 +1 @@ -{"kind": "text", "pdl__id": "text", "pdl__timing": {"start_nanos": 1741032691193683000, "end_nanos": 1741032793774135000, "timezone": "EST"}, "description": "Fibonacci", "defs": {}, "text": [{"kind": "model", "pdl__id": "text.0.model", "pdl__timing": {"start_nanos": 1741032691193884000, "end_nanos": 1741032705790307000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "input": "Write a Python function to compute the Fibonacci sequence. Do not include a doc string.\n\n", "parameters": {"temperature": 0.0}, "def": "CODE", "pdl__result": "```python\ndef fibonacci(n):\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])\n return fib_sequence[:n]\n\nprint(fibonacci(10))\n```"}, {"kind": "data", "pdl__id": "text.1", "pdl__timing": {"start_nanos": 1741032705790400000, "end_nanos": 1741032705790531000, "timezone": "EST"}, "defs": {}, "data": "\nFind a random number between 1 and 20\n", "pdl__result": "\nFind a random number between 1 and 20\n"}, {"kind": "code", "pdl__id": "text.2.code", "pdl__timing": {"start_nanos": 1741032705790842000, "end_nanos": 1741032705791542000, "timezone": "EST"}, "defs": {}, "lang": "python", "code": {"kind": "data", "pdl__id": "text.2.code", "pdl__timing": {"start_nanos": 1741032705790917000, "end_nanos": 1741032705791039000, "timezone": "EST"}, "defs": {}, "data": "import random\n# (In PDL, set `result` to the output you wish for your code block.)\nresult = random.randint(1, 20)\n", "pdl__result": "import random\n# (In PDL, set `result` to the output you wish for your code block.)\nresult = random.randint(1, 20)\n"}, "def": "N", "pdl__result": 11}, {"kind": "data", "pdl__id": "text.3", "pdl__timing": {"start_nanos": 1741032705791605000, "end_nanos": 1741032705792998000, "timezone": "EST"}, "defs": {}, "data": "\nNow computing fibonacci(${ N })\n", "pdl__result": "\nNow computing fibonacci(11)\n"}, {"kind": "code", "pdl__id": "text.4.code", "pdl__timing": {"start_nanos": 1741032705793189000, "end_nanos": 1741032705794708000, "timezone": "EST"}, "defs": {}, "lang": "python", "code": {"kind": "data", "pdl__id": "text.4.code", "pdl__timing": {"start_nanos": 1741032705793242000, "end_nanos": 1741032705794259000, "timezone": "EST"}, "defs": {}, "data": "s = \"\"\"'${ CODE } '\"\"\"\nresult = s.split(\"```\")[1].replace(\"python\", \"\")\n", "pdl__result": "s = \"\"\"'```python\ndef fibonacci(n):\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])\n return fib_sequence[:n]\n\nprint(fibonacci(10))\n``` '\"\"\"\nresult = s.split(\"```\")[1].replace(\"python\", \"\")\n"}, "def": "EXTRACTED", "pdl__result": "\ndef fibonacci(n):\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])\n return fib_sequence[:n]\n\nprint(fibonacci(10))\n"}, {"kind": "code", "pdl__id": "text.5.code", "pdl__timing": {"start_nanos": 1741032705794802000, "end_nanos": 1741032705796497000, "timezone": "EST"}, "defs": {}, "lang": "python", "code": {"kind": "data", "pdl__id": "text.5.code", "pdl__timing": {"start_nanos": 1741032705794850000, "end_nanos": 1741032705796063000, "timezone": "EST"}, "defs": {}, "data": "${ EXTRACTED }\nresult = fibonacci(${ N })\n", "pdl__result": "\ndef fibonacci(n):\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])\n return fib_sequence[:n]\n\nprint(fibonacci(10))\n\nresult = fibonacci(11)\n"}, "def": "RESULT", "contribute": [], "pdl__result": "[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]"}, {"kind": "data", "pdl__id": "text.6", "pdl__timing": {"start_nanos": 1741032705796558000, "end_nanos": 1741032705797459000, "timezone": "EST"}, "defs": {}, "data": "The result is: ${ RESULT }", "pdl__result": "The result is: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]"}, {"kind": "data", "pdl__id": "text.7", "pdl__timing": {"start_nanos": 1741032705797596000, "end_nanos": 1741032705797701000, "timezone": "EST"}, "defs": {}, "data": "\n\nExplain what the above code does and what the result means\n\n", "pdl__result": "\n\nExplain what the above code does and what the result means\n\n"}, {"kind": "model", "pdl__id": "text.8.model", "context": [{"content": "```python\ndef fibonacci(n):\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])\n return fib_sequence[:n]\n\nprint(fibonacci(10))\n```", "role": "assistant", "defsite": "text.0.model"}, {"role": "user", "content": "\nFind a random number between 1 and 20\n", "defsite": "text.1"}, {"role": "user", "content": "11", "defsite": "text.2.code"}, {"role": "user", "content": "\nNow computing fibonacci(11)\n", "defsite": "text.3"}, {"role": "user", "content": "\ndef fibonacci(n):\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])\n return fib_sequence[:n]\n\nprint(fibonacci(10))\n", "defsite": "text.4.code"}, {"role": "user", "content": "The result is: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]", "defsite": "text.6"}, {"role": "user", "content": "\n\nExplain what the above code does and what the result means\n\n", "defsite": "text.7"}], "pdl__timing": {"start_nanos": 1741032705797861000, "end_nanos": 1741032793773978000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "pdl__result": "**Explanation of the Code**\n\nThe code defines a function `fibonacci(n)` that generates the first `n` numbers 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.\n\nHere's a step-by-step breakdown:\n\n1. Initialize an empty list `fib_sequence` to store the Fibonacci sequence.\n2. Append the first two numbers in the sequence (0 and 1) to the list.\n3. While the length of the list is less than `n`, append the sum of the last two elements in the list (`[-1] + [-2]`) to the end of the list.\n4. Return a slice of the list from index 0 to `n-1` (inclusive), which represents the first `n` numbers in the Fibonacci sequence.\n\n**Result and Meaning**\n\nThe output of `fibonacci(10)` is `[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]`, which are the first 10 numbers in the Fibonacci sequence.\n\nIn this sequence:\n\n* Each number is the sum of the two preceding ones: e.g., `3 = 2 + 1`.\n* The sequence starts with `0` and `1`, which are the first two numbers.\n* The next numbers in the sequence are generated by adding the previous two numbers together.\n\nThe Fibonacci sequence has many interesting properties and applications, such as:\n\n* It appears in nature (e.g., branching of trees, arrangement of leaves).\n* It is used in finance to model population growth and financial markets.\n* It has connections to number theory, algebra, and geometry."}], "pdl__result": "```python\ndef fibonacci(n):\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])\n return fib_sequence[:n]\n\nprint(fibonacci(10))\n```\nFind a random number between 1 and 20\n11\nNow computing fibonacci(11)\n\ndef fibonacci(n):\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])\n return fib_sequence[:n]\n\nprint(fibonacci(10))\nThe result is: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n\nExplain what the above code does and what the result means\n\n**Explanation of the Code**\n\nThe code defines a function `fibonacci(n)` that generates the first `n` numbers 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.\n\nHere's a step-by-step breakdown:\n\n1. Initialize an empty list `fib_sequence` to store the Fibonacci sequence.\n2. Append the first two numbers in the sequence (0 and 1) to the list.\n3. While the length of the list is less than `n`, append the sum of the last two elements in the list (`[-1] + [-2]`) to the end of the list.\n4. Return a slice of the list from index 0 to `n-1` (inclusive), which represents the first `n` numbers in the Fibonacci sequence.\n\n**Result and Meaning**\n\nThe output of `fibonacci(10)` is `[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]`, which are the first 10 numbers in the Fibonacci sequence.\n\nIn this sequence:\n\n* Each number is the sum of the two preceding ones: e.g., `3 = 2 + 1`.\n* The sequence starts with `0` and `1`, which are the first two numbers.\n* The next numbers in the sequence are generated by adding the previous two numbers together.\n\nThe Fibonacci sequence has many interesting properties and applications, such as:\n\n* It appears in nature (e.g., branching of trees, arrangement of leaves).\n* It is used in finance to model population growth and financial markets.\n* It has connections to number theory, algebra, and geometry."} \ No newline at end of file +{"kind": "text", "id": "text", "pdl__timing": {"start_nanos": 1741203513790588000, "end_nanos": 1741203525295800000, "timezone": "EST"}, "description": "Fibonacci", "defs": {}, "text": [{"kind": "model", "id": "text.0.model", "pdl__timing": {"start_nanos": 1741203513790634000, "end_nanos": 1741203517662755000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "input": "Write a Python function to compute the Fibonacci sequence. Do not include a doc string.\n\n", "parameters": {"temperature": 0.0}, "def": "CODE", "result": "Here is a simple Python function that computes the Fibonacci sequence using recursion:\n\n```python\ndef fibonacci(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n```\n\nHowever, this recursive implementation has exponential time complexity due to repeated calculations. For larger inputs, it's more efficient to use an iterative approach or memoization (top-down dynamic programming). Here is a more optimized version using iteration:\n\n```python\ndef fibonacci_optimized(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n\n fib_values = [0, 1]\n for i in range(2, n):\n fib_values.append(fib_values[i - 1] + fib_values[i - 2])\n \n return fib_values[-1]\n```\n\nThis optimized version has linear time complexity and is more efficient for larger inputs."}, {"kind": "data", "id": "text.1", "pdl__timing": {"start_nanos": 1741203517662788000, "end_nanos": 1741203517662861000, "timezone": "EST"}, "defs": {}, "data": "\nFind a random number between 1 and 20\n", "result": "\nFind a random number between 1 and 20\n"}, {"kind": "code", "id": "text.2.code", "pdl__timing": {"start_nanos": 1741203517662974000, "end_nanos": 1741203517663447000, "timezone": "EST"}, "defs": {}, "lang": "python", "code": {"kind": "data", "id": "text.2.code", "pdl__timing": {"start_nanos": 1741203517662995000, "end_nanos": 1741203517663030000, "timezone": "EST"}, "defs": {}, "data": "import random\n# (In PDL, set `result` to the output you wish for your code block.)\nresult = random.randint(1, 20)\n", "result": "import random\n# (In PDL, set `result` to the output you wish for your code block.)\nresult = random.randint(1, 20)\n"}, "def": "N", "result": 8}, {"kind": "data", "id": "text.3", "pdl__timing": {"start_nanos": 1741203517663474000, "end_nanos": 1741203517664019000, "timezone": "EST"}, "defs": {}, "data": "\nNow computing fibonacci(${ N })\n", "result": "\nNow computing fibonacci(8)\n"}, {"kind": "code", "id": "text.4.code", "pdl__timing": {"start_nanos": 1741203517664126000, "end_nanos": 1741203517664615000, "timezone": "EST"}, "defs": {}, "lang": "python", "code": {"kind": "data", "id": "text.4.code", "pdl__timing": {"start_nanos": 1741203517664143000, "end_nanos": 1741203517664452000, "timezone": "EST"}, "defs": {}, "data": "s = \"\"\"'${ CODE } '\"\"\"\nresult = s.split(\"```\")[1].replace(\"python\", \"\")\n", "result": "s = \"\"\"'Here is a simple Python function that computes the Fibonacci sequence using recursion:\n\n```python\ndef fibonacci(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n```\n\nHowever, this recursive implementation has exponential time complexity due to repeated calculations. For larger inputs, it's more efficient to use an iterative approach or memoization (top-down dynamic programming). Here is a more optimized version using iteration:\n\n```python\ndef fibonacci_optimized(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n\n fib_values = [0, 1]\n for i in range(2, n):\n fib_values.append(fib_values[i - 1] + fib_values[i - 2])\n \n return fib_values[-1]\n```\n\nThis optimized version has linear time complexity and is more efficient for larger inputs. '\"\"\"\nresult = s.split(\"```\")[1].replace(\"python\", \"\")\n"}, "def": "EXTRACTED", "result": "\ndef fibonacci(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n"}, {"kind": "code", "id": "text.5.code", "pdl__timing": {"start_nanos": 1741203517664639000, "end_nanos": 1741203517665164000, "timezone": "EST"}, "defs": {}, "lang": "python", "code": {"kind": "data", "id": "text.5.code", "pdl__timing": {"start_nanos": 1741203517664652000, "end_nanos": 1741203517665014000, "timezone": "EST"}, "defs": {}, "data": "${ EXTRACTED }\nresult = fibonacci(${ N })\n", "result": "\ndef fibonacci(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n\nresult = fibonacci(8)\n"}, "def": "RESULT", "contribute": [], "result": 13}, {"kind": "data", "id": "text.6", "pdl__timing": {"start_nanos": 1741203517665179000, "end_nanos": 1741203517665438000, "timezone": "EST"}, "defs": {}, "data": "The result is: ${ RESULT }", "result": "The result is: 13"}, {"kind": "data", "id": "text.7", "pdl__timing": {"start_nanos": 1741203517665495000, "end_nanos": 1741203517665523000, "timezone": "EST"}, "defs": {}, "data": "\n\nExplain what the above code does and what the result means\n\n", "result": "\n\nExplain what the above code does and what the result means\n\n"}, {"kind": "model", "id": "text.8.model", "context": [{"content": "Here is a simple Python function that computes the Fibonacci sequence using recursion:\n\n```python\ndef fibonacci(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n```\n\nHowever, this recursive implementation has exponential time complexity due to repeated calculations. For larger inputs, it's more efficient to use an iterative approach or memoization (top-down dynamic programming). Here is a more optimized version using iteration:\n\n```python\ndef fibonacci_optimized(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n\n fib_values = [0, 1]\n for i in range(2, n):\n fib_values.append(fib_values[i - 1] + fib_values[i - 2])\n \n return fib_values[-1]\n```\n\nThis optimized version has linear time complexity and is more efficient for larger inputs.", "role": "assistant", "defsite": "text.0.model"}, {"role": "user", "content": "\nFind a random number between 1 and 20\n", "defsite": "text.1"}, {"role": "user", "content": "8", "defsite": "text.2.code"}, {"role": "user", "content": "\nNow computing fibonacci(8)\n", "defsite": "text.3"}, {"role": "user", "content": "\ndef fibonacci(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n", "defsite": "text.4.code"}, {"role": "user", "content": "The result is: 13", "defsite": "text.6"}, {"role": "user", "content": "\n\nExplain what the above code does and what the result means\n\n", "defsite": "text.7"}], "pdl__timing": {"start_nanos": 1741203517665581000, "end_nanos": 1741203525295760000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "result": "The provided Python function `fibonacci(n)` calculates the nth number in the Fibonacci sequence using recursion. 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 (0, 1, 1, 2, 3, 5, 8, ...).\n\nIn this case, when you call `fibonacci(8)`, it calculates the 8th number in the Fibonacci sequence:\n\n1. If `n` is less than or equal to 0, return an error message (\"Input should be a positive integer.\") since Fibonacci numbers are defined for positive integers only.\n2. If `n` equals 1, return 0 (the first number in the sequence).\n3. If `n` equals 2, return 1 (the second number in the sequence).\n4. For `n` greater than 2, it uses recursion:\n - It calculates `fibonacci(n - 1)` and adds it to `fibonacci(n - 2)`.\n - This process continues until `n` becomes 1 or 2, at which point it starts returning values based on the defined base cases.\n\nThe result of `fibonacci(8)` is **13**. In the Fibonacci sequence:\n- The third number (after 0 and 1) is 1.\n- The fourth number is calculated as `fibonacci(3) = fibonacci(2) + fibonacci(1) = 1 + 0 = 1`.\n- Continue this way until the eighth term, which is:\n - `fibonacci(4) = fibonacci(3) + fibonacci(2) = 1 + 1 = 2`\n - `fibonacci(5) = fibonacci(4) + fibonacci(3) = 2 + 1 = 3`\n - `fibonacci(6) = fibonacci(5) + fibonacci(4) = 3 + 2 = 5`\n - ... and so on, until we reach `fibonacci(8)` which is:\n - `fibonacci(7) = fibonacci(6) + fibonacci(5) = 5 + 3 = 8`\n - `fibonacci(8) = fibonacci(7) + fibonacci(6) = 8 + 5 = 13`.\n\nSo, the result of `fibonacci(8)` is **13**, which represents the 8th number in the Fibonacci sequence."}], "result": "Here is a simple Python function that computes the Fibonacci sequence using recursion:\n\n```python\ndef fibonacci(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n```\n\nHowever, this recursive implementation has exponential time complexity due to repeated calculations. For larger inputs, it's more efficient to use an iterative approach or memoization (top-down dynamic programming). Here is a more optimized version using iteration:\n\n```python\ndef fibonacci_optimized(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n\n fib_values = [0, 1]\n for i in range(2, n):\n fib_values.append(fib_values[i - 1] + fib_values[i - 2])\n \n return fib_values[-1]\n```\n\nThis optimized version has linear time complexity and is more efficient for larger inputs.\nFind a random number between 1 and 20\n8\nNow computing fibonacci(8)\n\ndef fibonacci(n):\n if n <= 0:\n return \"Input should be a positive integer.\"\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\nThe result is: 13\n\nExplain what the above code does and what the result means\n\nThe provided Python function `fibonacci(n)` calculates the nth number in the Fibonacci sequence using recursion. 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 (0, 1, 1, 2, 3, 5, 8, ...).\n\nIn this case, when you call `fibonacci(8)`, it calculates the 8th number in the Fibonacci sequence:\n\n1. If `n` is less than or equal to 0, return an error message (\"Input should be a positive integer.\") since Fibonacci numbers are defined for positive integers only.\n2. If `n` equals 1, return 0 (the first number in the sequence).\n3. If `n` equals 2, return 1 (the second number in the sequence).\n4. For `n` greater than 2, it uses recursion:\n - It calculates `fibonacci(n - 1)` and adds it to `fibonacci(n - 2)`.\n - This process continues until `n` becomes 1 or 2, at which point it starts returning values based on the defined base cases.\n\nThe result of `fibonacci(8)` is **13**. In the Fibonacci sequence:\n- The third number (after 0 and 1) is 1.\n- The fourth number is calculated as `fibonacci(3) = fibonacci(2) + fibonacci(1) = 1 + 0 = 1`.\n- Continue this way until the eighth term, which is:\n - `fibonacci(4) = fibonacci(3) + fibonacci(2) = 1 + 1 = 2`\n - `fibonacci(5) = fibonacci(4) + fibonacci(3) = 2 + 1 = 3`\n - `fibonacci(6) = fibonacci(5) + fibonacci(4) = 3 + 2 = 5`\n - ... and so on, until we reach `fibonacci(8)` which is:\n - `fibonacci(7) = fibonacci(6) + fibonacci(5) = 5 + 3 = 8`\n - `fibonacci(8) = fibonacci(7) + fibonacci(6) = 8 + 5 = 13`.\n\nSo, the result of `fibonacci(8)` is **13**, which represents the 8th number in the Fibonacci sequence."} \ No newline at end of file diff --git a/pdl-live-react/src/demos/demo4.json b/pdl-live-react/src/demos/demo4.json index 93dee5577..209dffe28 100644 --- a/pdl-live-react/src/demos/demo4.json +++ b/pdl-live-react/src/demos/demo4.json @@ -1 +1 @@ -{"kind": "text", "pdl__id": "text", "description": "Chatbot", "defs": {}, "text": [{"kind": "read", "pdl__id": "text.0.read", "defs": {}, "read": null, "message": "What is your query?\n", "multiline": false, "pdl__result": "what is the fastest animal?", "pdl__timing": {"start_nanos": 1741197524724877000, "end_nanos": 1741197524724972000, "timezone": "EST"}}, {"kind": "repeat", "pdl__id": "text.1.repeat", "defs": {}, "for": null, "while": true, "repeat": {"kind": "text", "pdl__id": "text.1.repeat.1.text", "defs": {}, "text": [{"kind": "model", "pdl__id": "text.1.repeat.1.text.0.model", "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "pdl__timing": {"start_nanos": 1741197527671318000, "end_nanos": 1741197530912277000, "timezone": "EST"}}, {"kind": "read", "pdl__id": "text.1.repeat.1.text.1.read", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "pdl__timing": {"start_nanos": 1741197530912314000, "end_nanos": 1741197530912531000, "timezone": "EST"}}, "\n", {"kind": "if", "pdl__id": "text.1.repeat.1.text.3.if", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "pdl__id": "text.1.repeat.0.text.3.if.0.text", "defs": {}, "text": [{"kind": "read", "pdl__id": "text.1.repeat.0.text.3.if.0.text.0.read", "defs": {}, "read": null, "message": "Why not?\n", "multiline": false, "pdl__timing": {"start_nanos": 1741197527670646000, "end_nanos": 1741197527670725000, "timezone": "EST"}}], "pdl__timing": {"start_nanos": 1741197527670596000, "end_nanos": 1741197527670750000, "timezone": "EST"}}, "pdl__timing": {"start_nanos": 1741197530913011000, "end_nanos": 1741197530913545000, "timezone": "EST"}}], "pdl__timing": {"start_nanos": 1741197527671283000, "end_nanos": 1741197530913573000, "timezone": "EST"}}, "until": "${ eval == 'yes'}", "max_iterations": null, "join": {"with": ""}, "pdl__trace": [{"kind": "text", "pdl__id": "text.1.repeat.0.text", "defs": {}, "text": [{"kind": "model", "pdl__id": "text.1.repeat.0.text.0.model", "context": [{"role": "user", "content": "what is the fastest animal?", "defsite": "text.0.read"}], "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "pdl__result": "The fastest animal on land is the cheetah. This incredible creature can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts covering distances of about 1,500 feet (460 meters). Cheetahs have several adaptations that contribute to their incredible speed, including a lean body, long legs, and a unique, flexible spine. They also have large lungs for efficient oxygen intake during high-speed chases.", "pdl__timing": {"start_nanos": 1741197524725066000, "end_nanos": 1741197527618585000, "timezone": "EST"}}, {"kind": "read", "pdl__id": "text.1.repeat.0.text.1.read", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "pdl__result": "no", "pdl__timing": {"start_nanos": 1741197527618630000, "end_nanos": 1741197527618736000, "timezone": "EST"}}, {"kind": "data", "pdl__id": "text.1.repeat.0.text.2", "defs": {}, "data": "\n", "pdl__result": "\n", "pdl__timing": {"start_nanos": 1741197527618750000, "end_nanos": 1741197527619195000, "timezone": "EST"}}, {"kind": "if", "pdl__id": "text.1.repeat.0.text.3.if", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "pdl__id": "text.1.repeat.0.text.3.if.0.text", "defs": {}, "text": [{"kind": "read", "pdl__id": "text.1.repeat.0.text.3.if.0.text.0.read", "defs": {}, "read": null, "message": "Why not?\n", "multiline": false, "pdl__result": "in europe?", "pdl__timing": {"start_nanos": 1741197527670646000, "end_nanos": 1741197527670725000, "timezone": "EST"}}], "pdl__result": "in europe?", "pdl__timing": {"start_nanos": 1741197527670596000, "end_nanos": 1741197527670750000, "timezone": "EST"}}, "if_result": true, "pdl__result": "in europe?", "pdl__timing": {"start_nanos": 1741197527669322000, "end_nanos": 1741197527670771000, "timezone": "EST"}}], "pdl__result": "The fastest animal on land is the cheetah. This incredible creature can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts covering distances of about 1,500 feet (460 meters). Cheetahs have several adaptations that contribute to their incredible speed, including a lean body, long legs, and a unique, flexible spine. They also have large lungs for efficient oxygen intake during high-speed chases.no\nin europe?", "pdl__timing": {"start_nanos": 1741197524725034000, "end_nanos": 1741197527670791000, "timezone": "EST"}}, {"kind": "text", "pdl__id": "text.1.repeat.1.text", "defs": {}, "text": [{"kind": "model", "pdl__id": "text.1.repeat.1.text.0.model", "context": [{"role": "user", "content": "what is the fastest animal?", "defsite": "text.0.read"}, {"content": "The fastest animal on land is the cheetah. This incredible creature can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts covering distances of about 1,500 feet (460 meters). Cheetahs have several adaptations that contribute to their incredible speed, including a lean body, long legs, and a unique, flexible spine. They also have large lungs for efficient oxygen intake during high-speed chases.", "role": "assistant", "defsite": "text.1.repeat.1.text.0.model"}, {"role": "user", "content": "no", "defsite": "text.1.repeat.0.text.1.read"}, {"role": "user", "content": "\n", "defsite": "text.1.repeat.0.text.2"}, {"role": "user", "content": "in europe?", "defsite": "text.1.repeat.0.text.3.if.0.text.0.read"}], "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "pdl__result": "In Europe, the fastest land animal is still the cheetah, as it does not inhabit this continent naturally due to its preference for open savannas and grasslands. However, if we consider European hares (Lepus europaeus), they are the fastest terrestrial mammals native to Europe. Hares can reach speeds of up to 50 kilometers per hour (31 miles per hour) in short bursts over distances of about 200-400 meters, thanks to their powerful hind legs and long, muscular bodies.\n\nFor aquatic animals, the European sturgeon is one of the fastest, reaching speeds up to 35 kilometers per hour (22 miles per hour) in short bursts while swimming. This species is known for its long, powerful body and large, flat head, which helps it navigate through water efficiently.\n\nIn summary, cheetahs are the fastest land animals globally, but if we limit our discussion to Europe, hares become the fastest terrestrial mammals, while European sturgeons hold the title for the fastest aquatic animal in this region.", "pdl__timing": {"start_nanos": 1741197527671318000, "end_nanos": 1741197530912277000, "timezone": "EST"}}, {"kind": "read", "pdl__id": "text.1.repeat.1.text.1.read", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "pdl__result": "yes", "pdl__timing": {"start_nanos": 1741197530912314000, "end_nanos": 1741197530912531000, "timezone": "EST"}}, {"kind": "data", "pdl__id": "text.1.repeat.1.text.2", "defs": {}, "data": "\n", "pdl__result": "\n", "pdl__timing": {"start_nanos": 1741197530912550000, "end_nanos": 1741197530912891000, "timezone": "EST"}}, {"kind": "if", "pdl__id": "text.1.repeat.1.text.3.if", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "pdl__id": "text.1.repeat.0.text.3.if.0.text", "defs": {}, "text": [{"kind": "read", "pdl__id": "text.1.repeat.0.text.3.if.0.text.0.read", "defs": {}, "read": null, "message": "Why not?\n", "multiline": false, "pdl__timing": {"start_nanos": 1741197527670646000, "end_nanos": 1741197527670725000, "timezone": "EST"}}], "pdl__timing": {"start_nanos": 1741197527670596000, "end_nanos": 1741197527670750000, "timezone": "EST"}}, "if_result": false, "pdl__result": "", "pdl__timing": {"start_nanos": 1741197530913011000, "end_nanos": 1741197530913545000, "timezone": "EST"}}], "pdl__result": "In Europe, the fastest land animal is still the cheetah, as it does not inhabit this continent naturally due to its preference for open savannas and grasslands. However, if we consider European hares (Lepus europaeus), they are the fastest terrestrial mammals native to Europe. Hares can reach speeds of up to 50 kilometers per hour (31 miles per hour) in short bursts over distances of about 200-400 meters, thanks to their powerful hind legs and long, muscular bodies.\n\nFor aquatic animals, the European sturgeon is one of the fastest, reaching speeds up to 35 kilometers per hour (22 miles per hour) in short bursts while swimming. This species is known for its long, powerful body and large, flat head, which helps it navigate through water efficiently.\n\nIn summary, cheetahs are the fastest land animals globally, but if we limit our discussion to Europe, hares become the fastest terrestrial mammals, while European sturgeons hold the title for the fastest aquatic animal in this region.yes\n", "pdl__timing": {"start_nanos": 1741197527671283000, "end_nanos": 1741197530913573000, "timezone": "EST"}}], "pdl__result": "The fastest animal on land is the cheetah. This incredible creature can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts covering distances of about 1,500 feet (460 meters). Cheetahs have several adaptations that contribute to their incredible speed, including a lean body, long legs, and a unique, flexible spine. They also have large lungs for efficient oxygen intake during high-speed chases.no\nin europe?In Europe, the fastest land animal is still the cheetah, as it does not inhabit this continent naturally due to its preference for open savannas and grasslands. However, if we consider European hares (Lepus europaeus), they are the fastest terrestrial mammals native to Europe. Hares can reach speeds of up to 50 kilometers per hour (31 miles per hour) in short bursts over distances of about 200-400 meters, thanks to their powerful hind legs and long, muscular bodies.\n\nFor aquatic animals, the European sturgeon is one of the fastest, reaching speeds up to 35 kilometers per hour (22 miles per hour) in short bursts while swimming. This species is known for its long, powerful body and large, flat head, which helps it navigate through water efficiently.\n\nIn summary, cheetahs are the fastest land animals globally, but if we limit our discussion to Europe, hares become the fastest terrestrial mammals, while European sturgeons hold the title for the fastest aquatic animal in this region.yes\n", "pdl__timing": {"start_nanos": 1741197524724995000, "end_nanos": 1741197530914219000, "timezone": "EST"}}], "pdl__result": "what is the fastest animal?The fastest animal on land is the cheetah. This incredible creature can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts covering distances of about 1,500 feet (460 meters). Cheetahs have several adaptations that contribute to their incredible speed, including a lean body, long legs, and a unique, flexible spine. They also have large lungs for efficient oxygen intake during high-speed chases.no\nin europe?In Europe, the fastest land animal is still the cheetah, as it does not inhabit this continent naturally due to its preference for open savannas and grasslands. However, if we consider European hares (Lepus europaeus), they are the fastest terrestrial mammals native to Europe. Hares can reach speeds of up to 50 kilometers per hour (31 miles per hour) in short bursts over distances of about 200-400 meters, thanks to their powerful hind legs and long, muscular bodies.\n\nFor aquatic animals, the European sturgeon is one of the fastest, reaching speeds up to 35 kilometers per hour (22 miles per hour) in short bursts while swimming. This species is known for its long, powerful body and large, flat head, which helps it navigate through water efficiently.\n\nIn summary, cheetahs are the fastest land animals globally, but if we limit our discussion to Europe, hares become the fastest terrestrial mammals, while European sturgeons hold the title for the fastest aquatic animal in this region.yes\n", "pdl__timing": {"start_nanos": 1741197524724823000, "end_nanos": 1741197530914303000, "timezone": "EST"}} +{"kind": "text", "id": "text", "pdl__timing": {"start_nanos": 1741203526624735000, "end_nanos": 1741203532241004000, "timezone": "EST"}, "description": "Chatbot", "defs": {}, "text": [{"kind": "read", "id": "text.0.read", "pdl__timing": {"start_nanos": 1741203526624779000, "end_nanos": 1741203526624938000, "timezone": "EST"}, "defs": {}, "read": null, "message": "What is your query?\n", "multiline": false, "result": "what is the fastest animal?"}, {"kind": "repeat", "id": "text.1.repeat", "pdl__timing": {"start_nanos": 1741203526624963000, "end_nanos": 1741203532240976000, "timezone": "EST"}, "defs": {}, "for": null, "while": true, "repeat": {"kind": "text", "id": "text.1.repeat.1.text", "pdl__timing": {"start_nanos": 1741203528619635000, "end_nanos": 1741203532240612000, "timezone": "EST"}, "defs": {}, "text": [{"kind": "model", "id": "text.1.repeat.1.text.0.model", "pdl__timing": {"start_nanos": 1741203528619668000, "end_nanos": 1741203532239568000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b"}, {"kind": "read", "id": "text.1.repeat.1.text.1.read", "pdl__timing": {"start_nanos": 1741203532239609000, "end_nanos": 1741203532239719000, "timezone": "EST"}, "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval"}, "\n", {"kind": "if", "id": "text.1.repeat.1.text.3.if", "pdl__timing": {"start_nanos": 1741203532240139000, "end_nanos": 1741203532240588000, "timezone": "EST"}, "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "id": "text.1.repeat.0.text.3.if.0.text", "pdl__timing": {"start_nanos": 1741203528618991000, "end_nanos": 1741203528619184000, "timezone": "EST"}, "defs": {}, "text": [{"kind": "read", "id": "text.1.repeat.0.text.3.if.0.text.0.read", "pdl__timing": {"start_nanos": 1741203528619051000, "end_nanos": 1741203528619160000, "timezone": "EST"}, "defs": {}, "read": null, "message": "Why not?\n", "multiline": false}]}}]}, "until": "${ eval == 'yes'}", "max_iterations": null, "join": {"with": ""}, "trace": [{"kind": "text", "id": "text.1.repeat.0.text", "pdl__timing": {"start_nanos": 1741203526624999000, "end_nanos": 1741203528619218000, "timezone": "EST"}, "defs": {}, "text": [{"kind": "model", "id": "text.1.repeat.0.text.0.model", "context": [{"role": "user", "content": "what is the fastest animal?", "defsite": "text.0.read"}], "pdl__timing": {"start_nanos": 1741203526625027000, "end_nanos": 1741203528560496000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "result": "The fastest land animal is the cheetah. It can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts, reaching its top speed within approximately 3 seconds. Cheetahs are known for their exceptional acceleration capabilities and long, powerful legs designed specifically for hunting prey over long distances."}, {"kind": "read", "id": "text.1.repeat.0.text.1.read", "pdl__timing": {"start_nanos": 1741203528560543000, "end_nanos": 1741203528560717000, "timezone": "EST"}, "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "result": "no"}, {"kind": "data", "id": "text.1.repeat.0.text.2", "pdl__timing": {"start_nanos": 1741203528560736000, "end_nanos": 1741203528561153000, "timezone": "EST"}, "defs": {}, "data": "\n", "result": "\n"}, {"kind": "if", "id": "text.1.repeat.0.text.3.if", "pdl__timing": {"start_nanos": 1741203528618315000, "end_nanos": 1741203528619201000, "timezone": "EST"}, "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "id": "text.1.repeat.0.text.3.if.0.text", "pdl__timing": {"start_nanos": 1741203528618991000, "end_nanos": 1741203528619184000, "timezone": "EST"}, "defs": {}, "text": [{"kind": "read", "id": "text.1.repeat.0.text.3.if.0.text.0.read", "pdl__timing": {"start_nanos": 1741203528619051000, "end_nanos": 1741203528619160000, "timezone": "EST"}, "defs": {}, "read": null, "message": "Why not?\n", "multiline": false, "result": "in europe?"}], "result": "in europe?"}, "if_result": true, "result": "in europe?"}], "result": "The fastest land animal is the cheetah. It can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts, reaching its top speed within approximately 3 seconds. Cheetahs are known for their exceptional acceleration capabilities and long, powerful legs designed specifically for hunting prey over long distances.no\nin europe?"}, {"kind": "text", "id": "text.1.repeat.1.text", "pdl__timing": {"start_nanos": 1741203528619635000, "end_nanos": 1741203532240612000, "timezone": "EST"}, "defs": {}, "text": [{"kind": "model", "id": "text.1.repeat.1.text.0.model", "context": [{"role": "user", "content": "what is the fastest animal?", "defsite": "text.0.read"}, {"content": "The fastest land animal is the cheetah. It can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts, reaching its top speed within approximately 3 seconds. Cheetahs are known for their exceptional acceleration capabilities and long, powerful legs designed specifically for hunting prey over long distances.", "role": "assistant", "defsite": "text.1.repeat.1.text.0.model"}, {"role": "user", "content": "no", "defsite": "text.1.repeat.0.text.1.read"}, {"role": "user", "content": "\n", "defsite": "text.1.repeat.0.text.2"}, {"role": "user", "content": "in europe?", "defsite": "text.1.repeat.0.text.3.if.0.text.0.read"}], "pdl__timing": {"start_nanos": 1741203528619668000, "end_nanos": 1741203532239568000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "result": "In terms of the fastest land animal found in Europe, it's the pronghorn (Antilocapra americana), not a cheetah. The pronghorn is native to North America but has also established populations in parts of Europe, such as England and Germany. It boasts an impressive top speed of up to 60 miles per hour (97 kilometers per hour) and has several adaptations that aid its exceptional speed, including a unique hump on its back for energy storage and efficient lung capacity to oxygenate muscles during high-speed chases.\n\nWhile cheetahs are not native to Europe, they can be found in certain countries like Portugal due to human intervention through captive breeding programs. However, if you're asking about the fastest European animal on land without considering exotic introductions, the pronghorn is indeed the winner."}, {"kind": "read", "id": "text.1.repeat.1.text.1.read", "pdl__timing": {"start_nanos": 1741203532239609000, "end_nanos": 1741203532239719000, "timezone": "EST"}, "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "result": "yes"}, {"kind": "data", "id": "text.1.repeat.1.text.2", "pdl__timing": {"start_nanos": 1741203532239731000, "end_nanos": 1741203532240053000, "timezone": "EST"}, "defs": {}, "data": "\n", "result": "\n"}, {"kind": "if", "id": "text.1.repeat.1.text.3.if", "pdl__timing": {"start_nanos": 1741203532240139000, "end_nanos": 1741203532240588000, "timezone": "EST"}, "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "id": "text.1.repeat.0.text.3.if.0.text", "pdl__timing": {"start_nanos": 1741203528618991000, "end_nanos": 1741203528619184000, "timezone": "EST"}, "defs": {}, "text": [{"kind": "read", "id": "text.1.repeat.0.text.3.if.0.text.0.read", "pdl__timing": {"start_nanos": 1741203528619051000, "end_nanos": 1741203528619160000, "timezone": "EST"}, "defs": {}, "read": null, "message": "Why not?\n", "multiline": false}]}, "if_result": false, "result": ""}], "result": "In terms of the fastest land animal found in Europe, it's the pronghorn (Antilocapra americana), not a cheetah. The pronghorn is native to North America but has also established populations in parts of Europe, such as England and Germany. It boasts an impressive top speed of up to 60 miles per hour (97 kilometers per hour) and has several adaptations that aid its exceptional speed, including a unique hump on its back for energy storage and efficient lung capacity to oxygenate muscles during high-speed chases.\n\nWhile cheetahs are not native to Europe, they can be found in certain countries like Portugal due to human intervention through captive breeding programs. However, if you're asking about the fastest European animal on land without considering exotic introductions, the pronghorn is indeed the winner.yes\n"}], "result": "The fastest land animal is the cheetah. It can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts, reaching its top speed within approximately 3 seconds. Cheetahs are known for their exceptional acceleration capabilities and long, powerful legs designed specifically for hunting prey over long distances.no\nin europe?In terms of the fastest land animal found in Europe, it's the pronghorn (Antilocapra americana), not a cheetah. The pronghorn is native to North America but has also established populations in parts of Europe, such as England and Germany. It boasts an impressive top speed of up to 60 miles per hour (97 kilometers per hour) and has several adaptations that aid its exceptional speed, including a unique hump on its back for energy storage and efficient lung capacity to oxygenate muscles during high-speed chases.\n\nWhile cheetahs are not native to Europe, they can be found in certain countries like Portugal due to human intervention through captive breeding programs. However, if you're asking about the fastest European animal on land without considering exotic introductions, the pronghorn is indeed the winner.yes\n"}], "result": "what is the fastest animal?The fastest land animal is the cheetah. It can reach speeds up to 60-70 miles per hour (97-113 kilometers per hour) in short bursts, reaching its top speed within approximately 3 seconds. Cheetahs are known for their exceptional acceleration capabilities and long, powerful legs designed specifically for hunting prey over long distances.no\nin europe?In terms of the fastest land animal found in Europe, it's the pronghorn (Antilocapra americana), not a cheetah. The pronghorn is native to North America but has also established populations in parts of Europe, such as England and Germany. It boasts an impressive top speed of up to 60 miles per hour (97 kilometers per hour) and has several adaptations that aid its exceptional speed, including a unique hump on its back for energy storage and efficient lung capacity to oxygenate muscles during high-speed chases.\n\nWhile cheetahs are not native to Europe, they can be found in certain countries like Portugal due to human intervention through captive breeding programs. However, if you're asking about the fastest European animal on land without considering exotic introductions, the pronghorn is indeed the winner.yes\n"} \ No newline at end of file diff --git a/pdl-live-react/src/demos/demo5.json b/pdl-live-react/src/demos/demo5.json index e97ed093f..f33d43241 100644 --- a/pdl-live-react/src/demos/demo5.json +++ b/pdl-live-react/src/demos/demo5.json @@ -1 +1 @@ -{"kind": "text", "pdl__id": "text", "pdl__timing": {"start_nanos": 1741032889390332000, "end_nanos": 1741032973975943000, "timezone": "EST"}, "description": "Code explanation example", "defs": {"CODE": {"kind": "read", "pdl__id": "text.0.read", "pdl__timing": {"start_nanos": 1741032889390466000, "end_nanos": 1741032889393693000, "timezone": "EST"}, "defs": {}, "read": "./data.yaml", "message": null, "multiline": false, "pdl__result": "source_code: \n |\n @SuppressWarnings(\"unchecked\")\n public 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 }\nrepo_info: \n repo: streamsets/datacollector\n path: stagesupport/src/main/java/com/.../OffsetUtil.java\n function_name: OffsetUtil.deserializeOffsetMap", "parser": "yaml"}, "TRUTH": {"kind": "read", "pdl__id": "text.1.read", "pdl__timing": {"start_nanos": 1741032889393821000, "end_nanos": 1741032889394735000, "timezone": "EST"}, "defs": {}, "read": "./ground_truth.txt", "message": null, "multiline": false, "pdl__result": "The function `deserializeOffsetMap` takes a string as input and returns a map. It first checks if the input string is null or empty. If it is, it creates a new empty map and returns it. Otherwise, it uses the Jackson library to parse the input string into a map and returns it.\n\nThe `@SuppressWarnings(\"unchecked\")` annotation is used to suppress the warning that the type of the parsed map is not checked. This is because the Jackson library is used to parse the input string into a map, but the specific type of the map is not known at compile time. Therefore, the warning is suppressed to avoid potential issues."}}, "text": [{"kind": "model", "pdl__id": "text.0.model", "pdl__timing": {"start_nanos": 1741032889394959000, "end_nanos": 1741032972726744000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "input": "Here is some info about the location of the function in the repo.\nrepo:\n${ CODE.repo_info.repo }\npath: ${ CODE.repo_info.path }\nFunction_name: ${ CODE.repo_info.function_name }\n\n\nExplain the following code:\n```\n${ CODE.source_code }```\n", "parameters": {"temperature": 0.0}, "def": "EXPLANATION", "contribute": [], "pdl__result": "**Code Explanation: `deserializeOffsetMap` Method**\n\nThe `deserializeOffsetMap` method is a static utility function located in the `OffsetUtil` class. It deserializes a string representation of an offset map into a Java `Map` object.\n\n### Purpose\nThe purpose of this method is to take a string containing a serialized offset map and convert it back into a usable `Map` object, which can be used to store key-value pairs representing offsets.\n\n### Parameters\n\n* `lastSourceOffset`: A string representation of the offset map to be deserialized. This parameter is optional (can be null or empty).\n\n### Return Value\nThe method returns a `Map` containing the deserialized offset map.\n\n### Code Breakdown\n\n1. **Null/Empty Check**: The method first checks if the input `lastSourceOffset` string is null or empty. If so, it creates an empty `HashMap` to return.\n2. **Deserialization**: If the input string is not null or empty, it uses a JSON deserializer (`JSON_MAPPER`) to convert the string into a `Map` object. The `readValue` method of the JSON mapper takes two parameters: the input string and the target class type (in this case, `Map.class`). This will deserialize the string into a `HashMap`.\n3. **Return**: Finally, the deserialized offset map is returned as a `Map`.\n\n### Notes\n\n* The `@SuppressWarnings(\"unchecked\")` annotation suppresses an unchecked cast warning that would otherwise be generated by the Java compiler.\n* The `JSON_MAPPER` object is assumed to be a Jackson JSON mapper instance, which is used for serializing and deserializing JSON data in Java."}, {"kind": "code", "pdl__id": "text.1.code", "pdl__timing": {"start_nanos": 1741032972726901000, "end_nanos": 1741032973971484000, "timezone": "EST"}, "defs": {}, "lang": "python", "code": {"kind": "data", "pdl__id": "text.1.code", "pdl__timing": {"start_nanos": 1741032972726994000, "end_nanos": 1741032972728770000, "timezone": "EST"}, "defs": {}, "data": "import textdistance\nexpl = \"\"\"\n${ EXPLANATION }\n\"\"\"\ntruth = \"\"\"\n${ TRUTH }\n\"\"\"\n# (In PDL, set `result` to the output you wish for your code block.)\nresult = textdistance.levenshtein.normalized_similarity(expl, truth)\n", "pdl__result": "import textdistance\nexpl = \"\"\"\n**Code Explanation: `deserializeOffsetMap` Method**\n\nThe `deserializeOffsetMap` method is a static utility function located in the `OffsetUtil` class. It deserializes a string representation of an offset map into a Java `Map` object.\n\n### Purpose\nThe purpose of this method is to take a string containing a serialized offset map and convert it back into a usable `Map` object, which can be used to store key-value pairs representing offsets.\n\n### Parameters\n\n* `lastSourceOffset`: A string representation of the offset map to be deserialized. This parameter is optional (can be null or empty).\n\n### Return Value\nThe method returns a `Map` containing the deserialized offset map.\n\n### Code Breakdown\n\n1. **Null/Empty Check**: The method first checks if the input `lastSourceOffset` string is null or empty. If so, it creates an empty `HashMap` to return.\n2. **Deserialization**: If the input string is not null or empty, it uses a JSON deserializer (`JSON_MAPPER`) to convert the string into a `Map` object. The `readValue` method of the JSON mapper takes two parameters: the input string and the target class type (in this case, `Map.class`). This will deserialize the string into a `HashMap`.\n3. **Return**: Finally, the deserialized offset map is returned as a `Map`.\n\n### Notes\n\n* The `@SuppressWarnings(\"unchecked\")` annotation suppresses an unchecked cast warning that would otherwise be generated by the Java compiler.\n* The `JSON_MAPPER` object is assumed to be a Jackson JSON mapper instance, which is used for serializing and deserializing JSON data in Java.\n\"\"\"\ntruth = \"\"\"\nThe function `deserializeOffsetMap` takes a string as input and returns a map. It first checks if the input string is null or empty. If it is, it creates a new empty map and returns it. Otherwise, it uses the Jackson library to parse the input string into a map and returns it.\n\nThe `@SuppressWarnings(\"unchecked\")` annotation is used to suppress the warning that the type of the parsed map is not checked. This is because the Jackson library is used to parse the input string into a map, but the specific type of the map is not known at compile time. Therefore, the warning is suppressed to avoid potential issues.\n\"\"\"\n# (In PDL, set `result` to the output you wish for your code block.)\nresult = textdistance.levenshtein.normalized_similarity(expl, truth)\n"}, "def": "EVAL", "contribute": [], "pdl__result": 0.24047470331043097}, {"kind": "data", "pdl__id": "text.2.data", "pdl__timing": {"start_nanos": 1741032973971679000, "end_nanos": 1741032973975821000, "timezone": "EST"}, "defs": {}, "data": {"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": "**Code Explanation: `deserializeOffsetMap` Method**\n\nThe `deserializeOffsetMap` method is a static utility function located in the `OffsetUtil` class. It deserializes a string representation of an offset map into a Java `Map` object.\n\n### Purpose\nThe purpose of this method is to take a string containing a serialized offset map and convert it back into a usable `Map` object, which can be used to store key-value pairs representing offsets.\n\n### Parameters\n\n* `lastSourceOffset`: A string representation of the offset map to be deserialized. This parameter is optional (can be null or empty).\n\n### Return Value\nThe method returns a `Map` containing the deserialized offset map.\n\n### Code Breakdown\n\n1. **Null/Empty Check**: The method first checks if the input `lastSourceOffset` string is null or empty. If so, it creates an empty `HashMap` to return.\n2. **Deserialization**: If the input string is not null or empty, it uses a JSON deserializer (`JSON_MAPPER`) to convert the string into a `Map` object. The `readValue` method of the JSON mapper takes two parameters: the input string and the target class type (in this case, `Map.class`). This will deserialize the string into a `HashMap`.\n3. **Return**: Finally, the deserialized offset map is returned as a `Map`.\n\n### Notes\n\n* The `@SuppressWarnings(\"unchecked\")` annotation suppresses an unchecked cast warning that would otherwise be generated by the Java compiler.\n* The `JSON_MAPPER` object is assumed to be a Jackson JSON mapper instance, which is used for serializing and deserializing JSON data in Java.", "metric": 0.24047470331043097}, "pdl__result": {"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": "**Code Explanation: `deserializeOffsetMap` Method**\n\nThe `deserializeOffsetMap` method is a static utility function located in the `OffsetUtil` class. It deserializes a string representation of an offset map into a Java `Map` object.\n\n### Purpose\nThe purpose of this method is to take a string containing a serialized offset map and convert it back into a usable `Map` object, which can be used to store key-value pairs representing offsets.\n\n### Parameters\n\n* `lastSourceOffset`: A string representation of the offset map to be deserialized. This parameter is optional (can be null or empty).\n\n### Return Value\nThe method returns a `Map` containing the deserialized offset map.\n\n### Code Breakdown\n\n1. **Null/Empty Check**: The method first checks if the input `lastSourceOffset` string is null or empty. If so, it creates an empty `HashMap` to return.\n2. **Deserialization**: If the input string is not null or empty, it uses a JSON deserializer (`JSON_MAPPER`) to convert the string into a `Map` object. The `readValue` method of the JSON mapper takes two parameters: the input string and the target class type (in this case, `Map.class`). This will deserialize the string into a `HashMap`.\n3. **Return**: Finally, the deserialized offset map is returned as a `Map`.\n\n### Notes\n\n* The `@SuppressWarnings(\"unchecked\")` annotation suppresses an unchecked cast warning that would otherwise be generated by the Java compiler.\n* The `JSON_MAPPER` object is assumed to be a Jackson JSON mapper instance, which is used for serializing and deserializing JSON data in Java.", "metric": 0.24047470331043097}}], "pdl__result": "{\"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\": \"**Code Explanation: `deserializeOffsetMap` Method**\\n\\nThe `deserializeOffsetMap` method is a static utility function located in the `OffsetUtil` class. It deserializes a string representation of an offset map into a Java `Map` object.\\n\\n### Purpose\\nThe purpose of this method is to take a string containing a serialized offset map and convert it back into a usable `Map` object, which can be used to store key-value pairs representing offsets.\\n\\n### Parameters\\n\\n* `lastSourceOffset`: A string representation of the offset map to be deserialized. This parameter is optional (can be null or empty).\\n\\n### Return Value\\nThe method returns a `Map` containing the deserialized offset map.\\n\\n### Code Breakdown\\n\\n1. **Null/Empty Check**: The method first checks if the input `lastSourceOffset` string is null or empty. If so, it creates an empty `HashMap` to return.\\n2. **Deserialization**: If the input string is not null or empty, it uses a JSON deserializer (`JSON_MAPPER`) to convert the string into a `Map` object. The `readValue` method of the JSON mapper takes two parameters: the input string and the target class type (in this case, `Map.class`). This will deserialize the string into a `HashMap`.\\n3. **Return**: Finally, the deserialized offset map is returned as a `Map`.\\n\\n### Notes\\n\\n* The `@SuppressWarnings(\\\"unchecked\\\")` annotation suppresses an unchecked cast warning that would otherwise be generated by the Java compiler.\\n* The `JSON_MAPPER` object is assumed to be a Jackson JSON mapper instance, which is used for serializing and deserializing JSON data in Java.\", \"metric\": 0.24047470331043097}"} \ No newline at end of file +{"kind": "text", "id": "text", "pdl__timing": {"start_nanos": 1741203533525149000, "end_nanos": 1741203540479332000, "timezone": "EST"}, "description": "Code explanation example", "defs": {"CODE": {"kind": "read", "id": "text.0.read", "pdl__timing": {"start_nanos": 1741203533525174000, "end_nanos": 1741203533525951000, "timezone": "EST"}, "defs": {}, "read": "./data.yaml", "message": null, "multiline": false, "result": "source_code: \n |\n @SuppressWarnings(\"unchecked\")\n public 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 }\nrepo_info: \n repo: streamsets/datacollector\n path: stagesupport/src/main/java/com/.../OffsetUtil.java\n function_name: OffsetUtil.deserializeOffsetMap", "parser": "yaml"}, "TRUTH": {"kind": "read", "id": "text.1.read", "pdl__timing": {"start_nanos": 1741203533525980000, "end_nanos": 1741203533529896000, "timezone": "EST"}, "defs": {}, "read": "./ground_truth.txt", "message": null, "multiline": false, "result": "The function `deserializeOffsetMap` takes a string as input and returns a map. It first checks if the input string is null or empty. If it is, it creates a new empty map and returns it. Otherwise, it uses the Jackson library to parse the input string into a map and returns it.\n\nThe `@SuppressWarnings(\"unchecked\")` annotation is used to suppress the warning that the type of the parsed map is not checked. This is because the Jackson library is used to parse the input string into a map, but the specific type of the map is not known at compile time. Therefore, the warning is suppressed to avoid potential issues."}}, "text": [{"kind": "model", "id": "text.0.model", "pdl__timing": {"start_nanos": 1741203533529943000, "end_nanos": 1741203539875125000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "input": "Here is some info about the location of the function in the repo.\nrepo:\n${ CODE.repo_info.repo }\npath: ${ CODE.repo_info.path }\nFunction_name: ${ CODE.repo_info.function_name }\n\n\nExplain the following code:\n```\n${ CODE.source_code }```\n", "parameters": {"temperature": 0.0}, "def": "EXPLANATION", "contribute": [], "result": "The provided Java function `deserializeOffsetMap` is part of the StreamSets Data Collector (streamsets/datacollector) repository, specifically located in the `stagesupport` package under `com.../OffsetUtil.java`. This function aims to deserialize a JSON string into a `Map` object, which represents an offset map containing key-value pairs of strings.\n\nHere's a breakdown of the code:\n\n1. `@SuppressWarnings(\"unchecked\")`: This annotation is used to suppress potential warnings related to unchecked or raw type usage. In this case, it indicates that the developer knows the type is safe and doesn't want to see warnings about it.\n\n2. `public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException`: This line defines a public static method named `deserializeOffsetMap` in the OffsetUtil class. It takes one parameter:\n - `lastSourceOffset`: A string representing a JSON offset map.\n\n3. The function begins with an if-else statement to handle two possible scenarios for `lastSourceOffset`:\n\n a. If `lastSourceOffset` is null or empty (`lastSourceOffset == null || lastSourceOffset.isEmpty()`), the method initializes and returns a new HashMap called `offsetMap`. This indicates that no offset map was provided, so an empty one will be created.\n \n b. Otherwise, if `lastSourceOffset` contains valid JSON data:\n - The function uses `JSON_MAPPER`, presumably a Jackson ObjectMapper instance, to deserialize the input string (`lastSourceOffset`) into a Map of type `Map.class`. This means it converts the JSON string into a HashMap.\n\n4. Finally, the method returns the deserialized `offsetMap` (either an empty one or the JSON-parsed map).\n\nIn summary, this function serves to safely convert a JSON offset map string into a Java Map object. If no valid JSON data is provided as input, it creates and returns an empty HashMap; otherwise, it parses the given JSON string into a Map using Jackson's ObjectMapper."}, {"kind": "code", "id": "text.1.code", "pdl__timing": {"start_nanos": 1741203539875175000, "end_nanos": 1741203540477839000, "timezone": "EST"}, "defs": {}, "lang": "python", "code": {"kind": "data", "id": "text.1.code", "pdl__timing": {"start_nanos": 1741203539875198000, "end_nanos": 1741203539875827000, "timezone": "EST"}, "defs": {}, "data": "import textdistance\nexpl = \"\"\"\n${ EXPLANATION }\n\"\"\"\ntruth = \"\"\"\n${ TRUTH }\n\"\"\"\n# (In PDL, set `result` to the output you wish for your code block.)\nresult = textdistance.levenshtein.normalized_similarity(expl, truth)\n", "result": "import textdistance\nexpl = \"\"\"\nThe provided Java function `deserializeOffsetMap` is part of the StreamSets Data Collector (streamsets/datacollector) repository, specifically located in the `stagesupport` package under `com.../OffsetUtil.java`. This function aims to deserialize a JSON string into a `Map` object, which represents an offset map containing key-value pairs of strings.\n\nHere's a breakdown of the code:\n\n1. `@SuppressWarnings(\"unchecked\")`: This annotation is used to suppress potential warnings related to unchecked or raw type usage. In this case, it indicates that the developer knows the type is safe and doesn't want to see warnings about it.\n\n2. `public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException`: This line defines a public static method named `deserializeOffsetMap` in the OffsetUtil class. It takes one parameter:\n - `lastSourceOffset`: A string representing a JSON offset map.\n\n3. The function begins with an if-else statement to handle two possible scenarios for `lastSourceOffset`:\n\n a. If `lastSourceOffset` is null or empty (`lastSourceOffset == null || lastSourceOffset.isEmpty()`), the method initializes and returns a new HashMap called `offsetMap`. This indicates that no offset map was provided, so an empty one will be created.\n \n b. Otherwise, if `lastSourceOffset` contains valid JSON data:\n - The function uses `JSON_MAPPER`, presumably a Jackson ObjectMapper instance, to deserialize the input string (`lastSourceOffset`) into a Map of type `Map.class`. This means it converts the JSON string into a HashMap.\n\n4. Finally, the method returns the deserialized `offsetMap` (either an empty one or the JSON-parsed map).\n\nIn summary, this function serves to safely convert a JSON offset map string into a Java Map object. If no valid JSON data is provided as input, it creates and returns an empty HashMap; otherwise, it parses the given JSON string into a Map using Jackson's ObjectMapper.\n\"\"\"\ntruth = \"\"\"\nThe function `deserializeOffsetMap` takes a string as input and returns a map. It first checks if the input string is null or empty. If it is, it creates a new empty map and returns it. Otherwise, it uses the Jackson library to parse the input string into a map and returns it.\n\nThe `@SuppressWarnings(\"unchecked\")` annotation is used to suppress the warning that the type of the parsed map is not checked. This is because the Jackson library is used to parse the input string into a map, but the specific type of the map is not known at compile time. Therefore, the warning is suppressed to avoid potential issues.\n\"\"\"\n# (In PDL, set `result` to the output you wish for your code block.)\nresult = textdistance.levenshtein.normalized_similarity(expl, truth)\n"}, "def": "EVAL", "contribute": [], "result": 0.2208249496981891}, {"kind": "data", "id": "text.2.data", "pdl__timing": {"start_nanos": 1741203540477894000, "end_nanos": 1741203540479296000, "timezone": "EST"}, "defs": {}, "data": {"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": "The provided Java function `deserializeOffsetMap` is part of the StreamSets Data Collector (streamsets/datacollector) repository, specifically located in the `stagesupport` package under `com.../OffsetUtil.java`. This function aims to deserialize a JSON string into a `Map` object, which represents an offset map containing key-value pairs of strings.\n\nHere's a breakdown of the code:\n\n1. `@SuppressWarnings(\"unchecked\")`: This annotation is used to suppress potential warnings related to unchecked or raw type usage. In this case, it indicates that the developer knows the type is safe and doesn't want to see warnings about it.\n\n2. `public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException`: This line defines a public static method named `deserializeOffsetMap` in the OffsetUtil class. It takes one parameter:\n - `lastSourceOffset`: A string representing a JSON offset map.\n\n3. The function begins with an if-else statement to handle two possible scenarios for `lastSourceOffset`:\n\n a. If `lastSourceOffset` is null or empty (`lastSourceOffset == null || lastSourceOffset.isEmpty()`), the method initializes and returns a new HashMap called `offsetMap`. This indicates that no offset map was provided, so an empty one will be created.\n \n b. Otherwise, if `lastSourceOffset` contains valid JSON data:\n - The function uses `JSON_MAPPER`, presumably a Jackson ObjectMapper instance, to deserialize the input string (`lastSourceOffset`) into a Map of type `Map.class`. This means it converts the JSON string into a HashMap.\n\n4. Finally, the method returns the deserialized `offsetMap` (either an empty one or the JSON-parsed map).\n\nIn summary, this function serves to safely convert a JSON offset map string into a Java Map object. If no valid JSON data is provided as input, it creates and returns an empty HashMap; otherwise, it parses the given JSON string into a Map using Jackson's ObjectMapper.", "metric": 0.2208249496981891}, "result": {"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": "The provided Java function `deserializeOffsetMap` is part of the StreamSets Data Collector (streamsets/datacollector) repository, specifically located in the `stagesupport` package under `com.../OffsetUtil.java`. This function aims to deserialize a JSON string into a `Map` object, which represents an offset map containing key-value pairs of strings.\n\nHere's a breakdown of the code:\n\n1. `@SuppressWarnings(\"unchecked\")`: This annotation is used to suppress potential warnings related to unchecked or raw type usage. In this case, it indicates that the developer knows the type is safe and doesn't want to see warnings about it.\n\n2. `public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException`: This line defines a public static method named `deserializeOffsetMap` in the OffsetUtil class. It takes one parameter:\n - `lastSourceOffset`: A string representing a JSON offset map.\n\n3. The function begins with an if-else statement to handle two possible scenarios for `lastSourceOffset`:\n\n a. If `lastSourceOffset` is null or empty (`lastSourceOffset == null || lastSourceOffset.isEmpty()`), the method initializes and returns a new HashMap called `offsetMap`. This indicates that no offset map was provided, so an empty one will be created.\n \n b. Otherwise, if `lastSourceOffset` contains valid JSON data:\n - The function uses `JSON_MAPPER`, presumably a Jackson ObjectMapper instance, to deserialize the input string (`lastSourceOffset`) into a Map of type `Map.class`. This means it converts the JSON string into a HashMap.\n\n4. Finally, the method returns the deserialized `offsetMap` (either an empty one or the JSON-parsed map).\n\nIn summary, this function serves to safely convert a JSON offset map string into a Java Map object. If no valid JSON data is provided as input, it creates and returns an empty HashMap; otherwise, it parses the given JSON string into a Map using Jackson's ObjectMapper.", "metric": 0.2208249496981891}}], "result": "{\"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\": \"The provided Java function `deserializeOffsetMap` is part of the StreamSets Data Collector (streamsets/datacollector) repository, specifically located in the `stagesupport` package under `com.../OffsetUtil.java`. This function aims to deserialize a JSON string into a `Map` object, which represents an offset map containing key-value pairs of strings.\\n\\nHere's a breakdown of the code:\\n\\n1. `@SuppressWarnings(\\\"unchecked\\\")`: This annotation is used to suppress potential warnings related to unchecked or raw type usage. In this case, it indicates that the developer knows the type is safe and doesn't want to see warnings about it.\\n\\n2. `public static Map deserializeOffsetMap(String lastSourceOffset) throws IOException`: This line defines a public static method named `deserializeOffsetMap` in the OffsetUtil class. It takes one parameter:\\n - `lastSourceOffset`: A string representing a JSON offset map.\\n\\n3. The function begins with an if-else statement to handle two possible scenarios for `lastSourceOffset`:\\n\\n a. If `lastSourceOffset` is null or empty (`lastSourceOffset == null || lastSourceOffset.isEmpty()`), the method initializes and returns a new HashMap called `offsetMap`. This indicates that no offset map was provided, so an empty one will be created.\\n \\n b. Otherwise, if `lastSourceOffset` contains valid JSON data:\\n - The function uses `JSON_MAPPER`, presumably a Jackson ObjectMapper instance, to deserialize the input string (`lastSourceOffset`) into a Map of type `Map.class`. This means it converts the JSON string into a HashMap.\\n\\n4. Finally, the method returns the deserialized `offsetMap` (either an empty one or the JSON-parsed map).\\n\\nIn summary, this function serves to safely convert a JSON offset map string into a Java Map object. If no valid JSON data is provided as input, it creates and returns an empty HashMap; otherwise, it parses the given JSON string into a Map using Jackson's ObjectMapper.\", \"metric\": 0.2208249496981891}"} \ No newline at end of file diff --git a/pdl-live-react/src/demos/demo6.json b/pdl-live-react/src/demos/demo6.json index 3eda719c8..58dce5472 100644 --- a/pdl-live-react/src/demos/demo6.json +++ b/pdl-live-react/src/demos/demo6.json @@ -1 +1 @@ -{"kind": "text", "pdl__id": "text", "pdl__timing": {"start_nanos": 1741032975976804000, "end_nanos": 0, "timezone": "EST"}, "description": "Creating JSON Data", "defs": {"data": {"kind": "read", "pdl__id": "text.0.read", "pdl__timing": {"start_nanos": 1741032975976938000, "end_nanos": 1741032975979881000, "timezone": "EST"}, "spec": {"questions": ["str"], "answers": ["obj"]}, "defs": {}, "read": "./gen-data.yaml", "message": null, "multiline": false, "pdl__result": "source_code: \n |\n @SuppressWarnings(\"unchecked\")\n public 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 }\nrepo_info: \n repo: streamsets/datacollector\n path: stagesupport/src/main/java/com/.../OffsetUtil.java\n function_name: OffsetUtil.deserializeOffsetMap\n", "parser": "yaml"}}, "text": [{"kind": "model", "pdl__id": "text.0.model", "pdl__timing": {"start_nanos": 1741032975980142000, "end_nanos": 0, "timezone": "EST"}, "spec": {"name": "str", "age": "int"}, "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "input": {"kind": "text", "pdl__id": "text.0.model.text", "pdl__timing": {"start_nanos": 1741032975985105000, "end_nanos": 0, "timezone": "EST"}, "defs": {}, "text": [{"kind": "error", "pdl__id": "", "defs": {}, "program": {"kind": "read", "pdl__id": "text.0.read", "pdl__timing": {"start_nanos": 1741032975976938000, "end_nanos": 1741032975979881000, "timezone": "EST"}, "spec": {"questions": ["str"], "answers": ["obj"]}, "defs": {}, "read": "./gen-data.yaml", "message": null, "multiline": false, "pdl__result": "source_code: \n |\n @SuppressWarnings(\"unchecked\")\n public 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 }\nrepo_info: \n repo: streamsets/datacollector\n path: stagesupport/src/main/java/com/.../OffsetUtil.java\n function_name: OffsetUtil.deserializeOffsetMap\n", "parser": "yaml"}, "msg": "Type errors during spec checking:\n/Users/lmandel/ml4code/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Missing required field: questions\n/Users/lmandel/ml4code/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Missing required field: answers\n/Users/lmandel/ml4code/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Field not allowed: repo_info\n/Users/lmandel/ml4code/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Field not allowed: source_code"}]}, "parameters": {"timeout": null, "temperature": 0.0, "top_p": null, "n": null, "stop": null, "max_tokens": null, "presence_penalty": null, "frequency_penalty": null, "logit_bias": null, "user": null, "response_format": null, "seed": null, "tools": null, "tool_choice": null, "logprobs": null, "top_logprobs": null, "parallel_tool_calls": null, "extra_headers": null, "functions": null, "function_call": null, "base_url": null, "api_version": null, "api_key": null, "model_list": null, "mock_response": null, "custom_llm_provider": null, "max_retries": null, "stop_sequences": "\n"}, "def": "model_output", "parser": "yaml"}]} \ No newline at end of file +{"kind": "text", "id": "text", "pdl__timing": {"start_nanos": 1741203541716935000, "end_nanos": 0, "timezone": "EST"}, "description": "Creating JSON Data", "defs": {"data": {"kind": "read", "id": "text.0.read", "pdl__timing": {"start_nanos": 1741203541716962000, "end_nanos": 1741203541717749000, "timezone": "EST"}, "spec": {"questions": ["str"], "answers": ["obj"]}, "defs": {}, "read": "./gen-data.yaml", "message": null, "multiline": false, "result": "source_code: \n |\n @SuppressWarnings(\"unchecked\")\n public 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 }\nrepo_info: \n repo: streamsets/datacollector\n path: stagesupport/src/main/java/com/.../OffsetUtil.java\n function_name: OffsetUtil.deserializeOffsetMap\n", "parser": "yaml"}}, "text": [{"kind": "model", "id": "text.0.model", "pdl__timing": {"start_nanos": 1741203541717799000, "end_nanos": 0, "timezone": "EST"}, "spec": {"name": "str", "age": "int"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "input": {"kind": "text", "id": "text.0.model.text", "pdl__timing": {"start_nanos": 1741203541718796000, "end_nanos": 0, "timezone": "EST"}, "defs": {}, "text": [{"kind": "error", "id": "", "defs": {}, "program": {"kind": "read", "id": "text.0.read", "pdl__timing": {"start_nanos": 1741203541716962000, "end_nanos": 1741203541717749000, "timezone": "EST"}, "spec": {"questions": ["str"], "answers": ["obj"]}, "defs": {}, "read": "./gen-data.yaml", "message": null, "multiline": false, "result": "source_code: \n |\n @SuppressWarnings(\"unchecked\")\n public 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 }\nrepo_info: \n repo: streamsets/datacollector\n path: stagesupport/src/main/java/com/.../OffsetUtil.java\n function_name: OffsetUtil.deserializeOffsetMap\n", "parser": "yaml"}, "msg": "Type errors during spec checking:\n/Users/jchen/Work/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Missing required field: questions\n/Users/jchen/Work/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Missing required field: answers\n/Users/jchen/Work/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Field not allowed: repo_info\n/Users/jchen/Work/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Field not allowed: source_code"}]}, "parameters": {"timeout": null, "temperature": 0.0, "top_p": null, "n": null, "stop": null, "max_tokens": null, "presence_penalty": null, "frequency_penalty": null, "logit_bias": null, "user": null, "response_format": null, "seed": null, "tools": null, "tool_choice": null, "logprobs": null, "top_logprobs": null, "parallel_tool_calls": null, "extra_headers": null, "functions": null, "function_call": null, "base_url": null, "api_version": null, "api_key": null, "model_list": null, "mock_response": null, "custom_llm_provider": null, "max_retries": null, "stop_sequences": "\n"}, "def": "model_output", "parser": "yaml"}]} \ No newline at end of file diff --git a/pdl-live-react/src/demos/demo7.json b/pdl-live-react/src/demos/demo7.json index 0a33469d4..c30f43b83 100644 --- a/pdl-live-react/src/demos/demo7.json +++ b/pdl-live-react/src/demos/demo7.json @@ -1 +1 @@ -{"kind": "text", "pdl__id": "text", "description": "Function def and call", "defs": {}, "text": [{"kind": "function", "pdl__id": "text.0.function", "defs": {}, "function": {"sentence": "str", "language": "str"}, "return": {"kind": "lastOf", "pdl__id": "text.3.call.lastOf", "defs": {}, "lastOf": ["\nTranslate the sentence '${ sentence }' to ${ language }.\n", {"kind": "model", "pdl__id": "text.3.call.lastOf.model", "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop": ["\n"]}, "pdl__timing": {"start_nanos": 1741191922209505000, "end_nanos": 1741191922404354000, "timezone": "EST"}}], "pdl__timing": {"start_nanos": 1741191922208902000, "end_nanos": 1741191922404413000, "timezone": "EST"}}, "def": "translate", "pdl__result": "description=None spec=None defs={} def_='translate' contribute=[, ] parser=None fallback=None role=None context=[] pdl__id='text.0.function' pdl__result=None pdl__location=PdlLocationType(path=['text', '[0]'], file='/dev/fd/63', table={\"['description']\": 1, \"['text']\": 2, \"['text', '[0]']\": 3, \"['text', '[0]', 'def']\": 3, \"['text', '[0]', 'function']\": 4, \"['text', '[0]', 'function', 'sentence']\": 5, \"['text', '[0]', 'function', 'language']\": 6, \"['text', '[0]', 'return']\": 7, \"['text', '[0]', 'return', 'lastOf']\": 8, \"['text', '[0]', 'return', 'lastOf', '[0]']\": 9, \"['text', '[0]', 'return', 'lastOf', '[1]']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'model']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters']\": 11, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'stop']\": 12, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'temperature']\": 13, \"['text', '[1]']\": 14, \"['text', '[1]', 'call']\": 14, \"['text', '[1]', 'args']\": 15, \"['text', '[1]', 'args', 'sentence']\": 16, \"['text', '[1]', 'args', 'language']\": 17, \"['text', '[2]']\": 18, \"['text', '[3]']\": 19, \"['text', '[3]', 'call']\": 19, \"['text', '[3]', 'args']\": 20, \"['text', '[3]', 'args', 'sentence']\": 21, \"['text', '[3]', 'args', 'language']\": 22}) pdl__timing=PdlTiming(start_nanos=1741191921141899000, end_nanos=1741191921141949000, first_use_nanos=0, timezone='') kind= function={'sentence': 'str', 'language': 'str'} returns=LastOfBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.3.call.lastOf', pdl__result=None, pdl__location=PdlLocationType(path=['text', '[0]', 'return'], file='/dev/fd/63', table={\"['description']\": 1, \"['text']\": 2, \"['text', '[0]']\": 3, \"['text', '[0]', 'def']\": 3, \"['text', '[0]', 'function']\": 4, \"['text', '[0]', 'function', 'sentence']\": 5, \"['text', '[0]', 'function', 'language']\": 6, \"['text', '[0]', 'return']\": 7, \"['text', '[0]', 'return', 'lastOf']\": 8, \"['text', '[0]', 'return', 'lastOf', '[0]']\": 9, \"['text', '[0]', 'return', 'lastOf', '[1]']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'model']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters']\": 11, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'stop']\": 12, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'temperature']\": 13, \"['text', '[1]']\": 14, \"['text', '[1]', 'call']\": 14, \"['text', '[1]', 'args']\": 15, \"['text', '[1]', 'args', 'sentence']\": 16, \"['text', '[1]', 'args', 'language']\": 17, \"['text', '[2]']\": 18, \"['text', '[3]']\": 19, \"['text', '[3]', 'call']\": 19, \"['text', '[3]', 'args']\": 20, \"['text', '[3]', 'args', 'sentence']\": 21, \"['text', '[3]', 'args', 'language']\": 22}), pdl__timing=PdlTiming(start_nanos=1741191922208902000, end_nanos=1741191922404413000, first_use_nanos=0, timezone=''), kind=, lastOf=[\"\\nTranslate the sentence '${ sentence }' to ${ language }.\\n\", LitellmModelBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.3.call.lastOf.model', pdl__result=None, pdl__location=PdlLocationType(path=['text', '[0]', 'return', 'lastOf', '[1]'], file='/dev/fd/63', table={\"['description']\": 1, \"['text']\": 2, \"['text', '[0]']\": 3, \"['text', '[0]', 'def']\": 3, \"['text', '[0]', 'function']\": 4, \"['text', '[0]', 'function', 'sentence']\": 5, \"['text', '[0]', 'function', 'language']\": 6, \"['text', '[0]', 'return']\": 7, \"['text', '[0]', 'return', 'lastOf']\": 8, \"['text', '[0]', 'return', 'lastOf', '[0]']\": 9, \"['text', '[0]', 'return', 'lastOf', '[1]']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'model']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters']\": 11, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'stop']\": 12, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'temperature']\": 13, \"['text', '[1]']\": 14, \"['text', '[1]', 'call']\": 14, \"['text', '[1]', 'args']\": 15, \"['text', '[1]', 'args', 'sentence']\": 16, \"['text', '[1]', 'args', 'language']\": 17, \"['text', '[2]']\": 18, \"['text', '[3]']\": 19, \"['text', '[3]', 'call']\": 19, \"['text', '[3]', 'args']\": 20, \"['text', '[3]', 'args', 'sentence']\": 21, \"['text', '[3]', 'args', 'language']\": 22}), pdl__timing=PdlTiming(start_nanos=1741191922209505000, end_nanos=1741191922404354000, first_use_nanos=0, timezone=''), kind=, model='ollama/llama3.1:8b', input=None, modelResponse=None, pdl__trace=None, platform=, parameters=LitellmParameters(timeout=None, temperature=0.0, top_p=None, n=None, stop=['\\n'], max_tokens=None, presence_penalty=None, frequency_penalty=None, logit_bias=None, user=None, response_format=None, seed=None, tools=None, tool_choice=None, logprobs=None, top_logprobs=None, parallel_tool_calls=None, extra_headers=None, functions=None, function_call=None, base_url=None, api_version=None, api_key=None, model_list=None, mock_response=None, custom_llm_provider=None, max_retries=None))])", "pdl__timing": {"start_nanos": 1741191921141899000, "end_nanos": 1741191921141949000, "timezone": "EST"}}, {"kind": "call", "pdl__id": "text.1.call", "defs": {}, "call": "${ translate }", "args": {"sentence": "I love Paris!", "language": "French"}, "pdl__trace": {"kind": "lastOf", "pdl__id": "text.1.call.lastOf", "defs": {}, "lastOf": [{"kind": "data", "pdl__id": "text.1.call.lastOf", "defs": {}, "data": "\nTranslate the sentence '${ sentence }' to ${ language }.\n", "pdl__result": "\nTranslate the sentence 'I love Paris!' to French.\n", "pdl__timing": {"start_nanos": 1741191921174051000, "end_nanos": 1741191921174571000, "timezone": "EST"}}, {"kind": "model", "pdl__id": "text.1.call.lastOf.model", "context": [{"role": "user", "content": "\nTranslate the sentence 'I love Paris!' to French.\n", "defsite": "text.1.call.lastOf"}], "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop": ["\n"]}, "pdl__result": "### Translator", "pdl__timing": {"start_nanos": 1741191921214591000, "end_nanos": 1741191922206280000, "timezone": "EST"}}], "pdl__result": "### Translator", "pdl__timing": {"start_nanos": 1741191921174007000, "end_nanos": 1741191922206337000, "timezone": "EST"}}, "pdl__result": "### Translator", "pdl__timing": {"start_nanos": 1741191921141971000, "end_nanos": 1741191922206371000, "timezone": "EST"}}, {"kind": "data", "pdl__id": "text.2", "defs": {}, "data": "\n", "pdl__result": "\n", "pdl__timing": {"start_nanos": 1741191922206392000, "end_nanos": 1741191922206766000, "timezone": "EST"}}, {"kind": "call", "pdl__id": "text.3.call", "defs": {}, "call": "${ translate }", "args": {"sentence": "I love Madrid!", "language": "Spanish"}, "pdl__trace": {"kind": "lastOf", "pdl__id": "text.3.call.lastOf", "defs": {}, "lastOf": [{"kind": "data", "pdl__id": "text.3.call.lastOf", "defs": {}, "data": "\nTranslate the sentence '${ sentence }' to ${ language }.\n", "pdl__result": "\nTranslate the sentence 'I love Madrid!' to Spanish.\n", "pdl__timing": {"start_nanos": 1741191922208944000, "end_nanos": 1741191922209453000, "timezone": "EST"}}, {"kind": "model", "pdl__id": "text.3.call.lastOf.model", "context": [{"role": "user", "content": "\nTranslate the sentence 'I love Paris!' to French.\n", "defsite": "text.1.call.lastOf"}, {"content": "### Translator", "role": "assistant", "defsite": "text.3.call.lastOf.model"}, {"role": "user", "content": "\n", "defsite": "text.2"}, {"role": "user", "content": "\nTranslate the sentence 'I love Madrid!' to Spanish.\n", "defsite": "text.3.call.lastOf"}], "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop": ["\n"]}, "pdl__result": "### Translator", "pdl__timing": {"start_nanos": 1741191922209505000, "end_nanos": 1741191922404354000, "timezone": "EST"}}], "pdl__result": "### Translator", "pdl__timing": {"start_nanos": 1741191922208902000, "end_nanos": 1741191922404413000, "timezone": "EST"}}, "pdl__result": "### Translator", "pdl__timing": {"start_nanos": 1741191922207263000, "end_nanos": 1741191922404444000, "timezone": "EST"}}], "pdl__result": "### Translator\n### Translator", "pdl__timing": {"start_nanos": 1741191921141841000, "end_nanos": 1741191922404475000, "timezone": "EST"}} +{"kind": "text", "id": "text", "pdl__timing": {"start_nanos": 1741203542849458000, "end_nanos": 1741203544182692000, "timezone": "EST"}, "description": "Function def and call", "defs": {}, "text": [{"kind": "function", "id": "text.0.function", "pdl__timing": {"start_nanos": 1741203542849503000, "end_nanos": 1741203542849554000, "timezone": "EST"}, "defs": {}, "function": {"sentence": "str", "language": "str"}, "return": {"kind": "lastOf", "id": "text.3.call.lastOf", "pdl__timing": {"start_nanos": 1741203543856103000, "end_nanos": 1741203544182646000, "timezone": "EST"}, "defs": {}, "lastOf": ["\nTranslate the sentence '${ sentence }' to ${ language }.\n", {"kind": "model", "id": "text.3.call.lastOf.model", "pdl__timing": {"start_nanos": 1741203543856980000, "end_nanos": 1741203544182607000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "parameters": {"temperature": 0.0, "stop": ["\n"]}}]}, "def": "translate", "result": "description=None spec=None defs={} assign='translate' contribute=[, ] parser=None fallback=None role=None context=[] id='text.0.function' result=None location=LocationType(path=['text', '[0]'], file='/dev/fd/63', table={\"['description']\": 1, \"['text']\": 2, \"['text', '[0]']\": 3, \"['text', '[0]', 'def']\": 3, \"['text', '[0]', 'function']\": 4, \"['text', '[0]', 'function', 'sentence']\": 5, \"['text', '[0]', 'function', 'language']\": 6, \"['text', '[0]', 'return']\": 7, \"['text', '[0]', 'return', 'lastOf']\": 8, \"['text', '[0]', 'return', 'lastOf', '[0]']\": 9, \"['text', '[0]', 'return', 'lastOf', '[1]']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'model']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters']\": 11, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'stop']\": 12, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'temperature']\": 13, \"['text', '[1]']\": 14, \"['text', '[1]', 'call']\": 14, \"['text', '[1]', 'args']\": 15, \"['text', '[1]', 'args', 'sentence']\": 16, \"['text', '[1]', 'args', 'language']\": 17, \"['text', '[2]']\": 18, \"['text', '[3]']\": 19, \"['text', '[3]', 'call']\": 19, \"['text', '[3]', 'args']\": 20, \"['text', '[3]', 'args', 'sentence']\": 21, \"['text', '[3]', 'args', 'language']\": 22}) pdl__timing=Timing(start_nanos=1741203542849503000, end_nanos=1741203542849554000, first_use_nanos=0, timezone='') kind= function={'sentence': 'str', 'language': 'str'} returns=LastOfBlock(description=None, spec=None, defs={}, assign=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], id='text.3.call.lastOf', result=None, location=LocationType(path=['text', '[0]', 'return'], file='/dev/fd/63', table={\"['description']\": 1, \"['text']\": 2, \"['text', '[0]']\": 3, \"['text', '[0]', 'def']\": 3, \"['text', '[0]', 'function']\": 4, \"['text', '[0]', 'function', 'sentence']\": 5, \"['text', '[0]', 'function', 'language']\": 6, \"['text', '[0]', 'return']\": 7, \"['text', '[0]', 'return', 'lastOf']\": 8, \"['text', '[0]', 'return', 'lastOf', '[0]']\": 9, \"['text', '[0]', 'return', 'lastOf', '[1]']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'model']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters']\": 11, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'stop']\": 12, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'temperature']\": 13, \"['text', '[1]']\": 14, \"['text', '[1]', 'call']\": 14, \"['text', '[1]', 'args']\": 15, \"['text', '[1]', 'args', 'sentence']\": 16, \"['text', '[1]', 'args', 'language']\": 17, \"['text', '[2]']\": 18, \"['text', '[3]']\": 19, \"['text', '[3]', 'call']\": 19, \"['text', '[3]', 'args']\": 20, \"['text', '[3]', 'args', 'sentence']\": 21, \"['text', '[3]', 'args', 'language']\": 22}), pdl__timing=Timing(start_nanos=1741203543856103000, end_nanos=1741203544182646000, first_use_nanos=0, timezone=''), kind=, lastOf=[\"\\nTranslate the sentence '${ sentence }' to ${ language }.\\n\", LitellmModelBlock(description=None, spec=None, defs={}, assign=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], id='text.3.call.lastOf.model', result=None, location=LocationType(path=['text', '[0]', 'return', 'lastOf', '[1]'], file='/dev/fd/63', table={\"['description']\": 1, \"['text']\": 2, \"['text', '[0]']\": 3, \"['text', '[0]', 'def']\": 3, \"['text', '[0]', 'function']\": 4, \"['text', '[0]', 'function', 'sentence']\": 5, \"['text', '[0]', 'function', 'language']\": 6, \"['text', '[0]', 'return']\": 7, \"['text', '[0]', 'return', 'lastOf']\": 8, \"['text', '[0]', 'return', 'lastOf', '[0]']\": 9, \"['text', '[0]', 'return', 'lastOf', '[1]']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'model']\": 10, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters']\": 11, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'stop']\": 12, \"['text', '[0]', 'return', 'lastOf', '[1]', 'parameters', 'temperature']\": 13, \"['text', '[1]']\": 14, \"['text', '[1]', 'call']\": 14, \"['text', '[1]', 'args']\": 15, \"['text', '[1]', 'args', 'sentence']\": 16, \"['text', '[1]', 'args', 'language']\": 17, \"['text', '[2]']\": 18, \"['text', '[3]']\": 19, \"['text', '[3]', 'call']\": 19, \"['text', '[3]', 'args']\": 20, \"['text', '[3]', 'args', 'sentence']\": 21, \"['text', '[3]', 'args', 'language']\": 22}), pdl__timing=Timing(start_nanos=1741203543856980000, end_nanos=1741203544182607000, first_use_nanos=0, timezone=''), kind=, model='ollama_chat/granite3.2:2b', input=None, trace=None, modelResponse=None, platform=, parameters=LitellmParameters(timeout=None, temperature=0.0, top_p=None, n=None, stop=['\\n'], max_tokens=None, presence_penalty=None, frequency_penalty=None, logit_bias=None, user=None, response_format=None, seed=None, tools=None, tool_choice=None, logprobs=None, top_logprobs=None, parallel_tool_calls=None, extra_headers=None, functions=None, function_call=None, base_url=None, api_version=None, api_key=None, model_list=None, mock_response=None, custom_llm_provider=None, max_retries=None))])"}, {"kind": "call", "id": "text.1.call", "pdl__timing": {"start_nanos": 1741203542849575000, "end_nanos": 1741203543851822000, "timezone": "EST"}, "defs": {}, "call": "${ translate }", "args": {"sentence": "I love Paris!", "language": "French"}, "trace": {"kind": "lastOf", "id": "text.1.call.lastOf", "pdl__timing": {"start_nanos": 1741203542851268000, "end_nanos": 1741203543851753000, "timezone": "EST"}, "defs": {}, "lastOf": [{"kind": "data", "id": "text.1.call.lastOf", "pdl__timing": {"start_nanos": 1741203542851298000, "end_nanos": 1741203542851695000, "timezone": "EST"}, "defs": {}, "data": "\nTranslate the sentence '${ sentence }' to ${ language }.\n", "result": "\nTranslate the sentence 'I love Paris!' to French.\n"}, {"kind": "model", "id": "text.1.call.lastOf.model", "context": [{"role": "user", "content": "\nTranslate the sentence 'I love Paris!' to French.\n", "defsite": "text.1.call.lastOf"}], "pdl__timing": {"start_nanos": 1741203542892366000, "end_nanos": 1741203543851624000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "parameters": {"temperature": 0.0, "stop": ["\n"]}, "result": "'J'aime Paris !'"}], "result": "'J'aime Paris !'"}, "result": "'J'aime Paris !'"}, {"kind": "data", "id": "text.2", "pdl__timing": {"start_nanos": 1741203543851864000, "end_nanos": 1741203543852885000, "timezone": "EST"}, "defs": {}, "data": "\n", "result": "\n"}, {"kind": "call", "id": "text.3.call", "pdl__timing": {"start_nanos": 1741203543853288000, "end_nanos": 1741203544182666000, "timezone": "EST"}, "defs": {}, "call": "${ translate }", "args": {"sentence": "I love Madrid!", "language": "Spanish"}, "trace": {"kind": "lastOf", "id": "text.3.call.lastOf", "pdl__timing": {"start_nanos": 1741203543856103000, "end_nanos": 1741203544182646000, "timezone": "EST"}, "defs": {}, "lastOf": [{"kind": "data", "id": "text.3.call.lastOf", "pdl__timing": {"start_nanos": 1741203543856172000, "end_nanos": 1741203543856829000, "timezone": "EST"}, "defs": {}, "data": "\nTranslate the sentence '${ sentence }' to ${ language }.\n", "result": "\nTranslate the sentence 'I love Madrid!' to Spanish.\n"}, {"kind": "model", "id": "text.3.call.lastOf.model", "context": [{"role": "user", "content": "\nTranslate the sentence 'I love Paris!' to French.\n", "defsite": "text.1.call.lastOf"}, {"content": "'J'aime Paris !'", "role": "assistant", "defsite": "text.3.call.lastOf.model"}, {"role": "user", "content": "\n", "defsite": "text.2"}, {"role": "user", "content": "\nTranslate the sentence 'I love Madrid!' to Spanish.\n", "defsite": "text.3.call.lastOf"}], "pdl__timing": {"start_nanos": 1741203543856980000, "end_nanos": 1741203544182607000, "timezone": "EST"}, "defs": {}, "platform": "litellm", "model": "ollama_chat/granite3.2:2b", "parameters": {"temperature": 0.0, "stop": ["\n"]}, "result": "The translation of \"I love Madrid!\" into Spanish is: \"Me encanta Madrid!\""}], "result": "The translation of \"I love Madrid!\" into Spanish is: \"Me encanta Madrid!\""}, "result": "The translation of \"I love Madrid!\" into Spanish is: \"Me encanta Madrid!\""}], "result": "'J'aime Paris !'\nThe translation of \"I love Madrid!\" into Spanish is: \"Me encanta Madrid!\""} \ No newline at end of file diff --git a/tests/results/examples/hello/hello-code-pdl.0.result b/tests/results/examples/hello/hello-code-pdl.0.result index 9905b5554..ae9292c0d 100644 --- a/tests/results/examples/hello/hello-code-pdl.0.result +++ b/tests/results/examples/hello/hello-code-pdl.0.result @@ -1,2 +1,2 @@ Hello -Greetings! How can I assist you today? \ No newline at end of file +Hello! How can I assist you today? Let's chat about anything you'd like. Whether it's general knowledge, explanations on various topics, or just a casual conversation, I'm here to help. What's on your mind? diff --git a/tests/results/examples/talk/4-function.0.result b/tests/results/examples/talk/4-function.0.result index 325d44fb1..2d4182036 100644 --- a/tests/results/examples/talk/4-function.0.result +++ b/tests/results/examples/talk/4-function.0.result @@ -1,2 +1,2 @@ -'Je suis adepte de Paris!' -'Te quiero mucho Madrid!' +'J'aime Paris !' +The translation of "I love Madrid!" into Spanish is: "Me encanta Madrid!" \ No newline at end of file diff --git a/tests/results/examples/talk/4-function.1.result b/tests/results/examples/talk/4-function.1.result new file mode 100644 index 000000000..c9646a004 --- /dev/null +++ b/tests/results/examples/talk/4-function.1.result @@ -0,0 +1,2 @@ +'J'aime Paris !' +The translation of "I love Madrid!" into Spanish is: "Me encanta Madrid." \ No newline at end of file diff --git a/tests/results/examples/talk/4-function.12.result b/tests/results/examples/talk/4-function.12.result deleted file mode 100644 index 2d73b2082..000000000 --- a/tests/results/examples/talk/4-function.12.result +++ /dev/null @@ -1,2 +0,0 @@ -The sentence 'I love Paris!' translates to 'Je t'aime Paris!' in French. However, if you want to say 'I love Paris' without the possessive pronoun, it would be 'Je aime Paris!'. -The sentence 'I love Madrid!' translates to 'Me encanta Madrid!' in Spanish. diff --git a/tests/results/examples/tutorial/parser_regex.0.result b/tests/results/examples/tutorial/parser_regex.0.result index 4693ad3cf..a05075973 100644 --- a/tests/results/examples/tutorial/parser_regex.0.result +++ b/tests/results/examples/tutorial/parser_regex.0.result @@ -1,2 +1,2 @@ -def add(a, b): - return a + b +result = add_two_numbers(3, 5) +print(result) # Output will be: 8 diff --git a/tests/results/examples/tutorial/parser_regex.1.result b/tests/results/examples/tutorial/parser_regex.1.result index bc2226fa3..b6f980879 100644 --- a/tests/results/examples/tutorial/parser_regex.1.result +++ b/tests/results/examples/tutorial/parser_regex.1.result @@ -1,2 +1,2 @@ -def add_numbers(a, b): - return a + b +result = add_numbers(3, 5) +print(result) # Outputs: 8 diff --git a/tests/results/examples/tutorial/parser_regex.2.result b/tests/results/examples/tutorial/parser_regex.2.result index 9cde8bb1a..c97902c54 100644 --- a/tests/results/examples/tutorial/parser_regex.2.result +++ b/tests/results/examples/tutorial/parser_regex.2.result @@ -1,2 +1,2 @@ -def add_numbers(num1, num2): - return num1 + num2 +result = add_two_numbers(5, 7) +print(result) # Output will be: 12 diff --git a/tests/results/examples/tutorial/parser_regex.3.result b/tests/results/examples/tutorial/parser_regex.3.result index 362bf86ea..75ae44fb8 100644 --- a/tests/results/examples/tutorial/parser_regex.3.result +++ b/tests/results/examples/tutorial/parser_regex.3.result @@ -1,7 +1,2 @@ -def add_numbers(a, b): - while b != 0: - carry = (a & b) << 1 - a = a ^ b - b = carry - - return a +result = add_two_numbers(3, 5) +print(result) # Output: 8