Move Bundles to Interface system and call it Provider Operations Type

Created on 17 June 2024, about 1 year ago

Problem/Motivation

Currently the bundles are Enums that might be problematic because they are not extedable and can't really have any functions attached to it. Also bundles is a very generic name, operation type, which becomes provider operation type is easy to understand what the purpose is.

We should move this to a interface system with a base operation type, that defines a base normalized input provider interface and base output provider interface with a required normalize function in it, that each of the operations must integrate.

The inputter will however take both any normalized interface that the operator creates or any mixed input for ease of use.

The invokeResponse will then be in charge of normalizing the input and the output, so that you can have metadata attached to the output. This will make sure that both the case of having any type of operation being agnostic is possible, but for people that just want the quick fix to use the array in and array out method from OpenAI, this is also possible.

Proposed resolution

  • Create a OperationsTypeInterface that is what is today the enum bundle that is a Plugin system. This will have two methods (at least for now), that is inputInterface and outputInterface, that set the interface for that specific bundle (see below).
  • Switch so that the LlmProviderInterfaces sets which operators it can take.
  • Create a NormalizedInputInterface that has no methods at all.
  • On the $input require mixed or a Interface that implements the NormalizedInputInterface.
  • Add a method to the LlmProviderInterfaces that is called normalizeInput that takes an NormalizedInputInterface and normalizes this into the format that specific provider requires.
  • Create a NormalizedOutputInterface that has the method validateNormalizedOutput that validates the normalized output for the operation, metadata that stores an array of any metadata the API might create.
  • Add a method to the LlmProviderInterface that is called normalizeOutput that takes an answer and normalizes it according to the documented normalization in the NormalizedOutputInterface and then validates it and also takes metadata that the provider might need.

Discussion

This will not make all solutions work out of the box and in certain cases that can be a good thing. For instance an ElevenLabs TextToSpeech would require you to take a choice of the voice you want to use. We can set the requirement that required values have to have a default value, but in the case that you use ElevenLabs you 99% of the cases want to take a choice here.

In a future where this is the default value for any audiotory discussion bot for producing website via spoken communication, we can of course have a default configuration exposes, much like we will have a default provider from the get go.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany marcus_johansson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024