Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Idea: Structured Output for Tools #49

Closed
OskarStark opened this issue Sep 25, 2024 · 5 comments
Closed

Feature Idea: Structured Output for Tools #49

OskarStark opened this issue Sep 25, 2024 · 5 comments

Comments

@OskarStark
Copy link
Contributor

OskarStark commented Sep 25, 2024

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.

@chr-hertel
Copy link
Member

chr-hertel commented Sep 26, 2024

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

@chr-hertel
Copy link
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
Copy link
Contributor Author

OskarStark commented Oct 2, 2024

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
Copy link
Member

Still valid or obsolete @OskarStark?

@OskarStark
Copy link
Contributor Author

Could be a nice addition, but not needed for now

@OskarStark OskarStark closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants