Skip to content

Feature Idea: Structured Output for Tools #49

Not planned
@OskarStark

Description

@OskarStark
Contributor

Description:

I’d like to suggest a feature that enables structured output for tools when interacting with the model. Currently, the model decides how to format and display the results, which may not always fit specific needs. This feature would allow users to specify the desired output format for their tools.

Example:

In my case, I have a tool that fetches products from my API and presents them to the user. However, I don’t want the model to decide the structure of the output. Instead, I’ve specified a JSON schema that dictates the format of the response.

For instance, the result would look something like this:

{
  "type": "products",
  "products": [
    {
      "name": "Product 1",
      "url": "https://example.com/product1",
      "price": 29.99
    },
    {
      "name": "Product 2",
      "url": "https://example.com/product2",
      "price": 49.99
    }
  ]
}

With this response, my frontend knows which renderer to use.

Expected Behavior:

  • The model should follow the given JSON schema when returning the result.
  • The user should have the ability to predefine how the output is structured, without the model altering it.

This would improve consistency and allow for more flexible tool integrations.

Activity

chr-hertel

chr-hertel commented on Sep 26, 2024

@chr-hertel
Member

could potentially be an easy pick after #47 with an extension like #[AsTool('product_search', ... , outputStructure: Product::class)] 🤔

chr-hertel

chr-hertel commented on Sep 29, 2024

@chr-hertel
Member

Nailing it down to:

  • extension of tool parameters with json schema rules like minLength or regex pattern
  • enable output structure on llm call with tool result in ChainProcessor of ToolBox
OskarStark

OskarStark commented on Oct 2, 2024

@OskarStark
ContributorAuthor

extension of tool parameters with json schema rules like minLength or regex pattern

Done in #75

enable output structure on llm call with tool result in ChainProcessor of ToolBox

Work in progress in #74

chr-hertel

chr-hertel commented on Jan 5, 2025

@chr-hertel
Member

Still valid or obsolete @OskarStark?

OskarStark

OskarStark commented on Jan 6, 2025

@OskarStark
ContributorAuthor

Could be a nice addition, but not needed for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @OskarStark@chr-hertel

      Issue actions

        Feature Idea: Structured Output for Tools · Issue #49 · php-llm/llm-chain