rig icon indicating copy to clipboard operation
rig copied to clipboard

feat: extractor api improvements

Open 0xMochan opened this issue 3 months ago • 2 comments

  • [x] I have looked for existing issues (including closed) about this

Feature Request

  • Extractors exist as a wrapper on top of agents with a pre-made tool. Since it constructs and abstracts the agent away, this means you can't customize the agent. This is a problem for anthropic as anthropic requires max_tokens to be set atm. This is also quite restrictive in other regards.

  • Extractors are also missing the prompt trait in general making them less composible (as per the feat/agentic-chains branch).

  • Extractors only work with full types and not with any serde_json::Value which means things like Vec<MyType>, bool, etc won't work.

  • Lastly, extractors are built with the use of tools to produce a json output but with the release of json-mode and similar in many providers (like OpenAI, etc), it might be suitable for provider specific or customizable extractors that make use of that feature rather than a custom tool. This customizability isn't really hit within our extractor implementation.

Proposal

Rather than Extractor being a whole struct, I wonder if .extract::<Type>(...) would be a better api. Or some other Extractor trait based on the provider that can be written (otherwise using a default tool implementation) to make this a bit more seemless. It seems like a general extractor improvements branch is in order.

Alternatives

Keeping the Extractor struct but making the agent exposable or even configurable. All the bugs could be fixed in the current implementation.

0xMochan avatar Nov 28 '24 20:11 0xMochan