[Python] Openai Agents: Best practice for adding references to each field in pydantic models

Discussão em 'Python' iniciado por Stack, Março 18, 2025.

  1. Stack

    Stack Membro Participativo

    What is the best practice for adding references/citations to agents using structured output?

    I have an output model that my agent will fill. The agent can use various tools (websearch, file, custom input etc)

    class CompanyHighlights(BaseModel):
    """
    Key numeric highlights about the company (ARR, active customers, valuation).
    """

    arr: str | None = Field(
    None, description="Annual Recurring Revenue, e.g. 'EUR xM'.", example="EUR 3M"
    )
    active_customers: str | None = Field(
    None,
    description="Number (or range) of active customers, e.g. '200'.",
    example="150 active customers",
    )
    current_valuation: str | None = Field(
    None,
    description="Approximate or official valuation, e.g. 'EUR xM'.",
    example="EUR 30M",
    )


    I know that I could either just add a new reference field to the model, or have each field as another model with it's own reference. But I'm curious if there's any best practice for this? Ideally it would be something like:

    arr: str | None = Field(None,
    description="Annual Recurring Revenue, e.g. 'EUR xM'.",
    example="EUR 3M",
    source = "Name of sources used to get this info: ['google.com','file1.pdf page 30']"
    )

    Continue reading...

Compartilhe esta Página