Skip to content

Commit e4fef24

Browse files
committed
feat: update interpreter to trace context state
and update react ui to visualize it in a topology viewer This is an initial pass... Signed-off-by: Nick Mitchell <[email protected]>
1 parent 6b861ff commit e4fef24

27 files changed

+2015
-17
lines changed

pdl-live-react/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
"preview": "vite preview",
1111
"test:quality": "concurrently -n 'lint,types,formatting' 'yarn lint' 'tsc --build --noEmit' \"prettier --check 'tests/**/*.ts' 'src/**/*.{ts,tsx,css}'\"",
1212
"test:ui": "yarn playwright install --with-deps && yarn playwright test",
13+
"types": "(cd .. && python -m src.pdl.pdl --schema > src/pdl/pdl-schema.json) && json2ts ../src/pdl/pdl-schema.json src/pdl_ast.d.ts --unreachableDefinitions",
1314
"test": "concurrently -n 'quality,playwright' 'yarn test:quality' 'yarn test:ui'"
1415
},
1516
"dependencies": {
1617
"@patternfly/react-code-editor": "^6.1.0",
1718
"@patternfly/react-core": "^6.1.0",
19+
"@patternfly/react-topology": "^6.1.0",
1820
"pretty-bytes": "^6.1.1",
1921
"pretty-ms": "^9.2.0",
2022
"react": "^18.3.1",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"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"}
1+
{"kind": "text", "start_nanos": 1738006438448127000, "end_nanos": 1738006439695520000, "timezone": "EST", "description": "Simple LLM interaction", "defs": {}, "text": ["write a hello world example\n", {"kind": "model", "context": [{"role": "user", "content": "write a hello world example\n"}], "start_nanos": 1738006438449110000, "end_nanos": 1738006439695499000, "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"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"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"}
1+
{"kind": "text", "start_nanos": 1738006440779179000, "end_nanos": 1738006442322911000, "timezone": "EST", "description": "Model chaining", "defs": {}, "text": ["Hello\n", {"kind": "model", "context": [{"role": "user", "content": "Hello\n"}], "start_nanos": 1738006440780081000, "end_nanos": 1738006441153102000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "parameters": {"stop_sequences": "!"}, "result": "Hi there! How can I assist you today?\n"}, "\nDid you just say Hello?\n", {"kind": "model", "context": [{"role": "user", "content": "Hello\n"}, {"content": "Hi there! How can I assist you today?\n", "role": "assistant"}, {"role": "user", "content": "\nDid you just say Hello?\n"}], "start_nanos": 1738006441154069000, "end_nanos": 1738006442322886000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "parameters": {"stop_sequences": "!"}, "result": "Yes, that's correct. As an AI language model, my goal is to provide helpful and accurate responses to your questions and conversations. I'm here to assist you in any way I can. So, what can I help you with today?\n"}], "result": "Hello\nHi there! How can I assist you today?\n\nDid you just say Hello?\nYes, that's correct. As an AI language model, my goal is to provide helpful and accurate responses to your questions and conversations. I'm here to assist you in any way I can. So, what can I help you with today?\n"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"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"}
1+
{"kind": "text", "start_nanos": 1738006443509360000, "end_nanos": 1738006451445830000, "timezone": "EST", "description": "Fibonacci", "defs": {}, "text": [{"kind": "model", "start_nanos": 1738006443509417000, "end_nanos": 1738006444900707000, "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": 1738006444901099000, "end_nanos": 1738006444901684000, "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": 1738006444902072000, "end_nanos": 1738006444902439000, "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": 14}, "\nNow compute `fibonacci(14)`\n", {"kind": "code", "start_nanos": 1738006444902723000, "end_nanos": 1738006444903156000, "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(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", "context": [{"content": "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", "role": "assistant"}, {"role": "user", "content": "\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\n"}], "start_nanos": 1738006444903557000, "end_nanos": 1738006451445791000, "timezone": "EST", "defs": {}, "platform": "litellm", "model": "ollama/granite-code:8b", "result": "The code defines a recursive function `fibonacci` that calculates the nth Fibonacci number. The base case is when n is less than or equal to 1, in which case the function simply returns n. Otherwise, it recursively calls itself with arguments n-1 and n-2, and returns the sum of the results.\n\nTo find a random number between 1 and 20, we can use the `random` module in Python:\n\n```python\nimport random\n\nrandom_number = random.randint(1, 20)\n```\n\nThis will generate a random integer between 1 and 20 (inclusive).\n\nTo compute `fibonacci(14)`, we can simply call the function with the argument 14:\n\n```python\nresult = fibonacci(14)\n```\n\nThe result is 377, which is the 14th Fibonacci number. 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, ...\n\nThe 14th Fibonacci number is 377.\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 code defines a recursive function `fibonacci` that calculates the nth Fibonacci number. The base case is when n is less than or equal to 1, in which case the function simply returns n. Otherwise, it recursively calls itself with arguments n-1 and n-2, and returns the sum of the results.\n\nTo find a random number between 1 and 20, we can use the `random` module in Python:\n\n```python\nimport random\n\nrandom_number = random.randint(1, 20)\n```\n\nThis will generate a random integer between 1 and 20 (inclusive).\n\nTo compute `fibonacci(14)`, we can simply call the function with the argument 14:\n\n```python\nresult = fibonacci(14)\n```\n\nThe result is 377, which is the 14th Fibonacci number. 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, ...\n\nThe 14th Fibonacci number is 377.\n"}

0 commit comments

Comments
 (0)