Skip to content

Version 0.9.0

Latest

Choose a tag to compare

@mandel mandel released this 10 Nov 04:37
· 10 commits to main since this release
v0.9.0
a68bc88

New Features

The main new features are:

  • contribute to a file or standard input and error
  • @pdl Python decorator

contribute to files

The user can declare a file aggregator that can be used in the contribute to accumulate the results of the blocks.
For example, in the following program, an aggregator named log associated to the file /tmp/log.txt is declared.
This aggregator is used to store the output of the model in the file /tmp/log.txt.

defs:
  log:
    aggregator: 
      file: /tmp/log.txt
text:
- Hello
- model: ollama_chat/granite3.3:2b
  contribute: [ result, context, log ]

By default, the aggregator stdin and stderr are available to contribute to the standard input and standard error.
It is useful, for example to outpout debug information. In the following program, the raw output of the model is emitted
on the standard error:

text:
- Hello
- model: ollama_chat/granite3.3:2b
  modelResponse: raw_response
  contribute:
    - result
    - context
    - stderr:
        value: ${raw_response}

@pdl Python decorator

In order to make it easy to define functions as PDL programs, we provide a @pdl decorator.

from pdl.pdl import pdl

@pdl
def chain_of_thought(scope):
    """
    lastOf:
    - "Question: ${ question }\n"
    - "Answer: Let's think step by step. "
    - model: ollama_chat/granite3.3:2b
      parameters:
          stop:
          - "<|endoftext|>"
          - "Question:"
          include_stop_sequence: false
    """
    return

def main():
    result = chain_of_thought(
        scope={"model": "ollama_chat/granite3.2:2b", 
               "question": "How to write Hello World in OCaml?\n"}
    )
    print(result)

if __name__ == "__main__":
    main()

In this example, the function chain_pf_thought is a string representing a PDL program. The free variables in the string are values passed in the dictionary scope given on argument.

What's Changed

Full Changelog: v0.8.0...v0.9.0