Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

vite-falcon
Copy link
Contributor

I wrote a PDL lint tool for one of my projects to validate that PDL files in the project are valid at build time. I imagine this tool would be nice to be part of Prompt Declaration Library itself. Hence this proposal.

The tool's behavior can be configured either via pyproject.toml or .pdl-lint file, with preference given to settings of pyproject.toml, ignoring any settings in .pdl-lint file.

Sample output

Happy Case

$ uv run pdl-lint -r
Linting 119 PDL files in /home/user/prompt-declaration-language (recursively)...
 - ✅  tests/data/hello.pdl
 - ✅  tests/data/function.pdl
 - ✅  tests/data/call_expression_args.pdl
 - ℹ️  SKIPPING tests/data/line/hello.pdl (in ignore list)
 - ✅  tests/data/line/hello20.pdl
 - ✅  tests/data/line/hello22.pdl
 - ✅  tests/data/line/hello23.pdl
 - ✅  tests/data/line/hello3.pdl
 - ✅  tests/data/line/hello26.pdl
 - ℹ️  SKIPPING tests/data/line/hello10.pdl (in ignore list)
 - ℹ️  SKIPPING tests/data/line/hello4.pdl (in ignore list)
 - ✅  tests/data/line/hello21.pdl
 - ✅  tests/data/line/hello17.pdl
 - ✅  tests/data/line/hello29.pdl
 - ℹ️  SKIPPING tests/data/line/hello31.pdl (in ignore list)
 - ✅  tests/data/line/hello30.pdl
 - ✅  tests/data/line/hello16.pdl
 - ✅  tests/data/line/hello14.pdl
 - ✅  tests/data/line/hello12.pdl
 - ✅  tests/data/line/hello18.pdl
 - ✅  tests/data/line/hello13.pdl
 - ✅  tests/data/line/hello25.pdl
 - ℹ️  SKIPPING tests/data/line/hello8.pdl (in ignore list)
 - ✅  tests/data/line/hello27.pdl
 - ℹ️  SKIPPING tests/data/line/hello11.pdl (in ignore list)
 - ✅  tests/data/line/hello28.pdl
 - ℹ️  SKIPPING tests/data/line/hello7.pdl (in ignore list)
 - ✅  tests/data/line/hello24.pdl
 - ℹ️  SKIPPING tests/data/line/hello1.pdl (in ignore list)
 - ✅  tests/data/line/hello19.pdl
 - ✅  tests/data/line/hello15.pdl
 - ✅  tests/data/line/hello9.pdl
 - ✅  pdl-live-react/demos/demo2.pdl
 - ✅  pdl-live-react/demos/demo1.pdl
 - ✅  pdl-live-react/demos/error.pdl
 - ✅  examples/demo/5-code-eval.pdl
 - ✅  examples/demo/1-hello.pdl
 - ✅  examples/demo/7-chatbot-roles.pdl
 - ✅  examples/demo/6-code-json.pdl
 - ✅  examples/demo/4-function.pdl
 - ✅  examples/demo/9-react.pdl
 - ✅  examples/demo/11-repeat.pdl
 - ✅  examples/demo/3-def-use.pdl
 - ✅  examples/demo/10-sdg.pdl
 - ✅  examples/demo/2-model-chaining.pdl
 - ✅  examples/demo/8-tools.pdl
 - ✅  examples/cldk/cldk-assistant.pdl
 - ✅  examples/sdk/hello.pdl
 - ✅  examples/gsm8k/gsm8.pdl
 - ✅  examples/gsm8k/gsm8k-plan.pdl
 - ✅  examples/teacher/teacher.pdl
 - ✅  examples/input/input_test.pdl
 - ✅  examples/input/input_test2.pdl
 - ✅  examples/input/input_test1.pdl
 - ✅  examples/tutorial/input_stdin.pdl
 - ✅  examples/tutorial/input_file_json.pdl
 - ✅  examples/tutorial/code_command.pdl
 - ✅  examples/tutorial/while.pdl
 - ✅  examples/tutorial/for_array.pdl
 - ✅  examples/tutorial/for_with.pdl
 - ✅  examples/tutorial/import.pdl
 - ✅  examples/tutorial/code_jinja.pdl
 - ✅  examples/tutorial/calling_llm_with_input_messages_var.pdl
 - ✅  examples/tutorial/function_empty_context.pdl
 - ✅  examples/tutorial/structured_decoding.pdl
 - ✅  examples/tutorial/type_list.pdl
 - ✅  examples/tutorial/if.pdl
 - ✅  examples/tutorial/parser_findall.pdl
 - ✅  examples/tutorial/type_checking.pdl
 - ✅  examples/tutorial/repeat.pdl
 - ✅  examples/tutorial/function_optional_params.pdl
 - ✅  examples/tutorial/for.pdl
 - ✅  examples/tutorial/input_stdin_multiline.pdl
 - ✅  examples/tutorial/defs-hello.pdl
 - ✅  examples/tutorial/for_object.pdl
 - ✅  examples/tutorial/calling_llm.pdl
 - ✅  examples/tutorial/data_block_raw.pdl
 - ✅  examples/tutorial/code_pdl.pdl
 - ✅  examples/tutorial/calling_llm_with_input.pdl
 - ✅  examples/tutorial/code_python.pdl
 - ✅  examples/tutorial/input_file.pdl
 - ✅  examples/tutorial/muting_block_output.pdl
 - ✅  examples/tutorial/function_definition.pdl
 - ✅  examples/tutorial/for_lastOf.pdl
 - ✅  examples/tutorial/free_variables.pdl
 - ✅  examples/tutorial/simple_program.pdl
 - ✅  examples/tutorial/import_lib.pdl
 - ✅  examples/tutorial/calling_llm_chaining.pdl
 - ✅  examples/tutorial/variable_def_use.pdl
 - ✅  examples/tutorial/parser_regex_code.pdl
 - ✅  examples/tutorial/defs.pdl
 - ✅  examples/tutorial/parser-regex.pdl
 - ✅  examples/tutorial/for_multiple_lists.pdl
 - ✅  examples/tutorial/function_alias.pdl
 - ✅  examples/tutorial/calling_llm_with_input_messages.pdl
 - ✅  examples/fibonacci/fib.pdl
 - ✅  examples/code/code-json.pdl
 - ✅  examples/code/code.pdl
 - ✅  examples/code/code-eval.pdl
 - ✅  examples/tools/calc.pdl
 - ✅  examples/intrinsics/demo-hallucination.pdl
 - ✅  examples/react/react_fun.pdl
 - ✅  examples/react/demo.pdl
 - ✅  examples/react/react_call.pdl
 - ✅  examples/rag/rag_library1.pdl
 - ✅  examples/rag/tfidf_rag.pdl
 - ✅  examples/rag/pdf_query.pdl
 - ✅  examples/rag/pdf_index.pdl
 - ✅  examples/chatbot/chatbot.pdl
 - ✅  examples/callback/repair_prompt.pdl
 - ✅  examples/granite-io/granite_io_thinking.pdl
 - ✅  examples/granite-io/granite_io_openai.pdl
 - ✅  examples/granite-io/granite_io_hallucinations.pdl
 - ✅  examples/granite-io/granite_io_transformers.pdl
 - ✅  examples/tutorial/programs/chatbot.pdl
 - ✅  examples/tutorial/programs/demo-hallucination.pdl
 - ✅  examples/tutorial/programs/code-json.pdl
 - ✅  examples/tutorial/programs/tfidf_rag.pdl
 - ✅  examples/tutorial/programs/weather.pdl
----------------------------------------------------------------------------------------------------
🎉  All files linted successfully 🎉

Failure Case

Linting 119 PDL files in /home/user/prompt-declaration-language (recursively)...
 - ✅  tests/data/hello.pdl
 - ✅  tests/data/function.pdl
 - ✅  tests/data/call_expression_args.pdl
 - ❌  tests/data/line/hello.pdl
     PDLParseError: ['tests/data/line/hello.pdl:0 - Missing required field: function', 'tests/data/line/hello.pdl:0 - Missing required field: return', 'tests/data/line/hello.pdl:2 - Field not allowed: texts']
 - ✅  tests/data/line/hello20.pdl
 - ✅  tests/data/line/hello22.pdl
 - ✅  tests/data/line/hello23.pdl
 - ✅  tests/data/line/hello3.pdl
 - ✅  tests/data/line/hello26.pdl
 - ❌  tests/data/line/hello10.pdl
     PDLParseError: ['tests/data/line/hello10.pdl:7 - QUESTION should be an object']
 - ❌  tests/data/line/hello4.pdl
     PDLParseError: ['tests/data/line/hello4.pdl:5 - Missing required field: repeat', 'tests/data/line/hello4.pdl:5 - Field not allowed: repeats']
 - ✅  tests/data/line/hello21.pdl
 - ✅  tests/data/line/hello17.pdl
 - ✅  tests/data/line/hello29.pdl
 - ❌  tests/data/line/hello31.pdl
     PDLParseError: ['tests/data/line/hello31.pdl:0 - Missing required field: function', 'tests/data/line/hello31.pdl:0 - Missing required field: return', 'tests/data/line/hello31.pdl:9 - Field not allowed: show_result']
 - ✅  tests/data/line/hello30.pdl
 - ✅  tests/data/line/hello16.pdl
 - ✅  tests/data/line/hello14.pdl
 - ✅  tests/data/line/hello12.pdl
 - ✅  tests/data/line/hello18.pdl
 - ✅  tests/data/line/hello13.pdl
 - ✅  tests/data/line/hello25.pdl
 - ❌  tests/data/line/hello8.pdl
     PDLParseError: ['tests/data/line/hello8.pdl:4 - Missing required field: code', 'tests/data/line/hello8.pdl:5 - Field not allowed: codea']
 - ✅  tests/data/line/hello27.pdl
 - ❌  tests/data/line/hello11.pdl
     PDLParseError: ['tests/data/line/hello11.pdl:7 - Field not allowed: defss']
 - ✅  tests/data/line/hello28.pdl
 - ❌  tests/data/line/hello7.pdl
     PDLParseError: ['tests/data/line/hello7.pdl:4 - Missing required field: lang', 'tests/data/line/hello7.pdl:4 - Field not allowed: lans']
 - ✅  tests/data/line/hello24.pdl
 - ❌  tests/data/line/hello1.pdl
     PDLParseError: ['tests/data/line/hello1.pdl:7 - Field not allowed: num_iterations']
 - ✅  tests/data/line/hello19.pdl
 - ✅  tests/data/line/hello15.pdl
 - ✅  tests/data/line/hello9.pdl
 - ✅  pdl-live-react/demos/demo2.pdl
 - ✅  pdl-live-react/demos/demo1.pdl
 - ✅  pdl-live-react/demos/error.pdl
 - ✅  examples/demo/5-code-eval.pdl
 - ✅  examples/demo/1-hello.pdl
 - ✅  examples/demo/7-chatbot-roles.pdl
 - ✅  examples/demo/6-code-json.pdl
 - ✅  examples/demo/4-function.pdl
 - ✅  examples/demo/9-react.pdl
 - ✅  examples/demo/11-repeat.pdl
 - ✅  examples/demo/3-def-use.pdl
 - ✅  examples/demo/10-sdg.pdl
 - ✅  examples/demo/2-model-chaining.pdl
 - ✅  examples/demo/8-tools.pdl
 - ✅  examples/cldk/cldk-assistant.pdl
 - ✅  examples/sdk/hello.pdl
 - ✅  examples/gsm8k/gsm8.pdl
 - ✅  examples/gsm8k/gsm8k-plan.pdl
 - ✅  examples/teacher/teacher.pdl
 - ✅  examples/input/input_test.pdl
 - ✅  examples/input/input_test2.pdl
 - ✅  examples/input/input_test1.pdl
 - ✅  examples/tutorial/input_stdin.pdl
 - ✅  examples/tutorial/input_file_json.pdl
 - ✅  examples/tutorial/code_command.pdl
 - ✅  examples/tutorial/while.pdl
 - ✅  examples/tutorial/for_array.pdl
 - ✅  examples/tutorial/for_with.pdl
 - ✅  examples/tutorial/import.pdl
 - ✅  examples/tutorial/code_jinja.pdl
 - ✅  examples/tutorial/calling_llm_with_input_messages_var.pdl
 - ✅  examples/tutorial/function_empty_context.pdl
 - ✅  examples/tutorial/structured_decoding.pdl
 - ✅  examples/tutorial/type_list.pdl
 - ✅  examples/tutorial/if.pdl
 - ✅  examples/tutorial/parser_findall.pdl
 - ✅  examples/tutorial/type_checking.pdl
 - ✅  examples/tutorial/repeat.pdl
 - ✅  examples/tutorial/function_optional_params.pdl
 - ✅  examples/tutorial/for.pdl
 - ✅  examples/tutorial/input_stdin_multiline.pdl
 - ✅  examples/tutorial/defs-hello.pdl
 - ✅  examples/tutorial/for_object.pdl
 - ✅  examples/tutorial/calling_llm.pdl
 - ✅  examples/tutorial/data_block_raw.pdl
 - ✅  examples/tutorial/code_pdl.pdl
 - ✅  examples/tutorial/calling_llm_with_input.pdl
 - ✅  examples/tutorial/code_python.pdl
 - ✅  examples/tutorial/input_file.pdl
 - ✅  examples/tutorial/muting_block_output.pdl
 - ✅  examples/tutorial/function_definition.pdl
 - ✅  examples/tutorial/for_lastOf.pdl
 - ✅  examples/tutorial/free_variables.pdl
 - ✅  examples/tutorial/simple_program.pdl
 - ✅  examples/tutorial/import_lib.pdl
 - ✅  examples/tutorial/calling_llm_chaining.pdl
 - ✅  examples/tutorial/variable_def_use.pdl
 - ✅  examples/tutorial/parser_regex_code.pdl
 - ✅  examples/tutorial/defs.pdl
 - ✅  examples/tutorial/parser-regex.pdl
 - ✅  examples/tutorial/for_multiple_lists.pdl
 - ✅  examples/tutorial/function_alias.pdl
 - ✅  examples/tutorial/calling_llm_with_input_messages.pdl
 - ✅  examples/fibonacci/fib.pdl
 - ✅  examples/code/code-json.pdl
 - ✅  examples/code/code.pdl
 - ✅  examples/code/code-eval.pdl
 - ✅  examples/tools/calc.pdl
 - ✅  examples/intrinsics/demo-hallucination.pdl
 - ✅  examples/react/react_fun.pdl
 - ✅  examples/react/demo.pdl
 - ✅  examples/react/react_call.pdl
 - ✅  examples/rag/rag_library1.pdl
 - ✅  examples/rag/tfidf_rag.pdl
 - ✅  examples/rag/pdf_query.pdl
 - ✅  examples/rag/pdf_index.pdl
 - ✅  examples/chatbot/chatbot.pdl
 - ✅  examples/callback/repair_prompt.pdl
 - ✅  examples/granite-io/granite_io_thinking.pdl
 - ✅  examples/granite-io/granite_io_openai.pdl
 - ✅  examples/granite-io/granite_io_hallucinations.pdl
 - ✅  examples/granite-io/granite_io_transformers.pdl
 - ✅  examples/tutorial/programs/chatbot.pdl
 - ✅  examples/tutorial/programs/demo-hallucination.pdl
 - ✅  examples/tutorial/programs/code-json.pdl
 - ✅  examples/tutorial/programs/tfidf_rag.pdl
 - ✅  examples/tutorial/programs/weather.pdl
----------------------------------------------------------------------------------------------------
😮  Linting failed for 8 file(s):
 - tests/data/line/hello.pdl
 - tests/data/line/hello10.pdl
 - tests/data/line/hello4.pdl
 - tests/data/line/hello31.pdl
 - tests/data/line/hello8.pdl
 - tests/data/line/hello11.pdl
 - tests/data/line/hello7.pdl
 - tests/data/line/hello1.pdl

Tool settings in pyproject.toml

[tool.pdl-lint]

# list of files or directories. Default: [ ]
ignore = [
  # - ignores this specific PDL file
  "tests/data/line/hello.pdl",

  # - ignores all PDL files within this directory (and sub-directories)
  "tests/a-dir",
]

# - File that pdl-lint should use to log information. Default: None.
log_file = "pdl-lint.log"

# - Log-level to use when logging to the file. Default: "DEBUG".
file_log_level = "DEBUG"

# - Log format when logging to the file. Default: "%(asctime)s %(name)s: %(message)s"
file_log_format = "%(asctime)s %(name)s: %(message)s"

# - Whether to log to console. Default: True
console_log_enabled = True

# - Log-level to use when logging to the console. Default: "INFO"
console_log_level = "INFO"

# - Log format when logging to console. Default: "%(message)s"
console_log_format = "%(message)s"

# - Single flag to turn all logging to debug. Default: False
debug = False

NOTE: Any additional properties in this section will be ignored. A warning will be shown instead to let the user know that the additional properties have no effect on this tool.

CLI Usage

usage: pdl-lint [-h] [-r] [--debug | --no-debug] [-l LOG_FILE] [paths ...]

positional arguments:
  paths                 The path(s) to lint.

options:
  -h, --help            show this help message and exit
  -r, --recursive       Lint all PDL files in the directory recursively. NOTE: This is only applicable when linting for files in a directory.
  --debug               Enable debug logging.
  --no-debug            Disable debug logging.
  -l LOG_FILE, --log-file LOG_FILE
                        The file to log to.

Testing done

I used uv instead of pip directly. But, I believe it has the same effect.

uv sync --all-extras --all-groups
uv run pytest tests
uv run pre-commit run --all-files

All tests, except those that depend on ollama, ran successfully. The error I get for the failing tests are shown below.

E       AssertionError: Unexpected runtime error: ['examples/chatbot/chatbot.pdl', 'examples/code/code-eval.pdl', 'examples/code/code-json.pdl', 'examples/code/code.pdl', 'examples/demo/1-hello.pdl', 'examples/demo/10-sdg.pdl', 'examples/demo/2-model-chaining.pdl', 'examples/demo/3-def-use.pdl', 'examples/demo/4-function.pdl', 'examples/demo/5-code-eval.pdl', 'examples/demo/6-code-json.pdl', 'examples/demo/7-chatbot-roles.pdl', 'examples/demo/8-tools.pdl', 'examples/demo/9-react.pdl', 'examples/fibonacci/fib.pdl', 'examples/rag/tfidf_rag.pdl', 'examples/react/demo.pdl', 'examples/sdk/hello.pdl', 'examples/teacher/teacher.pdl', 'examples/tools/calc.pdl', 'examples/tutorial/calling_llm.pdl', 'examples/tutorial/calling_llm_chaining.pdl', 'examples/tutorial/calling_llm_with_input.pdl', 'examples/tutorial/calling_llm_with_input_messages.pdl', 'examples/tutorial/calling_llm_with_input_messages_var.pdl', 'examples/tutorial/code_pdl.pdl', 'examples/tutorial/defs.pdl', 'examples/tutorial/function_definition.pdl', 'examples/tutorial/function_empty_context.pdl', 'examples/tutorial/muting_block_output.pdl', 'examples/tutorial/parser-regex.pdl', 'examples/tutorial/parser_regex_code.pdl', 'examples/tutorial/programs/chatbot.pdl', 'examples/tutorial/programs/code-json.pdl', 'examples/tutorial/programs/tfidf_rag.pdl', 'examples/tutorial/programs/weather.pdl', 'examples/tutorial/variable_def_use.pdl']
E       assert 37 == 0
E        +  where 37 = len(['examples/chatbot/chatbot.pdl', 'examples/code/code-eval.pdl', 'examples/code/code-json.pdl', 'examples/code/code.pdl', 'examples/demo/1-hello.pdl', 'examples/demo/10-sdg.pdl', ...])

tests/test_examples_run.py:259: AssertionError
--------------------------------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------------------------------
Error during the evaluation of Who is${ NAME }?: 'NAME' is undefined
Error during the evaluation of ${ I }: 'I' is undefined
Error during the evaluation of ${ I }: 'I' is undefined
Type errors during spec checking:
tests/data/line/hello3.pdl:6 -  World! should be of type <class 'int'>
Values inside the For block must be lists.
Error during the evaluation of ${ QUESTION }: 'QUESTION' is undefined
Type errors during spec checking:
tests/data/line/hello17.pdl:3 - hello should be of type <class 'int'>
Error during the evaluation of ${ QUESTION1 }: 'QUESTION1' is undefined
Values inside the For block must be lists.
Type errors during spec checking:
tests/data/line/hello16.pdl:8 - 30 should be of type <class 'str'>
Type errors in result of function call to ${ translate }:
tests/data/line/hello14.pdl:25 - Bonjour le monde! should be of type <class 'int'>
Type errors during spec checking:
tests/data/line/hello12.pdl:9 - How are you? should be of type <class 'bool'>
Error during the evaluation of ${ J == 5 }: 'J' is undefined
Type errors during spec checking:
tests/data/line/hello13.pdl:9 - 1 should be of type <class 'str'>
Error during 'watsonx_text/ibm/granite-34b-code-instruct' model call: litellm.APIConnectionError: API key is required
Traceback (most recent call last):
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/main.py", line 2762, in completion
    response = base_llm_http_handler.completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 223, in completion
    headers = provider_config.validate_environment(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/llms/watsonx/common_utils.py", line 187, in validate_environment
    token = _generate_watsonx_token(api_key=api_key, token=token)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/llms/watsonx/common_utils.py", line 75, in _generate_watsonx_token
    token = generate_iam_token(api_key)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/llms/watsonx/common_utils.py", line 43, in generate_iam_token
    raise ValueError("API key is required")
ValueError: API key is required

Lists inside the For block must be of the same length.
Error during the evaluation of ${ QUESTION1 }: 'QUESTION1' is undefined
Error during the evaluation of Hello,${ GEN1 }: 'GEN1' is undefined
Error during the evaluation of ${ models }: 'models' is undefined
Error during the evaluation of ${ boolean }: 'boolean' is undefined
Type errors during spec checking:
tests/data/line/hello9.pdl:3 - hello should be of type <class 'int'>
examples/demo/5-code-eval.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/demo/1-hello.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
>>> examples/demo/7-chatbot-roles.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/demo/6-code-json.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/demo/4-function.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/demo/9-react.pdl: model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/demo/3-def-use.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/demo/10-sdg.pdl: model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/demo/2-model-chaining.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/demo/8-tools.pdl: model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/sdk/hello.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/teacher/teacher.pdl: model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
Enter/Paste your content. Ctrl-D to save it.
Please provide an input: Please provide an input: examples/tutorial/calling_llm_with_input_messages_var.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/function_empty_context.pdl: model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
Type errors during spec checking:
examples/tutorial/type_list.pdl:0 - ['hello', 'world'] is expected to be empty
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
Enter/Paste your content. Ctrl-D to save it.
examples/tutorial/calling_llm.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/code_pdl.pdl: Error during 'ollama_chat/granite3.2:2b' model call: litellm.APIConnectionError: Cannot connect to host localhost:11434 ssl:default [Connect call failed ('127.0.0.1', 11434)]
Traceback (most recent call last):
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1115, in _wrap_create_connection
    sock = await aiohappyeyeballs.start_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 122, in start_connection
    raise first_exception
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 73, in start_connection
    sock = await _connect_sock(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 208, in _connect_sock
    await loop.sock_connect(sock, address)
  File "/usr/lib/python3.12/asyncio/selector_events.py", line 651, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/selector_events.py", line 691, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 11434)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/main.py", line 470, in acompletion
    response = await init_response
               ^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/llms/ollama_chat.py", line 607, in ollama_acompletion
    raise e  # don't use verbose_logger.exception, if exception is raised
    ^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/llms/ollama_chat.py", line 542, in ollama_acompletion
    resp = await session.post(**_request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/client.py", line 703, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 548, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1056, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1400, in _create_direct_connection
    raise last_exc
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1369, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1130, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:11434 ssl:default [Connect call failed ('127.0.0.1', 11434)]

Error during 'ollama_chat/granite3.2:2b' model call: litellm.APIConnectionError: Cannot connect to host localhost:11434 ssl:default [Connect call failed ('127.0.0.1', 11434)]
Traceback (most recent call last):
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1115, in _wrap_create_connection
    sock = await aiohappyeyeballs.start_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 122, in start_connection
    raise first_exception
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 73, in start_connection
    sock = await _connect_sock(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 208, in _connect_sock
    await loop.sock_connect(sock, address)
  File "/usr/lib/python3.12/asyncio/selector_events.py", line 651, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/selector_events.py", line 691, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 11434)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/main.py", line 470, in acompletion
    response = await init_response
               ^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/llms/ollama_chat.py", line 607, in ollama_acompletion
    raise e  # don't use verbose_logger.exception, if exception is raised
    ^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/litellm/llms/ollama_chat.py", line 542, in ollama_acompletion
    resp = await session.post(**_request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/client.py", line 703, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 548, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1056, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1400, in _create_direct_connection
    raise last_exc
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1369, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/prompt-declaration-language/.venv/lib/python3.12/site-packages/aiohttp/connector.py", line 1130, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:11434 ssl:default [Connect call failed ('127.0.0.1', 11434)]

examples/tutorial/calling_llm_with_input.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/muting_block_output.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/function_definition.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/calling_llm_chaining.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/variable_def_use.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/parser_regex_code.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/defs.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/parser-regex.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/calling_llm_with_input_messages.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/fibonacci/fib.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/code/code-json.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/code/code.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/code/code-eval.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tools/calc.pdl: model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/react/demo.pdl: model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:8b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/rag/tfidf_rag.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
What is your query?
examples/chatbot/chatbot.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
Error during the evaluation of Given the following code:
```python
${code_line}

and the following error:
${error_msg}
Please repair the code!
: 'code_line' is undefined
What is your query?
examples/tutorial/programs/chatbot.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/programs/code-json.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/programs/tfidf_rag.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
examples/tutorial/programs/weather.pdl: model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat
model 'ollama_chat/granite3.2:2b' encountered ConnectError('[Errno 99] Cannot assign requested address') trying to POST against http://localhost:11434/api/chat

@mandel
Copy link
Collaborator

mandel commented Apr 7, 2025

That is great, thank you @vite-falcon!

To be able to merge your PR, we would need the DCO to pass. If you click on this test, you will see the instructions on how to sign the commit.

It would be also good if the other static checks pass. To fix the formatting and execute the static check locally, you can execute

pre-commit run --all-files

Let me know if you need help for any of this.

@vite-falcon vite-falcon force-pushed the feat/vite-falcon/pdl-linter branch from 4e6ff82 to 09a23cf Compare April 7, 2025 17:13
@vite-falcon
Copy link
Contributor Author

Thank you for looking into this @mandel! Let me fix those issues. I think I missed to run the pre-commit after a last minute change.

@vite-falcon vite-falcon force-pushed the feat/vite-falcon/pdl-linter branch from 09a23cf to a202a3d Compare April 7, 2025 20:54
@vite-falcon
Copy link
Contributor Author

@mandel Refreshed the commit to pass all checks.

@mandel
Copy link
Collaborator

mandel commented Apr 8, 2025

That is great!!!

Thanks @vite-falcon!

@mandel mandel merged commit 39ffaa8 into IBM:main Apr 8, 2025
7 checks passed
@vite-falcon vite-falcon deleted the feat/vite-falcon/pdl-linter branch April 8, 2025 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants