pydantic / pydantic-ai

MIT License
78 stars 4 forks source link

Examples builder #93

Open samuelcolvin opened 22 hours ago

samuelcolvin commented 22 hours ago

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" />
...
"""

?

jxnl commented 22 hours ago

im 99% sure is the first one

jxnl commented 22 hours ago
Screenshot 2024-11-25 at 2 39 08 PM

When you ask Claw to generate new meeting notes, this is basically what it will do: very, very simple XML.