From 1dfe5b843a3dda0db26a13d4ab95cf68a262c8d0 Mon Sep 17 00:00:00 2001 From: Nick Mitchell Date: Tue, 21 Jan 2025 13:20:37 -0500 Subject: [PATCH] feat: and start_nanos, end_nanos, timezone to PdlBlock model Also updates the react UI to display this information. Signed-off-by: Nick Mitchell --- pdl-live-react/demos/demo1.pdl | 7 + pdl-live-react/demos/run.sh | 14 + pdl-live-react/eslint.config.js | 2 +- pdl-live-react/package.json | 1 + pdl-live-react/src/demos/README.md | 1 + pdl-live-react/src/demos/demo1.json | 21 +- pdl-live-react/src/demos/demo2.json | 2 +- pdl-live-react/src/demos/demo3.json | 58 +- 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 +- pdl-live-react/src/helpers.ts | 30 +- pdl-live-react/src/pdl_ast.d.ts | 908 +++++++++--------- pdl-live-react/src/view/Code.tsx | 12 +- .../src/view/transcript/Duration.css | 6 + .../src/view/transcript/Duration.tsx | 58 ++ .../src/view/transcript/PrettyKind.tsx | 15 +- .../src/view/transcript/TranscriptItem.tsx | 13 +- pdl-live-react/yarn.lock | 12 + pdl-live/src/pdl_ast.d.ts | 342 +++++++ src/pdl/pdl-schema.json | 747 +++++++++++++- src/pdl/pdl_ast.py | 9 + src/pdl/pdl_dumper.py | 13 + src/pdl/pdl_interpreter.py | 23 +- 25 files changed, 1762 insertions(+), 540 deletions(-) create mode 100644 pdl-live-react/demos/demo1.pdl create mode 100755 pdl-live-react/demos/run.sh create mode 100644 pdl-live-react/src/view/transcript/Duration.css create mode 100644 pdl-live-react/src/view/transcript/Duration.tsx diff --git a/pdl-live-react/demos/demo1.pdl b/pdl-live-react/demos/demo1.pdl new file mode 100644 index 00000000..ebd47ea2 --- /dev/null +++ b/pdl-live-react/demos/demo1.pdl @@ -0,0 +1,7 @@ +description: Simple LLM interaction +text: +- "write a hello world example\n" +- model: ollama/granite-code:8b + parameters: + stop_sequences: '!' + temperature: 0 \ No newline at end of file diff --git a/pdl-live-react/demos/run.sh b/pdl-live-react/demos/run.sh new file mode 100755 index 00000000..f0cb852e --- /dev/null +++ b/pdl-live-react/demos/run.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +SCRIPTDIR=$(cd $(dirname "$0") && pwd) +UI="$SCRIPTDIR"/.. # top of react UI +TOP="$UI"/.. # top of repo +T="$UI"/src/demos # place to store traces + +pdl --trace "$T"/demo1.json "$UI"/demos/demo1.pdl +pdl --trace "$T"/demo2.json "$TOP"/examples/tutorial/model_chaining.pdl +pdl --trace "$T"/demo3.json "$TOP"/examples/fibonacci/fib.pdl +pdl --trace "$T"/demo4.json "$TOP"/examples/chatbot/chatbot.pdl # WARNING: this one requires some human interaction. TODO script this. +pdl --trace "$T"/demo5.json "$TOP"/examples/talk/6-code-json.pdl +pdl --trace "$T"/demo6.json "$UI"/demos/error.pdl || true +pdl --trace "$T"/demo7.json "$TOP"/examples/talk/4-function.pdl diff --git a/pdl-live-react/eslint.config.js b/pdl-live-react/eslint.config.js index c01de94b..e0e9553a 100644 --- a/pdl-live-react/eslint.config.js +++ b/pdl-live-react/eslint.config.js @@ -5,7 +5,7 @@ import reactRefresh from 'eslint-plugin-react-refresh' import tseslint from 'typescript-eslint' export default tseslint.config( - { ignores: ['dist','test-results'] }, + { ignores: ['dist','test-results','src/**/*.d.ts'] }, { extends: [js.configs.recommended, ...tseslint.configs.recommended], files: ['**/*.{ts,tsx}'], diff --git a/pdl-live-react/package.json b/pdl-live-react/package.json index ed0edf52..4a42920d 100644 --- a/pdl-live-react/package.json +++ b/pdl-live-react/package.json @@ -15,6 +15,7 @@ "dependencies": { "@patternfly/react-code-editor": "^6.1.0", "@patternfly/react-core": "^6.1.0", + "pretty-ms": "^9.2.0", "react": "^18.3.1", "react-dom": "^18.3.1", "react-markdown": "^9.0.3", diff --git a/pdl-live-react/src/demos/README.md b/pdl-live-react/src/demos/README.md index c66db991..93305249 100644 --- a/pdl-live-react/src/demos/README.md +++ b/pdl-live-react/src/demos/README.md @@ -8,3 +8,4 @@ These demo traces were sourced as follows: - demo4: [chatbot.pdl](../../../examples/chatbot/chatbot.pdl) - demo5: [6-code-json.pdl](../../../examples/talk/6-code-json.pdl) - demo6: [error.pdl](../../demos/error.pdl) +- demo7: [4-talk.pdl](../../../examples/talk/4-function.pdl) diff --git a/pdl-live-react/src/demos/demo1.json b/pdl-live-react/src/demos/demo1.json index cb037616..ecb4ea7e 100644 --- a/pdl-live-react/src/demos/demo1.json +++ b/pdl-live-react/src/demos/demo1.json @@ -1,20 +1 @@ -{ - "kind": "text", - "description": "Simple LLM interaction", - "defs": {}, - "text": [ - "write a hello world example\n", - { - "kind": "model", - "defs": {}, - "platform": "litellm", - "model": "ollama/granite-code:8b", - "parameters": { - "temperature": 0.0, - "stop_sequences": "!" - }, - "result": "```python\nprint(\"hello world\")\n```\n" - } - ], - "result": "write a hello world example\n```python\nprint(\"hello world\")\n```\n" -} +{"kind": "text", "start_nanos": 1737481387443288000, "end_nanos": 1737481388576573000, "timezone": "EST", "description": "Simple LLM interaction", "defs": {}, "text": ["write a hello world example\n", {"kind": "model", "start_nanos": 1737481387444188000, "end_nanos": 1737481388576550000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "parameters": {"temperature": 0.0, "stop_sequences": "!"}, "result": "```python\nprint(\"hello world\")\n```\n"}], "result": "write a hello world example\n```python\nprint(\"hello world\")\n```\n"} \ 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 adcb9abe..d6a33af2 100644 --- a/pdl-live-react/src/demos/demo2.json +++ b/pdl-live-react/src/demos/demo2.json @@ -1 +1 @@ -{"kind": "text", "description": "Model chaining", "defs": {}, "text": ["Hello\n", {"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "parameters": {"stop_sequences": "!"}, "result": "Hello! How can I help you today?\n"}, "\nDid you just say Hello?\n", {"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "parameters": {"stop_sequences": "!"}, "result": "Yes, I did. Is there anything I can help you with?\n"}], "result": "Hello\nHello! How can I help you today?\n\nDid you just say Hello?\nYes, I did. Is there anything I can help you with?\n"} \ No newline at end of file +{"kind": "text", "start_nanos": 1737481389613977000, "end_nanos": 1737481390433251000, "timezone": "EST", "description": "Model chaining", "defs": {}, "text": ["Hello\n", {"kind": "model", "start_nanos": 1737481389614907000, "end_nanos": 1737481390031193000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "parameters": {"stop_sequences": "!"}, "result": "Hello! How can I help you today?\n"}, "\nDid you just say Hello?\n", {"kind": "model", "start_nanos": 1737481390031579000, "end_nanos": 1737481390433219000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "parameters": {"stop_sequences": "!"}, "result": "Yes, I did. How can I assist you further?\n"}], "result": "Hello\nHello! How can I help you today?\n\nDid you just say Hello?\nYes, I did. How can I assist you further?\n"} \ 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 1d399143..15e4dcbe 100644 --- a/pdl-live-react/src/demos/demo3.json +++ b/pdl-live-react/src/demos/demo3.json @@ -1,57 +1 @@ -{ - "kind": "text", - "description": "Fibonacci", - "defs": {}, - "text": [ - { - "kind": "model", - "defs": {}, - "platform": "litellm", - "model": "ollama/granite-code: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", - "result": "Here is the implementation of the Fibonacci sequence in Python:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n```\n" - }, - "\nExtract the Python code from the LLM response\n", - { - "kind": "code", - "defs": {}, - "lang": "python", - "code": "s = \"\"\"'Here is the implementation of the Fibonacci sequence in Python:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n```\n '\"\"\"\nresult = s.split(\"```\")[1].replace(\"python\", \"\")\n", - "def": "EXTRACTED", - "result": "\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n" - }, - "\nFind a random number between 1 and 20\n", - { - "kind": "code", - "defs": {}, - "lang": "python", - "code": "import random\nresult = random.randint(1, 20)\n", - "def": "N", - "result": 14 - }, - "\nNow compute `fibonacci(14)`\n", - { - "kind": "code", - "defs": {}, - "lang": "python", - "code": "\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\nresult = fibonacci(14)\n", - "def": "RESULT", - "contribute": [], - "result": 377 - }, - "The result is: 377", - "\n\nExplain what the above code does and what the result means\n\n", - { - "kind": "model", - "defs": {}, - "platform": "litellm", - "model": "ollama/granite-code:8b", - "result": "The Python code defines a recursive function called `fibonacci` that calculates the nth Fibonacci number. The function checks if n is less than or equal to 1, in which case it returns n. Otherwise, it recursively calls itself with arguments n-1 and n-2, and adds the results together.\n\nThe result of `fibonacci(14)` is 377, which means that the 14th Fibonacci number is 377. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, starting from 0 and 1. So, the first few Fibonacci numbers are:\n\n0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, ...\n\nThe 14th Fibonacci number is 377, which means that the sum of the 13th and 12th Fibonacci numbers is 377. This is an example of how the Fibonacci sequence can be used to calculate the sum of two preceding terms in the sequence.\n" - } - ], - "result": "Here is the implementation of the Fibonacci sequence in Python:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n```\n\nExtract the Python code from the LLM response\n\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\nFind a random number between 1 and 20\n14\nNow compute `fibonacci(14)`\nThe result is: 377\n\nExplain what the above code does and what the result means\n\nThe Python code defines a recursive function called `fibonacci` that calculates the nth Fibonacci number. The function checks if n is less than or equal to 1, in which case it returns n. Otherwise, it recursively calls itself with arguments n-1 and n-2, and adds the results together.\n\nThe result of `fibonacci(14)` is 377, which means that the 14th Fibonacci number is 377. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, starting from 0 and 1. So, the first few Fibonacci numbers are:\n\n0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, ...\n\nThe 14th Fibonacci number is 377, which means that the sum of the 13th and 12th Fibonacci numbers is 377. This is an example of how the Fibonacci sequence can be used to calculate the sum of two preceding terms in the sequence.\n" -} +{"kind": "text", "start_nanos": 1737481391456942000, "end_nanos": 1737481396443243000, "timezone": "EST", "description": "Fibonacci", "defs": {}, "text": [{"kind": "model", "start_nanos": 1737481391456982000, "end_nanos": 1737481392659272000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/granite-code: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", "result": "Here is the implementation of the Fibonacci sequence in Python:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n```\n"}, "\nExtract the Python code from the LLM response\n", {"kind": "code", "start_nanos": 1737481392659645000, "end_nanos": 1737481392661060000, "timezone": "EST", "defs": {}, "lang": "python", "code": "s = \"\"\"'Here is the implementation of the Fibonacci sequence in Python:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n```\n '\"\"\"\nresult = s.split(\"```\")[1].replace(\"python\", \"\")\n", "def": "EXTRACTED", "result": "\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n"}, "\nFind a random number between 1 and 20\n", {"kind": "code", "start_nanos": 1737481392661332000, "end_nanos": 1737481392661708000, "timezone": "EST", "defs": {}, "lang": "python", "code": "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": 11}, "\nNow compute `fibonacci(11)`\n", {"kind": "code", "start_nanos": 1737481392662005000, "end_nanos": 1737481392662424000, "timezone": "EST", "defs": {}, "lang": "python", "code": "\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\nresult = fibonacci(11)\n", "def": "RESULT", "contribute": [], "result": 89}, "The result is: 89", "\n\nExplain what the above code does and what the result means\n\n", {"kind": "model", "start_nanos": 1737481392662831000, "end_nanos": 1737481396443207000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "result": "The code defines a recursive function called `fibonacci` that takes an integer `n` as input. If `n` is less than or equal to 1, the function simply returns `n`. Otherwise, it recursively calls itself with `n-1` and `n-2`, adds the results, and returns the sum.\n\nThe result of computing `fibonacci(11)` is 89. This means that the 11th number in the Fibonacci sequence is 89. The Fibonacci sequence starts with 0 and 1, so the first few numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and 55. The 11th number in this sequence is 89.\n"}], "result": "Here is the implementation of the Fibonacci sequence in Python:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n```\n\nExtract the Python code from the LLM response\n\ndef fibonacci(n):\n if n <= 1:\n return n\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\nFind a random number between 1 and 20\n11\nNow compute `fibonacci(11)`\nThe result is: 89\n\nExplain what the above code does and what the result means\n\nThe code defines a recursive function called `fibonacci` that takes an integer `n` as input. If `n` is less than or equal to 1, the function simply returns `n`. Otherwise, it recursively calls itself with `n-1` and `n-2`, adds the results, and returns the sum.\n\nThe result of computing `fibonacci(11)` is 89. This means that the 11th number in the Fibonacci sequence is 89. The Fibonacci sequence starts with 0 and 1, so the first few numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and 55. The 11th number in this sequence is 89.\n"} \ 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 28fff66b..17439243 100644 --- a/pdl-live-react/src/demos/demo4.json +++ b/pdl-live-react/src/demos/demo4.json @@ -1 +1 @@ -{"kind": "text", "description": "Chatbot", "defs": {}, "text": [{"kind": "read", "defs": {}, "read": null, "message": "What is your query?\n", "multiline": false, "contribute": ["context"], "result": "what is the fastest animal"}, {"kind": "repeat_until", "defs": {}, "repeat": {"kind": "text", "defs": {}, "text": [{"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b"}, {"kind": "read", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "contribute": ["context"]}, {"kind": "if", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "defs": {}, "text": [{"kind": "read", "defs": {}, "read": null, "message": "Why not?\n", "multiline": false, "contribute": []}]}}]}, "until": "${ eval == 'yes'}", "join": {"with": ""}, "trace": [{"kind": "text", "defs": {}, "text": [{"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "result": "The fastest animal is the cheetah. They can run up to speeds of 70 miles per hour, making them the fastest land animal.\n"}, {"kind": "read", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "contribute": ["context"], "result": "no"}, {"kind": "if", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "defs": {}, "text": [{"kind": "read", "defs": {}, "read": null, "message": "Why not?\n", "multiline": false, "contribute": [], "result": "in europe"}], "result": ""}, "if_result": true, "result": ""}], "result": "The fastest animal is the cheetah. They can run up to speeds of 70 miles per hour, making them the fastest land animal.\n"}, {"kind": "text", "defs": {}, "text": [{"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "result": "I'm sorry, but you are incorrect. The cheetah is not the fastest animal. The fastest animal is the peregrine falcon, which can reach speeds of up to 240 miles per hour. Peregrine falcons are able to run at such high speeds due to their powerful wings and streamlined body shape. They are also able to hover in the air for short periods of time, allowing them to catch prey mid-air.\n"}, {"kind": "read", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "contribute": ["context"], "result": "yes"}, {"kind": "if", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "defs": {}, "text": [{"kind": "read", "defs": {}, "read": null, "message": "Why not?\n", "multiline": false, "contribute": []}]}, "if_result": false, "result": ""}], "result": "I'm sorry, but you are incorrect. The cheetah is not the fastest animal. The fastest animal is the peregrine falcon, which can reach speeds of up to 240 miles per hour. Peregrine falcons are able to run at such high speeds due to their powerful wings and streamlined body shape. They are also able to hover in the air for short periods of time, allowing them to catch prey mid-air.\n"}], "result": "The fastest animal is the cheetah. They can run up to speeds of 70 miles per hour, making them the fastest land animal.\nI'm sorry, but you are incorrect. The cheetah is not the fastest animal. The fastest animal is the peregrine falcon, which can reach speeds of up to 240 miles per hour. Peregrine falcons are able to run at such high speeds due to their powerful wings and streamlined body shape. They are also able to hover in the air for short periods of time, allowing them to catch prey mid-air.\n"}], "result": "The fastest animal is the cheetah. They can run up to speeds of 70 miles per hour, making them the fastest land animal.\nI'm sorry, but you are incorrect. The cheetah is not the fastest animal. The fastest animal is the peregrine falcon, which can reach speeds of up to 240 miles per hour. Peregrine falcons are able to run at such high speeds due to their powerful wings and streamlined body shape. They are also able to hover in the air for short periods of time, allowing them to catch prey mid-air.\n"} +{"kind": "text", "start_nanos": 1737481513257005000, "end_nanos": 1737481599907987000, "timezone": "EST", "description": "Chatbot", "defs": {}, "text": [{"kind": "read", "start_nanos": 1737481513257047000, "end_nanos": 1737481517243744000, "timezone": "EST", "defs": {}, "read": null, "message": "What is your query?\n", "multiline": false, "result": "what is the fastest animal"}, {"kind": "repeat_until", "start_nanos": 1737481517243782000, "end_nanos": 1737481599907942000, "timezone": "EST", "defs": {}, "repeat": {"kind": "text", "defs": {}, "text": [{"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/llama3.3"}, {"kind": "read", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval"}, "\n", {"kind": "if", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "defs": {}, "text": [{"kind": "read", "defs": {}, "read": null, "message": "Why not?\n", "multiline": false}]}}]}, "until": "${ eval == 'yes'}", "join": {"with": ""}, "trace": [{"kind": "text", "start_nanos": 1737481517243898000, "end_nanos": 1737481560793352000, "timezone": "EST", "defs": {}, "text": [{"kind": "model", "start_nanos": 1737481517243960000, "end_nanos": 1737481550974150000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/llama3.3", "result": "The fastest animal on land is the **cheetah**, which can reach speeds of up to **70 mph (113 km/h)**. However, when it comes to air and water, there are other animals that take the title:\n\n* **Fastest in air:** The **peregrine falcon**, which can dive at speeds of up to **242 mph (390 km/h)**.\n* **Fastest in water:** The **sailfish**, which can swim at speeds of up to **68 mph (110 km/h)**.\n\nHere are some other notable mentions:\n\n* **Pronghorn antelope**: Can run at speeds of up to 60 mph (97 km/h)\n* **Lion**: Can reach speeds of up to 50 mph (80 km/h)\n* **Black marlin**: Can swim at speeds of up to 50 mph (80 km/h)\n\nIt's worth noting that these speeds can vary depending on the source and the specific species, but overall, the cheetah is widely considered the fastest land animal."}, {"kind": "read", "start_nanos": 1737481550974168000, "end_nanos": 1737481556175158000, "timezone": "EST", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "result": "no"}, "\n", {"kind": "if", "start_nanos": 1737481556178093000, "end_nanos": 1737481560793297000, "timezone": "EST", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "start_nanos": 1737481556182265000, "end_nanos": 1737481560793253000, "timezone": "EST", "defs": {}, "text": [{"kind": "read", "start_nanos": 1737481556182346000, "end_nanos": 1737481560793190000, "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 animal on land is the **cheetah**, which can reach speeds of up to **70 mph (113 km/h)**. However, when it comes to air and water, there are other animals that take the title:\n\n* **Fastest in air:** The **peregrine falcon**, which can dive at speeds of up to **242 mph (390 km/h)**.\n* **Fastest in water:** The **sailfish**, which can swim at speeds of up to **68 mph (110 km/h)**.\n\nHere are some other notable mentions:\n\n* **Pronghorn antelope**: Can run at speeds of up to 60 mph (97 km/h)\n* **Lion**: Can reach speeds of up to 50 mph (80 km/h)\n* **Black marlin**: Can swim at speeds of up to 50 mph (80 km/h)\n\nIt's worth noting that these speeds can vary depending on the source and the specific species, but overall, the cheetah is widely considered the fastest land animal.no\nin europe?"}, {"kind": "text", "start_nanos": 1737481560794695000, "end_nanos": 1737481599906879000, "timezone": "EST", "defs": {}, "text": [{"kind": "model", "start_nanos": 1737481560794787000, "end_nanos": 1737481597479109000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/llama3.3", "result": "In Europe, the fastest land animal is the **European brown hare**, which can reach speeds of up to **45 mph (72 km/h)**. However, some other European animals are also quite speedy:\n\n* **Red fox**: Can run at speeds of up to 30-40 mph (48-64 km/h)\n* **Roe deer**: Can reach speeds of up to 30-35 mph (48-56 km/h)\n* **European rabbit**: Can run at speeds of up to 25-30 mph (40-48 km/h)\n\nIn the air, the fastest animal in Europe is the **peregrine falcon**, which can dive at speeds of up to **242 mph (390 km/h)**, just like its global counterpart.\n\nIn the water, the fastest animal in European waters is the **shortfin mako shark**, which can swim at speeds of up to **46 mph (74 km/h)**.\n\nLet me know if you have any other questions!"}, {"kind": "read", "start_nanos": 1737481597479121000, "end_nanos": 1737481599905087000, "timezone": "EST", "defs": {}, "read": null, "message": "\nIs this a good answer[yes/no]?\n", "multiline": false, "def": "eval", "result": "yes"}, "\n", {"kind": "if", "start_nanos": 1737481599905843000, "end_nanos": 1737481599906827000, "timezone": "EST", "defs": {}, "if": "${ eval == 'no' }", "then": {"kind": "text", "defs": {}, "text": [{"kind": "read", "defs": {}, "read": null, "message": "Why not?\n", "multiline": false}]}, "if_result": false, "result": ""}], "result": "In Europe, the fastest land animal is the **European brown hare**, which can reach speeds of up to **45 mph (72 km/h)**. However, some other European animals are also quite speedy:\n\n* **Red fox**: Can run at speeds of up to 30-40 mph (48-64 km/h)\n* **Roe deer**: Can reach speeds of up to 30-35 mph (48-56 km/h)\n* **European rabbit**: Can run at speeds of up to 25-30 mph (40-48 km/h)\n\nIn the air, the fastest animal in Europe is the **peregrine falcon**, which can dive at speeds of up to **242 mph (390 km/h)**, just like its global counterpart.\n\nIn the water, the fastest animal in European waters is the **shortfin mako shark**, which can swim at speeds of up to **46 mph (74 km/h)**.\n\nLet me know if you have any other questions!yes\n"}], "result": "The fastest animal on land is the **cheetah**, which can reach speeds of up to **70 mph (113 km/h)**. However, when it comes to air and water, there are other animals that take the title:\n\n* **Fastest in air:** The **peregrine falcon**, which can dive at speeds of up to **242 mph (390 km/h)**.\n* **Fastest in water:** The **sailfish**, which can swim at speeds of up to **68 mph (110 km/h)**.\n\nHere are some other notable mentions:\n\n* **Pronghorn antelope**: Can run at speeds of up to 60 mph (97 km/h)\n* **Lion**: Can reach speeds of up to 50 mph (80 km/h)\n* **Black marlin**: Can swim at speeds of up to 50 mph (80 km/h)\n\nIt's worth noting that these speeds can vary depending on the source and the specific species, but overall, the cheetah is widely considered the fastest land animal.no\nin europe?In Europe, the fastest land animal is the **European brown hare**, which can reach speeds of up to **45 mph (72 km/h)**. However, some other European animals are also quite speedy:\n\n* **Red fox**: Can run at speeds of up to 30-40 mph (48-64 km/h)\n* **Roe deer**: Can reach speeds of up to 30-35 mph (48-56 km/h)\n* **European rabbit**: Can run at speeds of up to 25-30 mph (40-48 km/h)\n\nIn the air, the fastest animal in Europe is the **peregrine falcon**, which can dive at speeds of up to **242 mph (390 km/h)**, just like its global counterpart.\n\nIn the water, the fastest animal in European waters is the **shortfin mako shark**, which can swim at speeds of up to **46 mph (74 km/h)**.\n\nLet me know if you have any other questions!yes\n"}], "result": "what is the fastest animalThe fastest animal on land is the **cheetah**, which can reach speeds of up to **70 mph (113 km/h)**. However, when it comes to air and water, there are other animals that take the title:\n\n* **Fastest in air:** The **peregrine falcon**, which can dive at speeds of up to **242 mph (390 km/h)**.\n* **Fastest in water:** The **sailfish**, which can swim at speeds of up to **68 mph (110 km/h)**.\n\nHere are some other notable mentions:\n\n* **Pronghorn antelope**: Can run at speeds of up to 60 mph (97 km/h)\n* **Lion**: Can reach speeds of up to 50 mph (80 km/h)\n* **Black marlin**: Can swim at speeds of up to 50 mph (80 km/h)\n\nIt's worth noting that these speeds can vary depending on the source and the specific species, but overall, the cheetah is widely considered the fastest land animal.no\nin europe?In Europe, the fastest land animal is the **European brown hare**, which can reach speeds of up to **45 mph (72 km/h)**. However, some other European animals are also quite speedy:\n\n* **Red fox**: Can run at speeds of up to 30-40 mph (48-64 km/h)\n* **Roe deer**: Can reach speeds of up to 30-35 mph (48-56 km/h)\n* **European rabbit**: Can run at speeds of up to 25-30 mph (40-48 km/h)\n\nIn the air, the fastest animal in Europe is the **peregrine falcon**, which can dive at speeds of up to **242 mph (390 km/h)**, just like its global counterpart.\n\nIn the water, the fastest animal in European waters is the **shortfin mako shark**, which can swim at speeds of up to **46 mph (74 km/h)**.\n\nLet me know if you have any other questions!yes\n"} diff --git a/pdl-live-react/src/demos/demo5.json b/pdl-live-react/src/demos/demo5.json index 18ecb334..fe295323 100644 --- a/pdl-live-react/src/demos/demo5.json +++ b/pdl-live-react/src/demos/demo5.json @@ -1 +1 @@ -{"kind": "lastOf", "description": "Code explanation example", "defs": {"CODE": {"kind": "read", "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", "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."}}, "lastOf": [{"kind": "model", "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", "def": "EXPLANATION", "contribute": [], "result": "**Code Explanation: Deserializing an Offset Map from a JSON String**\n\nThis Java method, `deserializeOffsetMap`, is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a string representation of an offset map (`lastSourceOffset`) as input and returns a deserialized `Map` containing the offset information.\n\n**Method Breakdown**\n\n1. **Suppression of unchecked cast warning**: The first line, `@SuppressWarnings(\"unchecked\")`, suppresses a warning that would otherwise be generated by Java due to the use of an unchecked cast.\n2. **Initialization of offset map**: A local variable `offsetMap` is declared as an instance of `Map`. This will store the deserialized offset information.\n3. **Handling null or empty input**: If the input string (`lastSourceOffset`) is either:\n\t* Null: An empty `HashMap` is created and assigned to `offsetMap`.\n\t* Empty (i.e., an empty string): An empty `HashMap` is created and assigned to `offsetMap`. This implies that no offset information is available, so an empty map is a reasonable default.\n4. **Deserialization using JSON_MAPPER**: If the input string is not null or empty, it's assumed to be a JSON representation of the offset map. The `JSON_MAPPER` object (an instance of `ObjectMapper`, likely created elsewhere in the codebase) is used to deserialize the JSON string into a Java `Map`. This map is then assigned to `offsetMap`.\n5. **Return the deserialized offset map**: Finally, the method returns the `offsetMap`.\n\n**Context**\n\nThis method is likely used in a context where offset information needs to be retrieved from a JSON-formatted string and stored in a Java `Map` for further processing or storage.\n\nExample usage:\n```java\nString jsonOffset = \"{\\\"key1\\\":\\\"value1\\\",\\\"key2\\\":\\\"value2\\\"}\";\nMap offsetMap = OffsetUtil.deserializeOffsetMap(jsonOffset);\n// Use the deserialized map as needed\n```\nNote that this method assumes the presence of a `JSON_MAPPER` instance elsewhere in the codebase. If not defined, you'll need to create an instance of `ObjectMapper` (e.g., using `new ObjectMapper()`) and configure it as necessary for your specific JSON serialization requirements."}, {"kind": "code", "defs": {}, "lang": "python", "code": "import textdistance\nexpl = \"\"\"\n**Code Explanation: Deserializing an Offset Map from a JSON String**\n\nThis Java method, `deserializeOffsetMap`, is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a string representation of an offset map (`lastSourceOffset`) as input and returns a deserialized `Map` containing the offset information.\n\n**Method Breakdown**\n\n1. **Suppression of unchecked cast warning**: The first line, `@SuppressWarnings(\"unchecked\")`, suppresses a warning that would otherwise be generated by Java due to the use of an unchecked cast.\n2. **Initialization of offset map**: A local variable `offsetMap` is declared as an instance of `Map`. This will store the deserialized offset information.\n3. **Handling null or empty input**: If the input string (`lastSourceOffset`) is either:\n\t* Null: An empty `HashMap` is created and assigned to `offsetMap`.\n\t* Empty (i.e., an empty string): An empty `HashMap` is created and assigned to `offsetMap`. This implies that no offset information is available, so an empty map is a reasonable default.\n4. **Deserialization using JSON_MAPPER**: If the input string is not null or empty, it's assumed to be a JSON representation of the offset map. The `JSON_MAPPER` object (an instance of `ObjectMapper`, likely created elsewhere in the codebase) is used to deserialize the JSON string into a Java `Map`. This map is then assigned to `offsetMap`.\n5. **Return the deserialized offset map**: Finally, the method returns the `offsetMap`.\n\n**Context**\n\nThis method is likely used in a context where offset information needs to be retrieved from a JSON-formatted string and stored in a Java `Map` for further processing or storage.\n\nExample usage:\n```java\nString jsonOffset = \"{\\\"key1\\\":\\\"value1\\\",\\\"key2\\\":\\\"value2\\\"}\";\nMap offsetMap = OffsetUtil.deserializeOffsetMap(jsonOffset);\n// Use the deserialized map as needed\n```\nNote that this method assumes the presence of a `JSON_MAPPER` instance elsewhere in the codebase. If not defined, you'll need to create an instance of `ObjectMapper` (e.g., using `new ObjectMapper()`) and configure it as necessary for your specific JSON serialization requirements.\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\"\"\"\nresult = textdistance.levenshtein.normalized_similarity(expl, truth)\n", "def": "EVAL", "result": 0.19828364950316169}, {"kind": "data", "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: Deserializing an Offset Map from a JSON String**\n\nThis Java method, `deserializeOffsetMap`, is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a string representation of an offset map (`lastSourceOffset`) as input and returns a deserialized `Map` containing the offset information.\n\n**Method Breakdown**\n\n1. **Suppression of unchecked cast warning**: The first line, `@SuppressWarnings(\"unchecked\")`, suppresses a warning that would otherwise be generated by Java due to the use of an unchecked cast.\n2. **Initialization of offset map**: A local variable `offsetMap` is declared as an instance of `Map`. This will store the deserialized offset information.\n3. **Handling null or empty input**: If the input string (`lastSourceOffset`) is either:\n\t* Null: An empty `HashMap` is created and assigned to `offsetMap`.\n\t* Empty (i.e., an empty string): An empty `HashMap` is created and assigned to `offsetMap`. This implies that no offset information is available, so an empty map is a reasonable default.\n4. **Deserialization using JSON_MAPPER**: If the input string is not null or empty, it's assumed to be a JSON representation of the offset map. The `JSON_MAPPER` object (an instance of `ObjectMapper`, likely created elsewhere in the codebase) is used to deserialize the JSON string into a Java `Map`. This map is then assigned to `offsetMap`.\n5. **Return the deserialized offset map**: Finally, the method returns the `offsetMap`.\n\n**Context**\n\nThis method is likely used in a context where offset information needs to be retrieved from a JSON-formatted string and stored in a Java `Map` for further processing or storage.\n\nExample usage:\n```java\nString jsonOffset = \"{\\\"key1\\\":\\\"value1\\\",\\\"key2\\\":\\\"value2\\\"}\";\nMap offsetMap = OffsetUtil.deserializeOffsetMap(jsonOffset);\n// Use the deserialized map as needed\n```\nNote that this method assumes the presence of a `JSON_MAPPER` instance elsewhere in the codebase. If not defined, you'll need to create an instance of `ObjectMapper` (e.g., using `new ObjectMapper()`) and configure it as necessary for your specific JSON serialization requirements.", "metric": 0.19828364950316169}, "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: Deserializing an Offset Map from a JSON String**\n\nThis Java method, `deserializeOffsetMap`, is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a string representation of an offset map (`lastSourceOffset`) as input and returns a deserialized `Map` containing the offset information.\n\n**Method Breakdown**\n\n1. **Suppression of unchecked cast warning**: The first line, `@SuppressWarnings(\"unchecked\")`, suppresses a warning that would otherwise be generated by Java due to the use of an unchecked cast.\n2. **Initialization of offset map**: A local variable `offsetMap` is declared as an instance of `Map`. This will store the deserialized offset information.\n3. **Handling null or empty input**: If the input string (`lastSourceOffset`) is either:\n\t* Null: An empty `HashMap` is created and assigned to `offsetMap`.\n\t* Empty (i.e., an empty string): An empty `HashMap` is created and assigned to `offsetMap`. This implies that no offset information is available, so an empty map is a reasonable default.\n4. **Deserialization using JSON_MAPPER**: If the input string is not null or empty, it's assumed to be a JSON representation of the offset map. The `JSON_MAPPER` object (an instance of `ObjectMapper`, likely created elsewhere in the codebase) is used to deserialize the JSON string into a Java `Map`. This map is then assigned to `offsetMap`.\n5. **Return the deserialized offset map**: Finally, the method returns the `offsetMap`.\n\n**Context**\n\nThis method is likely used in a context where offset information needs to be retrieved from a JSON-formatted string and stored in a Java `Map` for further processing or storage.\n\nExample usage:\n```java\nString jsonOffset = \"{\\\"key1\\\":\\\"value1\\\",\\\"key2\\\":\\\"value2\\\"}\";\nMap offsetMap = OffsetUtil.deserializeOffsetMap(jsonOffset);\n// Use the deserialized map as needed\n```\nNote that this method assumes the presence of a `JSON_MAPPER` instance elsewhere in the codebase. If not defined, you'll need to create an instance of `ObjectMapper` (e.g., using `new ObjectMapper()`) and configure it as necessary for your specific JSON serialization requirements.", "metric": 0.19828364950316169}}], "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: Deserializing an Offset Map from a JSON String**\n\nThis Java method, `deserializeOffsetMap`, is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a string representation of an offset map (`lastSourceOffset`) as input and returns a deserialized `Map` containing the offset information.\n\n**Method Breakdown**\n\n1. **Suppression of unchecked cast warning**: The first line, `@SuppressWarnings(\"unchecked\")`, suppresses a warning that would otherwise be generated by Java due to the use of an unchecked cast.\n2. **Initialization of offset map**: A local variable `offsetMap` is declared as an instance of `Map`. This will store the deserialized offset information.\n3. **Handling null or empty input**: If the input string (`lastSourceOffset`) is either:\n\t* Null: An empty `HashMap` is created and assigned to `offsetMap`.\n\t* Empty (i.e., an empty string): An empty `HashMap` is created and assigned to `offsetMap`. This implies that no offset information is available, so an empty map is a reasonable default.\n4. **Deserialization using JSON_MAPPER**: If the input string is not null or empty, it's assumed to be a JSON representation of the offset map. The `JSON_MAPPER` object (an instance of `ObjectMapper`, likely created elsewhere in the codebase) is used to deserialize the JSON string into a Java `Map`. This map is then assigned to `offsetMap`.\n5. **Return the deserialized offset map**: Finally, the method returns the `offsetMap`.\n\n**Context**\n\nThis method is likely used in a context where offset information needs to be retrieved from a JSON-formatted string and stored in a Java `Map` for further processing or storage.\n\nExample usage:\n```java\nString jsonOffset = \"{\\\"key1\\\":\\\"value1\\\",\\\"key2\\\":\\\"value2\\\"}\";\nMap offsetMap = OffsetUtil.deserializeOffsetMap(jsonOffset);\n// Use the deserialized map as needed\n```\nNote that this method assumes the presence of a `JSON_MAPPER` instance elsewhere in the codebase. If not defined, you'll need to create an instance of `ObjectMapper` (e.g., using `new ObjectMapper()`) and configure it as necessary for your specific JSON serialization requirements.", "metric": 0.19828364950316169}} \ No newline at end of file +{"kind": "lastOf", "start_nanos": 1737481678459806000, "end_nanos": 1737481687286219000, "timezone": "EST", "description": "Code explanation example", "defs": {"CODE": {"kind": "read", "start_nanos": 1737481678459827000, "end_nanos": 1737481678461273000, "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", "start_nanos": 1737481678461284000, "end_nanos": 1737481678461799000, "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."}}, "lastOf": [{"kind": "model", "start_nanos": 1737481678461837000, "end_nanos": 1737481686919460000, "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", "def": "EXPLANATION", "contribute": [], "result": "**Code Explanation: Deserializing an Offset Map from a String**\n\nThe `deserializeOffsetMap` method is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a single string parameter, `lastSourceOffset`, which is expected to contain a JSON representation of a map.\n\nHere's what the code does:\n\n1. **Handling null or empty input**: If `lastSourceOffset` is either `null` or an empty string (`\"\"`), it creates a new empty `HashMap` and returns it.\n2. **Deserializing JSON to Map**: Otherwise, if `lastSourceOffset` contains valid JSON data, the code uses the `JSON_MAPPER` (an instance of `ObjectMapper`, likely created elsewhere in the codebase) to deserialize the JSON into a Java `Map`. The deserialization is done using the `readValue` method, which returns an object of type `Map.class`.\n3. **Returning the Map**: Regardless of whether the input was null/empty or valid JSON, the method returns the resulting `offsetMap`.\n\n**Notes**\n\n* The `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a warning about unchecked casts. In this case, it's likely because the `readValue` method returns an object of type `Map.class`, which is an interface, and the code assigns it to a variable of type `Map`.\n* The `JSON_MAPPER` instance is not shown in this snippet, but it's assumed to be a valid instance of `ObjectMapper`, which is used for JSON serialization and deserialization.\n* The method throws an `IOException` if there are issues with the input JSON data.\n\nIn summary, this method takes a string containing JSON data, attempts to deserialize it into a Java map, and returns that map. If the input is null or empty, it returns an empty map instead."}, {"kind": "code", "start_nanos": 1737481686919497000, "end_nanos": 1737481687285124000, "timezone": "EST", "defs": {}, "lang": "python", "code": "import textdistance\nexpl = \"\"\"\n**Code Explanation: Deserializing an Offset Map from a String**\n\nThe `deserializeOffsetMap` method is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a single string parameter, `lastSourceOffset`, which is expected to contain a JSON representation of a map.\n\nHere's what the code does:\n\n1. **Handling null or empty input**: If `lastSourceOffset` is either `null` or an empty string (`\"\"`), it creates a new empty `HashMap` and returns it.\n2. **Deserializing JSON to Map**: Otherwise, if `lastSourceOffset` contains valid JSON data, the code uses the `JSON_MAPPER` (an instance of `ObjectMapper`, likely created elsewhere in the codebase) to deserialize the JSON into a Java `Map`. The deserialization is done using the `readValue` method, which returns an object of type `Map.class`.\n3. **Returning the Map**: Regardless of whether the input was null/empty or valid JSON, the method returns the resulting `offsetMap`.\n\n**Notes**\n\n* The `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a warning about unchecked casts. In this case, it's likely because the `readValue` method returns an object of type `Map.class`, which is an interface, and the code assigns it to a variable of type `Map`.\n* The `JSON_MAPPER` instance is not shown in this snippet, but it's assumed to be a valid instance of `ObjectMapper`, which is used for JSON serialization and deserialization.\n* The method throws an `IOException` if there are issues with the input JSON data.\n\nIn summary, this method takes a string containing JSON data, attempts to deserialize it into a Java map, and returns that map. If the input is null or empty, it returns an empty map instead.\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\"\"\"\nresult = textdistance.levenshtein.normalized_similarity(expl, truth)\n", "def": "EVAL", "result": 0.2735242548217417}, {"kind": "data", "start_nanos": 1737481687285141000, "end_nanos": 1737481687286195000, "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: Deserializing an Offset Map from a String**\n\nThe `deserializeOffsetMap` method is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a single string parameter, `lastSourceOffset`, which is expected to contain a JSON representation of a map.\n\nHere's what the code does:\n\n1. **Handling null or empty input**: If `lastSourceOffset` is either `null` or an empty string (`\"\"`), it creates a new empty `HashMap` and returns it.\n2. **Deserializing JSON to Map**: Otherwise, if `lastSourceOffset` contains valid JSON data, the code uses the `JSON_MAPPER` (an instance of `ObjectMapper`, likely created elsewhere in the codebase) to deserialize the JSON into a Java `Map`. The deserialization is done using the `readValue` method, which returns an object of type `Map.class`.\n3. **Returning the Map**: Regardless of whether the input was null/empty or valid JSON, the method returns the resulting `offsetMap`.\n\n**Notes**\n\n* The `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a warning about unchecked casts. In this case, it's likely because the `readValue` method returns an object of type `Map.class`, which is an interface, and the code assigns it to a variable of type `Map`.\n* The `JSON_MAPPER` instance is not shown in this snippet, but it's assumed to be a valid instance of `ObjectMapper`, which is used for JSON serialization and deserialization.\n* The method throws an `IOException` if there are issues with the input JSON data.\n\nIn summary, this method takes a string containing JSON data, attempts to deserialize it into a Java map, and returns that map. If the input is null or empty, it returns an empty map instead.", "metric": 0.2735242548217417}, "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: Deserializing an Offset Map from a String**\n\nThe `deserializeOffsetMap` method is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a single string parameter, `lastSourceOffset`, which is expected to contain a JSON representation of a map.\n\nHere's what the code does:\n\n1. **Handling null or empty input**: If `lastSourceOffset` is either `null` or an empty string (`\"\"`), it creates a new empty `HashMap` and returns it.\n2. **Deserializing JSON to Map**: Otherwise, if `lastSourceOffset` contains valid JSON data, the code uses the `JSON_MAPPER` (an instance of `ObjectMapper`, likely created elsewhere in the codebase) to deserialize the JSON into a Java `Map`. The deserialization is done using the `readValue` method, which returns an object of type `Map.class`.\n3. **Returning the Map**: Regardless of whether the input was null/empty or valid JSON, the method returns the resulting `offsetMap`.\n\n**Notes**\n\n* The `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a warning about unchecked casts. In this case, it's likely because the `readValue` method returns an object of type `Map.class`, which is an interface, and the code assigns it to a variable of type `Map`.\n* The `JSON_MAPPER` instance is not shown in this snippet, but it's assumed to be a valid instance of `ObjectMapper`, which is used for JSON serialization and deserialization.\n* The method throws an `IOException` if there are issues with the input JSON data.\n\nIn summary, this method takes a string containing JSON data, attempts to deserialize it into a Java map, and returns that map. If the input is null or empty, it returns an empty map instead.", "metric": 0.2735242548217417}}], "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: Deserializing an Offset Map from a String**\n\nThe `deserializeOffsetMap` method is part of the `OffsetUtil` class in the `streamsets/datacollector` repository. It takes a single string parameter, `lastSourceOffset`, which is expected to contain a JSON representation of a map.\n\nHere's what the code does:\n\n1. **Handling null or empty input**: If `lastSourceOffset` is either `null` or an empty string (`\"\"`), it creates a new empty `HashMap` and returns it.\n2. **Deserializing JSON to Map**: Otherwise, if `lastSourceOffset` contains valid JSON data, the code uses the `JSON_MAPPER` (an instance of `ObjectMapper`, likely created elsewhere in the codebase) to deserialize the JSON into a Java `Map`. The deserialization is done using the `readValue` method, which returns an object of type `Map.class`.\n3. **Returning the Map**: Regardless of whether the input was null/empty or valid JSON, the method returns the resulting `offsetMap`.\n\n**Notes**\n\n* The `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a warning about unchecked casts. In this case, it's likely because the `readValue` method returns an object of type `Map.class`, which is an interface, and the code assigns it to a variable of type `Map`.\n* The `JSON_MAPPER` instance is not shown in this snippet, but it's assumed to be a valid instance of `ObjectMapper`, which is used for JSON serialization and deserialization.\n* The method throws an `IOException` if there are issues with the input JSON data.\n\nIn summary, this method takes a string containing JSON data, attempts to deserialize it into a Java map, and returns that map. If the input is null or empty, it returns an empty map instead.", "metric": 0.2735242548217417}} \ 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 a06f7509..9e140351 100644 --- a/pdl-live-react/src/demos/demo6.json +++ b/pdl-live-react/src/demos/demo6.json @@ -1 +1 @@ -{"kind": "error", "description": "Error Handling", "defs": {}, "program": {"kind": "read", "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:\ndemos/error.pdl:3 - Missing required field: questions\ndemos/error.pdl:3 - Missing required field: answers\ndemos/error.pdl:3 - Field not allowed: source_code\ndemos/error.pdl:3 - Field not allowed: repo_info"} +{"kind": "error", "description": "Error Handling", "defs": {}, "program": {"kind": "read", "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/nickm/git/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Missing required field: questions\n/Users/nickm/git/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Missing required field: answers\n/Users/nickm/git/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Field not allowed: source_code\n/Users/nickm/git/prompt-declaration-language/pdl-live-react/demos/../demos/error.pdl:3 - Field not allowed: repo_info"} diff --git a/pdl-live-react/src/demos/demo7.json b/pdl-live-react/src/demos/demo7.json index 2c37874a..196b4a89 100644 --- a/pdl-live-react/src/demos/demo7.json +++ b/pdl-live-react/src/demos/demo7.json @@ -1 +1 @@ -{"kind": "text", "description": "Function call", "defs": {}, "text": [{"kind": "function", "defs": {}, "function": {"sentence": "str", "language": "str"}, "return": {"kind": "lastOf", "defs": {}, "lastOf": ["\nTranslate the sentence '${ sentence }' to ${ language }.\n", {"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop_sequences": "\n"}}]}, "def": "translate", "result": ""}, {"kind": "call", "defs": {}, "call": "${ translate }", "args": {"sentence": "I love Paris!", "language": "French"}, "trace": {"kind": "lastOf", "defs": {}, "lastOf": ["\nTranslate the sentence 'I love Paris!' to French.\n", {"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop_sequences": "\n"}, "result": "### Translator\n\nThe translation of \"I love Paris!\" in French is: \n\n\"J'adore Paris!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Je t'aime bien Paris!\""}], "result": "### Translator\n\nThe translation of \"I love Paris!\" in French is: \n\n\"J'adore Paris!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Je t'aime bien Paris!\""}, "result": "### Translator\n\nThe translation of \"I love Paris!\" in French is: \n\n\"J'adore Paris!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Je t'aime bien Paris!\""}, "\n", {"kind": "call", "defs": {}, "call": "${ translate }", "args": {"sentence": "I love Madrid!", "language": "Spanish"}, "trace": {"kind": "lastOf", "defs": {}, "lastOf": ["\nTranslate the sentence 'I love Madrid!' to Spanish.\n", {"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop_sequences": "\n"}, "result": "The translation of \"I love Madrid!\" in Spanish is:\n\n\"Me encanta Madrid!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Me gusta Madrid\"\n\nHowever, if you want to express a stronger affection or passion for Madrid, you could use:\n\n\"Me encanta mucho Madrid!\""}], "result": "The translation of \"I love Madrid!\" in Spanish is:\n\n\"Me encanta Madrid!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Me gusta Madrid\"\n\nHowever, if you want to express a stronger affection or passion for Madrid, you could use:\n\n\"Me encanta mucho Madrid!\""}, "result": "The translation of \"I love Madrid!\" in Spanish is:\n\n\"Me encanta Madrid!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Me gusta Madrid\"\n\nHowever, if you want to express a stronger affection or passion for Madrid, you could use:\n\n\"Me encanta mucho Madrid!\""}], "result": "### Translator\n\nThe translation of \"I love Paris!\" in French is: \n\n\"J'adore Paris!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Je t'aime bien Paris!\"\nThe translation of \"I love Madrid!\" in Spanish is:\n\n\"Me encanta Madrid!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Me gusta Madrid\"\n\nHowever, if you want to express a stronger affection or passion for Madrid, you could use:\n\n\"Me encanta mucho Madrid!\""} +{"kind": "text", "start_nanos": 1737481750846912000, "end_nanos": 1737481754327780000, "timezone": "EST", "description": "Function def and call", "defs": {}, "text": [{"kind": "function", "start_nanos": 1737481750846956000, "end_nanos": 1737481750847004000, "timezone": "EST", "defs": {}, "function": {"sentence": "str", "language": "str"}, "return": {"kind": "lastOf", "defs": {}, "lastOf": ["\nTranslate the sentence '${ sentence }' to ${ language }.\n", {"kind": "model", "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop_sequences": "\n"}}]}, "def": "translate", "result": ""}, {"kind": "call", "start_nanos": 1737481750847011000, "end_nanos": 1737481752439246000, "timezone": "EST", "defs": {}, "call": "${ translate }", "args": {"sentence": "I love Paris!", "language": "French"}, "trace": {"kind": "lastOf", "start_nanos": 1737481750849019000, "end_nanos": 1737481752439227000, "timezone": "EST", "defs": {}, "lastOf": ["\nTranslate the sentence 'I love Paris!' to French.\n", {"kind": "model", "start_nanos": 1737481750849457000, "end_nanos": 1737481752439203000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop_sequences": "\n"}, "result": "### Translator\n\nThe translation of \"I love Paris!\" in French is: \n\n\"J'adore Paris!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Je t'aime bien Paris!\""}], "result": "### Translator\n\nThe translation of \"I love Paris!\" in French is: \n\n\"J'adore Paris!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Je t'aime bien Paris!\""}, "result": "### Translator\n\nThe translation of \"I love Paris!\" in French is: \n\n\"J'adore Paris!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Je t'aime bien Paris!\""}, "\n", {"kind": "call", "start_nanos": 1737481752439702000, "end_nanos": 1737481754327755000, "timezone": "EST", "defs": {}, "call": "${ translate }", "args": {"sentence": "I love Madrid!", "language": "Spanish"}, "trace": {"kind": "lastOf", "start_nanos": 1737481752440992000, "end_nanos": 1737481754327738000, "timezone": "EST", "defs": {}, "lastOf": ["\nTranslate the sentence 'I love Madrid!' to Spanish.\n", {"kind": "model", "start_nanos": 1737481752441405000, "end_nanos": 1737481754327716000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/llama3.1:8b", "parameters": {"temperature": 0.0, "stop_sequences": "\n"}, "result": "The translation of \"I love Madrid!\" in Spanish is:\n\n\"Me encanta Madrid!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Me gusta Madrid\"\n\nHowever, if you want to express a stronger affection or passion for Madrid, you could use:\n\n\"Me encanta mucho Madrid!\""}], "result": "The translation of \"I love Madrid!\" in Spanish is:\n\n\"Me encanta Madrid!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Me gusta Madrid\"\n\nHowever, if you want to express a stronger affection or passion for Madrid, you could use:\n\n\"Me encanta mucho Madrid!\""}, "result": "The translation of \"I love Madrid!\" in Spanish is:\n\n\"Me encanta Madrid!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Me gusta Madrid\"\n\nHowever, if you want to express a stronger affection or passion for Madrid, you could use:\n\n\"Me encanta mucho Madrid!\""}], "result": "### Translator\n\nThe translation of \"I love Paris!\" in French is: \n\n\"J'adore Paris!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Je t'aime bien Paris!\"\nThe translation of \"I love Madrid!\" in Spanish is:\n\n\"Me encanta Madrid!\"\n\nThis uses the formal form of \"to love\", which is suitable for most situations. If you want to use the informal form, it would be:\n\n\"Me gusta Madrid\"\n\nHowever, if you want to express a stronger affection or passion for Madrid, you could use:\n\n\"Me encanta mucho Madrid!\""} diff --git a/pdl-live-react/src/helpers.ts b/pdl-live-react/src/helpers.ts index 8d3dcd45..3742a1c3 100644 --- a/pdl-live-react/src/helpers.ts +++ b/pdl-live-react/src/helpers.ts @@ -1,6 +1,6 @@ import { type ReactElement } from "react" -import type { BamModelBlock, PdlBlock, TextBlock } from "./pdl_ast" +import type { LitellmModelBlock, PdlBlock, TextBlock } from "./pdl_ast" /** Re-export for convenience */ export { type PdlBlock } from "./pdl_ast" @@ -13,6 +13,12 @@ export type PdlBlockWithResult = NonScalarPdlBlock & { result: NonNullable } +export type PdlBlockWithTiming = NonScalarPdlBlock & { + start_nanos: number + end_nanos: number + timezone: string +} + /** Does the given block have a `result` field? */ export function hasResult(block: PdlBlock): block is PdlBlockWithResult { return ( @@ -36,11 +42,15 @@ export function isPdlBlock( ) } +export function isNonScalarPdlBlock(data: PdlBlock): data is NonScalarPdlBlock { + return data != null && typeof data === "object" +} + /** Does the given block have a `parser` field? */ export function hasParser( data: PdlBlock, ): data is NonScalarPdlBlock & { parser: import("./pdl_ast").Parser } { - return data != null && typeof data === "object" && "result" in data + return isNonScalarPdlBlock(data) && "result" in data } const markdownPattern = /`/ @@ -80,8 +90,8 @@ export function isTextBlockWithArrayContent( } /** Does the given block represent an LLM interaction? */ -export function isLLMBlock(data: PdlBlock): data is BamModelBlock { - return (data as BamModelBlock).kind === "model" +export function isLLMBlock(data: PdlBlock): data is LitellmModelBlock { + return (data as LitellmModelBlock).kind === "model" } /** Does the given block have a `result` field? of type string */ @@ -113,3 +123,15 @@ export function firstLineOf(s: string) { export function nonNullable(value: T): value is NonNullable { return value !== null && value !== undefined } + +/** Does the given block have timing information? */ +export function hasTimingInformation( + block: PdlBlock, +): block is PdlBlockWithTiming { + return ( + isNonScalarPdlBlock(block) && + typeof block.start_nanos === "number" && + typeof block.end_nanos === "number" && + typeof block.timezone === "string" + ) +} diff --git a/pdl-live-react/src/pdl_ast.d.ts b/pdl-live-react/src/pdl_ast.d.ts index 72cd1b4c..7aa4c066 100644 --- a/pdl-live-react/src/pdl_ast.d.ts +++ b/pdl-live-react/src/pdl_ast.d.ts @@ -1,3 +1,4 @@ +/* eslint-disable */ /** * This file was automatically generated by json-schema-to-typescript. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, @@ -15,7 +16,6 @@ export type Program = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -128,11 +128,6 @@ export type Description17 = string | null * */ export type Description18 = string | null -/** - * Documentation associated to the block. - * - */ -export type Description19 = string | null /** * Name of the variable used to store the result of the execution of the block. * @@ -158,8 +153,8 @@ export type Parser = | PdlParser | RegexParser | null -export type Description20 = string | null -export type Spec20 = { +export type Description19 = string | null +export type Spec19 = { [k: string]: unknown } | null export type Pdl = @@ -169,7 +164,6 @@ export type Pdl = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -187,8 +181,8 @@ export type Pdl = | ErrorBlock | EmptyBlock | null -export type Description21 = string | null -export type Spec21 = { +export type Description20 = string | null +export type Spec20 = { [k: string]: unknown } | null export type Regex = string @@ -204,7 +198,6 @@ export type Fallback = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -227,6 +220,21 @@ export type Fallback = * */ export type Role = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone = string | null export type Path = string[] export type File = string export type Kind = "empty" @@ -264,7 +272,6 @@ export type Fallback1 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -287,6 +294,21 @@ export type Fallback1 = * */ export type Role1 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos1 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos1 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone1 = string | null export type Kind1 = "error" export type Msg = string export type Program1 = @@ -296,7 +318,6 @@ export type Program1 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -348,7 +369,6 @@ export type Fallback2 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -371,6 +391,21 @@ export type Fallback2 = * */ export type Role2 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos2 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos2 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone2 = string | null export type Kind2 = "include" /** * Name of the file to include. @@ -384,7 +419,6 @@ export type Trace = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -436,7 +470,6 @@ export type Fallback3 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -459,6 +492,21 @@ export type Fallback3 = * */ export type Role3 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos3 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos3 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone3 = string | null export type Kind3 = "read" /** * Message to prompt the user to enter a value. @@ -504,7 +552,6 @@ export type Fallback4 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -526,6 +573,21 @@ export type Fallback4 = * Role of associated to the message. */ export type Role4 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos4 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos4 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone4 = string | null export type Kind4 = "message" /** * Content of the message. @@ -537,7 +599,6 @@ export type Content = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -589,7 +650,6 @@ export type Fallback5 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -612,6 +672,21 @@ export type Fallback5 = * */ export type Role5 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos5 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos5 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone5 = string | null export type Kind5 = "object" export type Object = | { @@ -622,7 +697,6 @@ export type Object = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -648,7 +722,6 @@ export type Object = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -701,7 +774,6 @@ export type Fallback6 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -724,6 +796,21 @@ export type Fallback6 = * */ export type Role6 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos6 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos6 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone6 = string | null export type Kind6 = "array" export type Array = ( | boolean @@ -732,7 +819,6 @@ export type Array = ( | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -785,7 +871,6 @@ export type Fallback7 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -808,6 +893,21 @@ export type Fallback7 = * */ export type Role7 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos7 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos7 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone7 = string | null export type Kind7 = "lastOf" export type Lastof = ( | boolean @@ -816,7 +916,6 @@ export type Lastof = ( | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -869,7 +968,6 @@ export type Fallback8 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -892,6 +990,21 @@ export type Fallback8 = * */ export type Role8 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos8 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos8 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone8 = string | null export type Kind8 = "text" /** * Body of the text. @@ -904,7 +1017,6 @@ export type Text = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -928,7 +1040,6 @@ export type Text = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -982,7 +1093,6 @@ export type Fallback9 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1005,6 +1115,21 @@ export type Fallback9 = * */ export type Role9 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos9 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos9 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone9 = string | null export type Kind9 = "for" /** * Body of the loop. @@ -1017,7 +1142,6 @@ export type Repeat = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1068,7 +1192,6 @@ export type Trace1 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1122,7 +1245,6 @@ export type Fallback10 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1145,6 +1267,21 @@ export type Fallback10 = * */ export type Role10 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos10 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos10 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone10 = string | null export type Kind10 = "repeat_until" /** * Body of the loop. @@ -1157,7 +1294,6 @@ export type Repeat1 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1188,7 +1324,6 @@ export type Trace2 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1242,7 +1377,6 @@ export type Fallback11 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1265,6 +1399,21 @@ export type Fallback11 = * */ export type Role11 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos11 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos11 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone11 = string | null export type Kind11 = "repeat" /** * Body of the loop. @@ -1277,7 +1426,6 @@ export type Repeat2 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1313,7 +1461,6 @@ export type Trace3 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1367,7 +1514,6 @@ export type Fallback12 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1390,6 +1536,21 @@ export type Fallback12 = * */ export type Role12 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos12 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos12 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone12 = string | null export type Kind12 = "if" /** * Branch to exectute if the condition is true. @@ -1402,7 +1563,6 @@ export type Then = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1431,7 +1591,6 @@ export type Else = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1484,7 +1643,6 @@ export type Fallback13 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1507,6 +1665,21 @@ export type Fallback13 = * */ export type Role13 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos13 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos13 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone13 = string | null export type Kind13 = "data" /** * Do not evaluate expressions inside strings. @@ -1546,7 +1719,6 @@ export type Fallback14 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1569,6 +1741,21 @@ export type Fallback14 = * */ export type Role14 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos14 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos14 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone14 = string | null export type Kind14 = "get" /** * Name of the variable to access. @@ -1608,7 +1795,6 @@ export type Fallback15 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1631,6 +1817,21 @@ export type Fallback15 = * */ export type Role15 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos15 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos15 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone15 = string | null export type Kind15 = "code" /** * Programming language of the code. @@ -1648,7 +1849,6 @@ export type Code = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1700,7 +1900,6 @@ export type Fallback16 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1723,6 +1922,21 @@ export type Fallback16 = * */ export type Role16 = string | null +/** + * Time at which block execution began + * + */ +export type StartNanos16 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos16 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone16 = string | null export type Kind16 = "model" export type Input = | boolean @@ -1731,7 +1945,6 @@ export type Input = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1756,7 +1969,6 @@ export type Trace4 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1775,28 +1987,7 @@ export type Trace4 = | EmptyBlock | null export type Modelresponse = string | null -export type Platform = "bam" -export type PromptId = string | null -export type Enabled = boolean | null -export type SendTokens = boolean | null -export type Threshold = number | null -export type Enabled1 = boolean | null -export type SendTokens1 = boolean | null -export type Threshold1 = number | null -export type Enabled2 = boolean | null -export type SendTokens2 = boolean | null -export type Threshold2 = number | null -export type Enabled3 = boolean | null -export type SendTokens3 = boolean | null -export type Threshold3 = number | null -export type ExampleFileIds = - | [] - | [string] - | [string, string] - | [string, string, string] - | [string, string, string, string] - | [string, string, string, string, string] - | null +export type Platform = "litellm" /** * Name of the variable used to store the result of the execution of the block. * @@ -1831,7 +2022,6 @@ export type Fallback17 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1854,32 +2044,22 @@ export type Fallback17 = * */ export type Role17 = string | null -export type Kind17 = "model" -export type Input1 = - | boolean - | number - | string - | FunctionBlock - | CallBlock - | LitellmModelBlock - | BamModelBlock - | CodeBlock - | GetBlock - | DataBlock - | IfBlock - | RepeatBlock - | RepeatUntilBlock - | ForBlock - | TextBlock - | LastOfBlock - | ArrayBlock - | ObjectBlock - | MessageBlock - | ReadBlock - | IncludeBlock - | ErrorBlock - | EmptyBlock - | null +/** + * Time at which block execution began + * + */ +export type StartNanos17 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos17 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone17 = string | null +export type Kind17 = "call" export type Trace5 = | boolean | number @@ -1887,7 +2067,6 @@ export type Trace5 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1905,8 +2084,6 @@ export type Trace5 = | ErrorBlock | EmptyBlock | null -export type Modelresponse1 = string | null -export type Platform1 = "litellm" /** * Name of the variable used to store the result of the execution of the block. * @@ -1941,7 +2118,6 @@ export type Fallback18 = | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1964,15 +2140,40 @@ export type Fallback18 = * */ export type Role18 = string | null -export type Kind18 = "call" -export type Trace6 = +/** + * Time at which block execution began + * + */ +export type StartNanos18 = number | null +/** + * Time at which block execution ended + * + */ +export type EndNanos18 = number | null +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone18 = string | null +export type Kind18 = "function" +/** + * Functions parameters with their types. + * + */ +export type Function = { + [k: string]: unknown +} | null +/** + * Body of the function + * + */ +export type Return = | boolean | number | string | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -1990,41 +2191,16 @@ export type Trace6 = | ErrorBlock | EmptyBlock | null -/** - * Name of the variable used to store the result of the execution of the block. - * - */ -export type Def19 = string | null -/** - * Indicate if the block contributes to the result and background context. - * - */ -export type Contribute19 = ( - | ContributeTarget - | { - [k: string]: ContributeValue - } -)[] -/** - * Parser to use to construct a value out of a string result. - */ -export type Parser19 = - | ("json" | "jsonl" | "yaml") - | PdlParser - | RegexParser - | null -/** - * Block to execute in case of error. - * - */ -export type Fallback19 = +export type Scope = { + [k: string]: unknown +} | null +export type PdlBlock = | boolean | number | string | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2042,92 +2218,25 @@ export type Fallback19 = | ErrorBlock | EmptyBlock | null + /** - * Role associated to the block and sub-blocks. - * - */ -export type Role19 = string | null -export type Kind19 = "function" -/** - * Functions parameters with their types. - * - */ -export type Function = { - [k: string]: unknown -} | null -/** - * Body of the function - * - */ -export type Return = - | boolean - | number - | string - | FunctionBlock - | CallBlock - | LitellmModelBlock - | BamModelBlock - | CodeBlock - | GetBlock - | DataBlock - | IfBlock - | RepeatBlock - | RepeatUntilBlock - | ForBlock - | TextBlock - | LastOfBlock - | ArrayBlock - | ObjectBlock - | MessageBlock - | ReadBlock - | IncludeBlock - | ErrorBlock - | EmptyBlock - | null -export type Scope = { - [k: string]: unknown -} | null -export type PdlBlock = - | boolean - | number - | string - | FunctionBlock - | CallBlock - | LitellmModelBlock - | BamModelBlock - | CodeBlock - | GetBlock - | DataBlock - | IfBlock - | RepeatBlock - | RepeatUntilBlock - | ForBlock - | TextBlock - | LastOfBlock - | ArrayBlock - | ObjectBlock - | MessageBlock - | ReadBlock - | IncludeBlock - | ErrorBlock - | EmptyBlock - | null - -/** - * Function declaration. + * Function declaration. */ export interface FunctionBlock { description?: Description spec?: Spec defs?: Defs - def?: Def19 - contribute?: Contribute19 - parser?: Parser19 - fallback?: Fallback19 - role?: Role19 + def?: Def18 + contribute?: Contribute18 + parser?: Parser18 + fallback?: Fallback18 + role?: Role18 + start_nanos?: StartNanos18 + end_nanos?: EndNanos18 + timezone?: Timezone18 result?: unknown location?: LocationType | null - kind?: Kind19 + kind?: Kind18 function: Function return: Return scope?: Scope @@ -2151,7 +2260,6 @@ export interface Defs { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2177,17 +2285,20 @@ export interface CallBlock { description?: Description1 spec?: Spec1 defs?: Defs1 - def?: Def18 - contribute?: Contribute18 - parser?: Parser18 - fallback?: Fallback18 - role?: Role18 + def?: Def17 + contribute?: Contribute17 + parser?: Parser17 + fallback?: Fallback17 + role?: Role17 + start_nanos?: StartNanos17 + end_nanos?: EndNanos17 + timezone?: Timezone17 result?: unknown location?: LocationType | null - kind?: Kind18 + kind?: Kind17 call: unknown - args?: Args - trace?: Trace6 + args?: unknown + trace?: Trace5 } /** * Type specification of the result of the block. @@ -2208,7 +2319,6 @@ export interface Defs1 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2234,68 +2344,14 @@ export interface LitellmModelBlock { description?: Description2 spec?: Spec2 defs?: Defs2 - def?: Def17 - contribute?: Contribute17 - parser?: Parser17 - fallback?: Fallback17 - role?: Role17 - result?: unknown - location?: LocationType | null - kind?: Kind17 - model: unknown - input?: Input1 - trace?: Trace5 - modelResponse?: Modelresponse1 - platform?: Platform1 - parameters?: unknown -} -/** - * Type specification of the result of the block. - * - */ -export interface Spec2 { - [k: string]: unknown -} -/** - * Set of definitions executed before the execution of the block. - * - */ -export interface Defs2 { - [k: string]: - | boolean - | number - | string - | FunctionBlock - | CallBlock - | LitellmModelBlock - | BamModelBlock - | CodeBlock - | GetBlock - | DataBlock - | IfBlock - | RepeatBlock - | RepeatUntilBlock - | ForBlock - | TextBlock - | LastOfBlock - | ArrayBlock - | ObjectBlock - | MessageBlock - | ReadBlock - | IncludeBlock - | ErrorBlock - | EmptyBlock - | null -} -export interface BamModelBlock { - description?: Description3 - spec?: Spec3 - defs?: Defs3 def?: Def16 contribute?: Contribute16 parser?: Parser16 fallback?: Fallback16 role?: Role16 + start_nanos?: StartNanos16 + end_nanos?: EndNanos16 + timezone?: Timezone16 result?: unknown location?: LocationType | null kind?: Kind16 @@ -2303,25 +2359,21 @@ export interface BamModelBlock { input?: Input trace?: Trace4 modelResponse?: Modelresponse - platform: Platform - prompt_id?: PromptId + platform?: Platform parameters?: unknown - moderations?: ModerationParameters | null - data?: PromptTemplateData | null - constraints?: Constraints } /** * Type specification of the result of the block. * */ -export interface Spec3 { +export interface Spec2 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs3 { +export interface Defs2 { [k: string]: | boolean | number @@ -2329,7 +2381,6 @@ export interface Defs3 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2352,14 +2403,17 @@ export interface Defs3 { * Execute a piece of code. */ export interface CodeBlock { - description?: Description4 - spec?: Spec4 - defs?: Defs4 + description?: Description3 + spec?: Spec3 + defs?: Defs3 def?: Def15 contribute?: Contribute15 parser?: Parser15 fallback?: Fallback15 role?: Role15 + start_nanos?: StartNanos15 + end_nanos?: EndNanos15 + timezone?: Timezone15 result?: unknown location?: LocationType | null kind?: Kind15 @@ -2370,14 +2424,14 @@ export interface CodeBlock { * Type specification of the result of the block. * */ -export interface Spec4 { +export interface Spec3 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs4 { +export interface Defs3 { [k: string]: | boolean | number @@ -2385,7 +2439,6 @@ export interface Defs4 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2408,14 +2461,17 @@ export interface Defs4 { * Get the value of a variable. */ export interface GetBlock { - description?: Description5 - spec?: Spec5 - defs?: Defs5 + description?: Description4 + spec?: Spec4 + defs?: Defs4 def?: Def14 contribute?: Contribute14 parser?: Parser14 fallback?: Fallback14 role?: Role14 + start_nanos?: StartNanos14 + end_nanos?: EndNanos14 + timezone?: Timezone14 result?: unknown location?: LocationType | null kind?: Kind14 @@ -2425,14 +2481,14 @@ export interface GetBlock { * Type specification of the result of the block. * */ -export interface Spec5 { +export interface Spec4 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs5 { +export interface Defs4 { [k: string]: | boolean | number @@ -2440,7 +2496,6 @@ export interface Defs5 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2463,14 +2518,17 @@ export interface Defs5 { * Arbitrary JSON value. */ export interface DataBlock { - description?: Description6 - spec?: Spec6 - defs?: Defs6 + description?: Description5 + spec?: Spec5 + defs?: Defs5 def?: Def13 contribute?: Contribute13 parser?: Parser13 fallback?: Fallback13 role?: Role13 + start_nanos?: StartNanos13 + end_nanos?: EndNanos13 + timezone?: Timezone13 result?: unknown location?: LocationType | null kind?: Kind13 @@ -2481,14 +2539,14 @@ export interface DataBlock { * Type specification of the result of the block. * */ -export interface Spec6 { +export interface Spec5 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs6 { +export interface Defs5 { [k: string]: | boolean | number @@ -2496,7 +2554,6 @@ export interface Defs6 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2519,14 +2576,17 @@ export interface Defs6 { * Conditional control structure. */ export interface IfBlock { - description?: Description7 - spec?: Spec7 - defs?: Defs7 + description?: Description6 + spec?: Spec6 + defs?: Defs6 def?: Def12 contribute?: Contribute12 parser?: Parser12 fallback?: Fallback12 role?: Role12 + start_nanos?: StartNanos12 + end_nanos?: EndNanos12 + timezone?: Timezone12 result?: unknown location?: LocationType | null kind?: Kind12 @@ -2539,14 +2599,14 @@ export interface IfBlock { * Type specification of the result of the block. * */ -export interface Spec7 { +export interface Spec6 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs7 { +export interface Defs6 { [k: string]: | boolean | number @@ -2554,7 +2614,6 @@ export interface Defs7 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2577,14 +2636,17 @@ export interface Defs7 { * Repeat the execution of a block for a fixed number of iterations. */ export interface RepeatBlock { - description?: Description8 - spec?: Spec8 - defs?: Defs8 + description?: Description7 + spec?: Spec7 + defs?: Defs7 def?: Def11 contribute?: Contribute11 parser?: Parser11 fallback?: Fallback11 role?: Role11 + start_nanos?: StartNanos11 + end_nanos?: EndNanos11 + timezone?: Timezone11 result?: unknown location?: LocationType | null kind?: Kind11 @@ -2597,14 +2659,14 @@ export interface RepeatBlock { * Type specification of the result of the block. * */ -export interface Spec8 { +export interface Spec7 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs8 { +export interface Defs7 { [k: string]: | boolean | number @@ -2612,7 +2674,6 @@ export interface Defs8 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2635,14 +2696,17 @@ export interface Defs8 { * Repeat the execution of a block until a condition is satisfied. */ export interface RepeatUntilBlock { - description?: Description9 - spec?: Spec9 - defs?: Defs9 + description?: Description8 + spec?: Spec8 + defs?: Defs8 def?: Def10 contribute?: Contribute10 parser?: Parser10 fallback?: Fallback10 role?: Role10 + start_nanos?: StartNanos10 + end_nanos?: EndNanos10 + timezone?: Timezone10 result?: unknown location?: LocationType | null kind?: Kind10 @@ -2655,14 +2719,14 @@ export interface RepeatUntilBlock { * Type specification of the result of the block. * */ -export interface Spec9 { +export interface Spec8 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs9 { +export interface Defs8 { [k: string]: | boolean | number @@ -2670,7 +2734,6 @@ export interface Defs9 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2693,14 +2756,17 @@ export interface Defs9 { * Iteration over arrays. */ export interface ForBlock { - description?: Description10 - spec?: Spec10 - defs?: Defs10 + description?: Description9 + spec?: Spec9 + defs?: Defs9 def?: Def9 contribute?: Contribute9 parser?: Parser9 fallback?: Fallback9 role?: Role9 + start_nanos?: StartNanos9 + end_nanos?: EndNanos9 + timezone?: Timezone9 result?: unknown location?: LocationType | null kind?: Kind9 @@ -2713,14 +2779,14 @@ export interface ForBlock { * Type specification of the result of the block. * */ -export interface Spec10 { +export interface Spec9 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs10 { +export interface Defs9 { [k: string]: | boolean | number @@ -2728,7 +2794,6 @@ export interface Defs10 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2751,14 +2816,17 @@ export interface Defs10 { * Create the concatenation of the stringify version of the result of each block of the list of blocks. */ export interface TextBlock { - description?: Description11 - spec?: Spec11 - defs?: Defs11 + description?: Description10 + spec?: Spec10 + defs?: Defs10 def?: Def8 contribute?: Contribute8 parser?: Parser8 fallback?: Fallback8 role?: Role8 + start_nanos?: StartNanos8 + end_nanos?: EndNanos8 + timezone?: Timezone8 result?: unknown location?: LocationType | null kind?: Kind8 @@ -2768,14 +2836,14 @@ export interface TextBlock { * Type specification of the result of the block. * */ -export interface Spec11 { +export interface Spec10 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs11 { +export interface Defs10 { [k: string]: | boolean | number @@ -2783,7 +2851,6 @@ export interface Defs11 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2806,14 +2873,17 @@ export interface Defs11 { * Return the value of the last block if the list of blocks. */ export interface LastOfBlock { - description?: Description12 - spec?: Spec12 - defs?: Defs12 + description?: Description11 + spec?: Spec11 + defs?: Defs11 def?: Def7 contribute?: Contribute7 parser?: Parser7 fallback?: Fallback7 role?: Role7 + start_nanos?: StartNanos7 + end_nanos?: EndNanos7 + timezone?: Timezone7 result?: unknown location?: LocationType | null kind?: Kind7 @@ -2823,14 +2893,14 @@ export interface LastOfBlock { * Type specification of the result of the block. * */ -export interface Spec12 { +export interface Spec11 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs12 { +export interface Defs11 { [k: string]: | boolean | number @@ -2838,7 +2908,6 @@ export interface Defs12 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2861,14 +2930,17 @@ export interface Defs12 { * Return the array of values computed by each block of the list of blocks. */ export interface ArrayBlock { - description?: Description13 - spec?: Spec13 - defs?: Defs13 + description?: Description12 + spec?: Spec12 + defs?: Defs12 def?: Def6 contribute?: Contribute6 parser?: Parser6 fallback?: Fallback6 role?: Role6 + start_nanos?: StartNanos6 + end_nanos?: EndNanos6 + timezone?: Timezone6 result?: unknown location?: LocationType | null kind?: Kind6 @@ -2878,14 +2950,14 @@ export interface ArrayBlock { * Type specification of the result of the block. * */ -export interface Spec13 { +export interface Spec12 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs13 { +export interface Defs12 { [k: string]: | boolean | number @@ -2893,7 +2965,6 @@ export interface Defs13 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2916,14 +2987,17 @@ export interface Defs13 { * Return the object where the value of each field is defined by a block. If the body of the object is an array, the resulting object is the union of the objects computed by each element of the array. */ export interface ObjectBlock { - description?: Description14 - spec?: Spec14 - defs?: Defs14 + description?: Description13 + spec?: Spec13 + defs?: Defs13 def?: Def5 contribute?: Contribute5 parser?: Parser5 fallback?: Fallback5 role?: Role5 + start_nanos?: StartNanos5 + end_nanos?: EndNanos5 + timezone?: Timezone5 result?: unknown location?: LocationType | null kind?: Kind5 @@ -2933,14 +3007,14 @@ export interface ObjectBlock { * Type specification of the result of the block. * */ -export interface Spec14 { +export interface Spec13 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs14 { +export interface Defs13 { [k: string]: | boolean | number @@ -2948,7 +3022,6 @@ export interface Defs14 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -2971,14 +3044,17 @@ export interface Defs14 { * Create a message. */ export interface MessageBlock { - description?: Description15 - spec?: Spec15 - defs?: Defs15 + description?: Description14 + spec?: Spec14 + defs?: Defs14 def?: Def4 contribute?: Contribute4 parser?: Parser4 fallback?: Fallback4 role: Role4 + start_nanos?: StartNanos4 + end_nanos?: EndNanos4 + timezone?: Timezone4 result?: unknown location?: LocationType | null kind?: Kind4 @@ -2988,14 +3064,14 @@ export interface MessageBlock { * Type specification of the result of the block. * */ -export interface Spec15 { +export interface Spec14 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs15 { +export interface Defs14 { [k: string]: | boolean | number @@ -3003,7 +3079,6 @@ export interface Defs15 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -3026,14 +3101,17 @@ export interface Defs15 { * Read from a file or standard input. */ export interface ReadBlock { - description?: Description16 - spec?: Spec16 - defs?: Defs16 + description?: Description15 + spec?: Spec15 + defs?: Defs15 def?: Def3 contribute?: Contribute3 parser?: Parser3 fallback?: Fallback3 role?: Role3 + start_nanos?: StartNanos3 + end_nanos?: EndNanos3 + timezone?: Timezone3 result?: unknown location?: LocationType | null kind?: Kind3 @@ -3045,14 +3123,14 @@ export interface ReadBlock { * Type specification of the result of the block. * */ -export interface Spec16 { +export interface Spec15 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs16 { +export interface Defs15 { [k: string]: | boolean | number @@ -3060,7 +3138,6 @@ export interface Defs16 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -3083,14 +3160,17 @@ export interface Defs16 { * Include a PDL file. */ export interface IncludeBlock { - description?: Description17 - spec?: Spec17 - defs?: Defs17 + description?: Description16 + spec?: Spec16 + defs?: Defs16 def?: Def2 contribute?: Contribute2 parser?: Parser2 fallback?: Fallback2 role?: Role2 + start_nanos?: StartNanos2 + end_nanos?: EndNanos2 + timezone?: Timezone2 result?: unknown location?: LocationType | null kind?: Kind2 @@ -3101,14 +3181,14 @@ export interface IncludeBlock { * Type specification of the result of the block. * */ -export interface Spec17 { +export interface Spec16 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs17 { +export interface Defs16 { [k: string]: | boolean | number @@ -3116,7 +3196,6 @@ export interface Defs17 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -3136,14 +3215,17 @@ export interface Defs17 { | null } export interface ErrorBlock { - description?: Description18 - spec?: Spec18 - defs?: Defs18 + description?: Description17 + spec?: Spec17 + defs?: Defs17 def?: Def1 contribute?: Contribute1 parser?: Parser1 fallback?: Fallback1 role?: Role1 + start_nanos?: StartNanos1 + end_nanos?: EndNanos1 + timezone?: Timezone1 result?: unknown location?: LocationType | null kind?: Kind1 @@ -3154,14 +3236,14 @@ export interface ErrorBlock { * Type specification of the result of the block. * */ -export interface Spec18 { +export interface Spec17 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs18 { +export interface Defs17 { [k: string]: | boolean | number @@ -3169,7 +3251,6 @@ export interface Defs18 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -3192,14 +3273,17 @@ export interface Defs18 { * Block without an action. It can contain definitions. */ export interface EmptyBlock { - description?: Description19 - spec?: Spec19 - defs?: Defs19 + description?: Description18 + spec?: Spec18 + defs?: Defs18 def?: Def contribute?: Contribute parser?: Parser fallback?: Fallback role?: Role + start_nanos?: StartNanos + end_nanos?: EndNanos + timezone?: Timezone result?: unknown location?: LocationType | null kind?: Kind @@ -3208,14 +3292,14 @@ export interface EmptyBlock { * Type specification of the result of the block. * */ -export interface Spec19 { +export interface Spec18 { [k: string]: unknown } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs19 { +export interface Defs18 { [k: string]: | boolean | number @@ -3223,7 +3307,6 @@ export interface Defs19 { | FunctionBlock | CallBlock | LitellmModelBlock - | BamModelBlock | CodeBlock | GetBlock | DataBlock @@ -3246,13 +3329,13 @@ export interface ContributeValue { value: Value } export interface PdlParser { - description?: Description20 - spec?: Spec20 + description?: Description19 + spec?: Spec19 pdl: Pdl } export interface RegexParser { - description?: Description21 - spec?: Spec21 + description?: Description20 + spec?: Spec20 regex: Regex mode?: Mode } @@ -3281,56 +3364,3 @@ export interface JoinArray { export interface JoinLastOf { as: As2 } -export interface ModerationParameters { - hap?: ModerationHAP | null - social_bias?: ModerationSocialBias | null - [k: string]: unknown -} -export interface ModerationHAP { - input?: ModerationHAPInput | null - output?: ModerationHAPOutput | null - [k: string]: unknown -} -export interface ModerationHAPInput { - enabled?: Enabled - send_tokens?: SendTokens - threshold?: Threshold - [k: string]: unknown -} -export interface ModerationHAPOutput { - enabled?: Enabled1 - send_tokens?: SendTokens1 - threshold?: Threshold1 - [k: string]: unknown -} -export interface ModerationSocialBias { - input?: ModerationSocialBiasInput | null - output?: ModerationSocialBiasOutput | null - [k: string]: unknown -} -export interface ModerationSocialBiasInput { - enabled?: Enabled2 - send_tokens?: SendTokens2 - threshold?: Threshold2 - [k: string]: unknown -} -export interface ModerationSocialBiasOutput { - enabled?: Enabled3 - send_tokens?: SendTokens3 - threshold?: Threshold3 - [k: string]: unknown -} -export interface PromptTemplateData { - example_file_ids?: ExampleFileIds - [k: string]: unknown -} -export interface Constraints { - [k: string]: unknown -} -/** - * Arguments of the function with their values. - * - */ -export interface Args { - [k: string]: unknown -} diff --git a/pdl-live-react/src/view/Code.tsx b/pdl-live-react/src/view/Code.tsx index aee93098..4144349a 100644 --- a/pdl-live-react/src/view/Code.tsx +++ b/pdl-live-react/src/view/Code.tsx @@ -48,21 +48,25 @@ function block_code_cleanup(data: string | PdlBlock): string | PdlBlock { const new_data = { ...data, result: undefined } // remove trace match(new_data).with({ trace: P._ }, (data) => { - data.trace = undefined + delete data.trace }) + // remove other trace artifacts + delete new_data.start_nanos + delete new_data.end_nanos + delete new_data.timezone // remove contribute: ["result", context] if ( new_data?.contribute?.includes("result") && new_data?.contribute?.includes("context") ) { - new_data.contribute = undefined + delete new_data.contribute } // remove empty defs list if (Object.keys(data?.defs ?? {}).length === 0) { - new_data.defs = undefined + delete new_data.defs } // remove location info - new_data.location = undefined + delete new_data.location // recursive cleanup return map_block_children(block_code_cleanup, new_data) } diff --git a/pdl-live-react/src/view/transcript/Duration.css b/pdl-live-react/src/view/transcript/Duration.css new file mode 100644 index 00000000..de8aff55 --- /dev/null +++ b/pdl-live-react/src/view/transcript/Duration.css @@ -0,0 +1,6 @@ +.pdl-duration { + z-index: 1000; + font-size: 0.75em; + cursor: default; + color: var(--pf-t--global--text--color--subtle); +} diff --git a/pdl-live-react/src/view/transcript/Duration.tsx b/pdl-live-react/src/view/transcript/Duration.tsx new file mode 100644 index 00000000..37800333 --- /dev/null +++ b/pdl-live-react/src/view/transcript/Duration.tsx @@ -0,0 +1,58 @@ +import prettyMs from "pretty-ms" +import { + DescriptionList, + DescriptionListGroup, + DescriptionListTerm, + DescriptionListDescription, + Tooltip, +} from "@patternfly/react-core" + +import "./Duration.css" + +type Props = { + block: import("../../helpers").PdlBlockWithTiming +} + +/** Duration of block execution */ +function duration(block: Props["block"]) { + return block.end_nanos - block.start_nanos +} + +function format(nanos: number, timezone: string) { + return new Date(nanos / 1000000).toLocaleTimeString(navigator.language, { + timeZone: timezone, + }) +} + +export default function Duration({ block }: Props) { + const dur = prettyMs(duration(block) / 1000000) + + const tip = ( + + + Duration + {dur} + + + + Start Time + + {format(block.start_nanos, block.timezone)} + + + + + End Time + + {format(block.end_nanos, block.timezone)} + + + + ) + + return ( + + {dur} + + ) +} diff --git a/pdl-live-react/src/view/transcript/PrettyKind.tsx b/pdl-live-react/src/view/transcript/PrettyKind.tsx index 22efc977..5e714714 100644 --- a/pdl-live-react/src/view/transcript/PrettyKind.tsx +++ b/pdl-live-react/src/view/transcript/PrettyKind.tsx @@ -58,7 +58,8 @@ export default function PrettyKind({ )} ) - case "call": + case "call": { + const { args } = block return ( <> Call{" "} @@ -70,15 +71,19 @@ export default function PrettyKind({ {block.call.replace(/^\$\{\s*([^\s}]+)\s*\}$/, "$1")} ( - {block.args && - Object.values(block.args) - .map((a) => `"${a}"`) - .join(", ")} + {args != null && typeof args === "object" ? ( + Object.values(args) + .map((a) => `"${String(a)}"`) + .join(", ") + ) : ( + <> + )} ) )} ) + } case "error": return `${firstLineOf(block.msg)}` case "code": diff --git a/pdl-live-react/src/view/transcript/TranscriptItem.tsx b/pdl-live-react/src/view/transcript/TranscriptItem.tsx index c91b9afd..2d19d0e2 100644 --- a/pdl-live-react/src/view/transcript/TranscriptItem.tsx +++ b/pdl-live-react/src/view/transcript/TranscriptItem.tsx @@ -13,11 +13,17 @@ import Def from "./Def" import Icon from "./Icon" import Code from "../Code" import type Context from "../../Context" +import Duration from "./Duration" import PrettyKind from "./PrettyKind" import BreadcrumbBar from "./BreadcrumbBar" import BreadcrumbBarItem from "./BreadcrumbBarItem" -import { hasResult, nonNullable, type NonScalarPdlBlock } from "../../helpers" +import { + hasTimingInformation, + hasResult, + nonNullable, + type NonScalarPdlBlock, +} from "../../helpers" type Props = PropsWithChildren<{ className?: string @@ -103,6 +109,11 @@ export default function TranscriptItem(props: Props) { data-id={props.ctx.id} > } + : undefined + } selectableActions={{ onClickAction: drilldown, selectableActionAriaLabelledby: props.ctx.id, diff --git a/pdl-live-react/yarn.lock b/pdl-live-react/yarn.lock index 83400220..50bc543d 100644 --- a/pdl-live-react/yarn.lock +++ b/pdl-live-react/yarn.lock @@ -2233,6 +2233,11 @@ parse-json@^5.2.0: json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" +parse-ms@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-4.0.0.tgz#c0c058edd47c2a590151a718990533fd62803df4" + integrity sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw== + path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -2296,6 +2301,13 @@ prettier@^3.2.5, prettier@^3.4.2: resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.4.2.tgz#a5ce1fb522a588bf2b78ca44c6e6fe5aa5a2b13f" integrity sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ== +pretty-ms@^9.2.0: + version "9.2.0" + resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-9.2.0.tgz#e14c0aad6493b69ed63114442a84133d7e560ef0" + integrity sha512-4yf0QO/sllf/1zbZWYnvWw3NxCQwLXKzIj0G849LSufP15BXKM0rbD2Z3wVnkMfjdn/CB0Dpp444gYAACdsplg== + dependencies: + parse-ms "^4.0.0" + prop-types@^15.8.1: version "15.8.1" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" diff --git a/pdl-live/src/pdl_ast.d.ts b/pdl-live/src/pdl_ast.d.ts index c59191c9..620af81b 100644 --- a/pdl-live/src/pdl_ast.d.ts +++ b/pdl-live/src/pdl_ast.d.ts @@ -216,6 +216,21 @@ export type Fallback = * */ export type Role = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone = string | null; export type Path = string[]; export type File = string; export type Kind = "empty"; @@ -271,6 +286,21 @@ export type Fallback1 = * */ export type Role1 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos1 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos1 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone1 = string | null; export type Kind1 = "error"; export type Msg = string; export type Program1 = @@ -349,6 +379,21 @@ export type Fallback2 = * */ export type Role2 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos2 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos2 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone2 = string | null; export type Kind2 = "include"; /** * Name of the file to include. @@ -431,6 +476,21 @@ export type Fallback3 = * */ export type Role3 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos3 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos3 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone3 = string | null; export type Kind3 = "read"; /** * Message to prompt the user to enter a value. @@ -493,6 +553,21 @@ export type Fallback4 = * Role of associated to the message. */ export type Role4 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos4 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos4 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone4 = string | null; export type Kind4 = "message"; /** * Content of the message. @@ -573,6 +648,21 @@ export type Fallback5 = * */ export type Role5 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos5 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos5 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone5 = string | null; export type Kind5 = "object"; export type Object = | { @@ -678,6 +768,21 @@ export type Fallback6 = * */ export type Role6 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos6 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos6 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone6 = string | null; export type Kind6 = "array"; export type Array = ( | boolean @@ -756,6 +861,21 @@ export type Fallback7 = * */ export type Role7 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos7 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos7 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone7 = string | null; export type Kind7 = "lastOf"; export type Lastof = ( | boolean @@ -834,6 +954,21 @@ export type Fallback8 = * */ export type Role8 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos8 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos8 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone8 = string | null; export type Kind8 = "text"; /** * Body of the text. @@ -940,6 +1075,21 @@ export type Fallback9 = * */ export type Role9 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos9 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos9 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone9 = string | null; export type Kind9 = "for"; /** * Body of the loop. @@ -1073,6 +1223,21 @@ export type Fallback10 = * */ export type Role10 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos10 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos10 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone10 = string | null; export type Kind10 = "repeat_until"; /** * Body of the loop. @@ -1186,6 +1351,21 @@ export type Fallback11 = * */ export type Role11 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos11 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos11 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone11 = string | null; export type Kind11 = "repeat"; /** * Body of the loop. @@ -1304,6 +1484,21 @@ export type Fallback12 = * */ export type Role12 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos12 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos12 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone12 = string | null; export type Kind12 = "if"; /** * Branch to exectute if the condition is true. @@ -1414,6 +1609,21 @@ export type Fallback13 = * */ export type Role13 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos13 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos13 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone13 = string | null; export type Kind13 = "data"; /** * Do not evaluate expressions inside strings. @@ -1471,6 +1681,21 @@ export type Fallback14 = * */ export type Role14 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos14 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos14 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone14 = string | null; export type Kind14 = "get"; /** * Name of the variable to access. @@ -1528,6 +1753,21 @@ export type Fallback15 = * */ export type Role15 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos15 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos15 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone15 = string | null; export type Kind15 = "code"; /** * Programming language of the code. @@ -1614,6 +1854,21 @@ export type Fallback16 = * */ export type Role16 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos16 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos16 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone16 = string | null; export type Kind16 = "model"; export type Input = | boolean @@ -1717,6 +1972,21 @@ export type Fallback17 = * */ export type Role17 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos17 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos17 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone17 = string | null; export type Kind17 = "call"; export type Trace5 = | boolean @@ -1794,6 +2064,21 @@ export type Fallback18 = * */ export type Role18 = string | null; +/** + * Time at which block execution began + * + */ +export type StartNanos18 = number | null; +/** + * Time at which block execution ended + * + */ +export type EndNanos18 = number | null; +/** + * Timezone of start_nanos and end_nanos + * + */ +export type Timezone18 = string | null; export type Kind18 = "function"; /** * Functions parameters with their types. @@ -1870,6 +2155,9 @@ export interface FunctionBlock { parser?: Parser18; fallback?: Fallback18; role?: Role18; + start_nanos?: StartNanos18; + end_nanos?: EndNanos18; + timezone?: Timezone18; result?: unknown; location?: LocationType | null; kind?: Kind18; @@ -1926,6 +2214,9 @@ export interface CallBlock { parser?: Parser17; fallback?: Fallback17; role?: Role17; + start_nanos?: StartNanos17; + end_nanos?: EndNanos17; + timezone?: Timezone17; result?: unknown; location?: LocationType | null; kind?: Kind17; @@ -1982,6 +2273,9 @@ export interface LitellmModelBlock { parser?: Parser16; fallback?: Fallback16; role?: Role16; + start_nanos?: StartNanos16; + end_nanos?: EndNanos16; + timezone?: Timezone16; result?: unknown; location?: LocationType | null; kind?: Kind16; @@ -2041,6 +2335,9 @@ export interface CodeBlock { parser?: Parser15; fallback?: Fallback15; role?: Role15; + start_nanos?: StartNanos15; + end_nanos?: EndNanos15; + timezone?: Timezone15; result?: unknown; location?: LocationType | null; kind?: Kind15; @@ -2096,6 +2393,9 @@ export interface GetBlock { parser?: Parser14; fallback?: Fallback14; role?: Role14; + start_nanos?: StartNanos14; + end_nanos?: EndNanos14; + timezone?: Timezone14; result?: unknown; location?: LocationType | null; kind?: Kind14; @@ -2150,6 +2450,9 @@ export interface DataBlock { parser?: Parser13; fallback?: Fallback13; role?: Role13; + start_nanos?: StartNanos13; + end_nanos?: EndNanos13; + timezone?: Timezone13; result?: unknown; location?: LocationType | null; kind?: Kind13; @@ -2205,6 +2508,9 @@ export interface IfBlock { parser?: Parser12; fallback?: Fallback12; role?: Role12; + start_nanos?: StartNanos12; + end_nanos?: EndNanos12; + timezone?: Timezone12; result?: unknown; location?: LocationType | null; kind?: Kind12; @@ -2262,6 +2568,9 @@ export interface RepeatBlock { parser?: Parser11; fallback?: Fallback11; role?: Role11; + start_nanos?: StartNanos11; + end_nanos?: EndNanos11; + timezone?: Timezone11; result?: unknown; location?: LocationType | null; kind?: Kind11; @@ -2319,6 +2628,9 @@ export interface RepeatUntilBlock { parser?: Parser10; fallback?: Fallback10; role?: Role10; + start_nanos?: StartNanos10; + end_nanos?: EndNanos10; + timezone?: Timezone10; result?: unknown; location?: LocationType | null; kind?: Kind10; @@ -2376,6 +2688,9 @@ export interface ForBlock { parser?: Parser9; fallback?: Fallback9; role?: Role9; + start_nanos?: StartNanos9; + end_nanos?: EndNanos9; + timezone?: Timezone9; result?: unknown; location?: LocationType | null; kind?: Kind9; @@ -2433,6 +2748,9 @@ export interface TextBlock { parser?: Parser8; fallback?: Fallback8; role?: Role8; + start_nanos?: StartNanos8; + end_nanos?: EndNanos8; + timezone?: Timezone8; result?: unknown; location?: LocationType | null; kind?: Kind8; @@ -2487,6 +2805,9 @@ export interface LastOfBlock { parser?: Parser7; fallback?: Fallback7; role?: Role7; + start_nanos?: StartNanos7; + end_nanos?: EndNanos7; + timezone?: Timezone7; result?: unknown; location?: LocationType | null; kind?: Kind7; @@ -2541,6 +2862,9 @@ export interface ArrayBlock { parser?: Parser6; fallback?: Fallback6; role?: Role6; + start_nanos?: StartNanos6; + end_nanos?: EndNanos6; + timezone?: Timezone6; result?: unknown; location?: LocationType | null; kind?: Kind6; @@ -2595,6 +2919,9 @@ export interface ObjectBlock { parser?: Parser5; fallback?: Fallback5; role?: Role5; + start_nanos?: StartNanos5; + end_nanos?: EndNanos5; + timezone?: Timezone5; result?: unknown; location?: LocationType | null; kind?: Kind5; @@ -2649,6 +2976,9 @@ export interface MessageBlock { parser?: Parser4; fallback?: Fallback4; role: Role4; + start_nanos?: StartNanos4; + end_nanos?: EndNanos4; + timezone?: Timezone4; result?: unknown; location?: LocationType | null; kind?: Kind4; @@ -2703,6 +3033,9 @@ export interface ReadBlock { parser?: Parser3; fallback?: Fallback3; role?: Role3; + start_nanos?: StartNanos3; + end_nanos?: EndNanos3; + timezone?: Timezone3; result?: unknown; location?: LocationType | null; kind?: Kind3; @@ -2759,6 +3092,9 @@ export interface IncludeBlock { parser?: Parser2; fallback?: Fallback2; role?: Role2; + start_nanos?: StartNanos2; + end_nanos?: EndNanos2; + timezone?: Timezone2; result?: unknown; location?: LocationType | null; kind?: Kind2; @@ -2811,6 +3147,9 @@ export interface ErrorBlock { parser?: Parser1; fallback?: Fallback1; role?: Role1; + start_nanos?: StartNanos1; + end_nanos?: EndNanos1; + timezone?: Timezone1; result?: unknown; location?: LocationType | null; kind?: Kind1; @@ -2866,6 +3205,9 @@ export interface EmptyBlock { parser?: Parser; fallback?: Fallback; role?: Role; + start_nanos?: StartNanos; + end_nanos?: EndNanos; + timezone?: Timezone; result?: unknown; location?: LocationType | null; kind?: Kind; diff --git a/src/pdl/pdl-schema.json b/src/pdl/pdl-schema.json index 5f725755..db5fb79e 100644 --- a/src/pdl/pdl-schema.json +++ b/src/pdl/pdl-schema.json @@ -255,6 +255,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -624,6 +663,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -1012,6 +1090,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -1414,6 +1531,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -1719,6 +1875,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -2004,6 +2199,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -2375,6 +2609,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -2863,6 +3136,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -3255,6 +3567,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -3545,9 +3896,48 @@ "type": "null" } ], - "default": null, - "description": "Role associated to the block and sub-blocks.\n ", - "title": "Role" + "default": null, + "description": "Role associated to the block and sub-blocks.\n ", + "title": "Role" + }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" }, "result": { "anyOf": [ @@ -4018,6 +4408,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -4442,6 +4871,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -4811,6 +5279,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -5754,6 +6261,45 @@ "description": "Role of associated to the message.", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -6122,6 +6668,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -6840,6 +7425,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -7211,6 +7835,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -7691,6 +8354,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, @@ -8176,6 +8878,45 @@ "description": "Role associated to the block and sub-blocks.\n ", "title": "Role" }, + "start_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution began\n ", + "title": "Start Nanos" + }, + "end_nanos": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": 0, + "description": "Time at which block execution ended\n ", + "title": "End Nanos" + }, + "timezone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Timezone of start_nanos and end_nanos\n ", + "title": "Timezone" + }, "result": { "anyOf": [ {}, diff --git a/src/pdl/pdl_ast.py b/src/pdl/pdl_ast.py index 61642f49..e0ac479d 100644 --- a/src/pdl/pdl_ast.py +++ b/src/pdl/pdl_ast.py @@ -133,6 +133,15 @@ class Block(BaseModel): role: RoleType = None """Role associated to the block and sub-blocks. """ + start_nanos: Optional[int] = 0 + """Time at which block execution began + """ + end_nanos: Optional[int] = 0 + """Time at which block execution ended + """ + timezone: Optional[str] = "" + """Timezone of start_nanos and end_nanos + """ # Fields for internal use result: Optional[Any] = None location: Optional[LocationType] = None diff --git a/src/pdl/pdl_dumper.py b/src/pdl/pdl_dumper.py index 80930601..1cb83bc0 100644 --- a/src/pdl/pdl_dumper.py +++ b/src/pdl/pdl_dumper.py @@ -1,3 +1,4 @@ +import datetime import json from typing import Any, Sequence, TypeAlias @@ -79,6 +80,18 @@ def block_to_dict(block: pdl_ast.BlockType, json_compatible: bool) -> DumpedBloc return block d: dict[str, Any] = {} d["kind"] = str(block.kind) + if block.start_nanos != 0: + d["start_nanos"] = block.start_nanos + d["end_nanos"] = block.end_nanos + + now = datetime.datetime.now() + local_now = now.astimezone() + local_tz = local_now.tzinfo + if local_tz is not None: + local_tzname = local_tz.tzname(local_now) + else: + local_tzname = "UTC" + d["timezone"] = local_tzname if block.description is not None: d["description"] = block.description if block.role is not None: diff --git a/src/pdl/pdl_interpreter.py b/src/pdl/pdl_interpreter.py index d9a4a3ec..71f144fd 100644 --- a/src/pdl/pdl_interpreter.py +++ b/src/pdl/pdl_interpreter.py @@ -4,6 +4,7 @@ import shlex import subprocess # nosec import sys +import time import types # TODO: temporarily disabling warnings to mute a pydantic warning from liteLLM @@ -299,7 +300,7 @@ def step_block( yield YieldResultMessage(result) append_log(state, "pdl_context", background) else: - result, background, scope, trace = yield from step_advanced_block( + result, background, scope, trace = yield from step_advanced_block_timed( state, scope, block, loc ) scope = scope | {"pdl_context": background} @@ -314,6 +315,26 @@ def context_in_contribute(block: AdvancedBlockType) -> bool: return False +# A start-end time wrapper around `step_advanced_block` +def step_advanced_block_timed( + state: InterpreterState, + scope: ScopeType, + block: AdvancedBlockType, + loc: LocationType, +) -> Generator[YieldMessage, Any, tuple[Any, Messages, ScopeType, BlockType]]: + start_nanos = time.time_ns() + result, background, scope, trace = yield from step_advanced_block( + state, scope, block, loc + ) + end_nanos = time.time_ns() + match trace: + case Block(): + trace = trace.model_copy( + update={"start_nanos": start_nanos, "end_nanos": end_nanos} + ) + return result, background, scope, trace + + def step_advanced_block( state: InterpreterState, scope: ScopeType,