pydantic-ai icon indicating copy to clipboard operation
pydantic-ai copied to clipboard

Examples builder

Open samuelcolvin opened this issue 1 year ago • 4 comments

We plan to add an examples builder which would take a sequence of things (e.g. pydantic models, dataclasses, dicts etc.) and serialize them.

Usage would be something like

from pydantic_ai import format_examples

@agent.system_prompt
def foobar():
    return f'the examples are:\n{format_examples(examples, dialect='xml')}'

The suggest is that LLMs find it particularly easy to read XML, so we'll offer (among other formats) XML as way to format the examples.

By default, should it use

"""
<example>
  <input>
    show me values greater than 5
  </input>
  <sql>
    SELECT * FROM table WHERE value > 5
  </sql>
</example>
...
"""

or

"""
<example input="show me values greater than 5" sql="SELECT * FROM table WHERE value > 5" />
...
"""

?

samuelcolvin avatar Nov 25 '24 19:11 samuelcolvin