Replies: 4 comments 2 replies
-
From offline discussion: next steps:
|
Beta Was this translation helpful? Give feedback.
-
linking this item here - #681 |
Beta Was this translation helpful? Give feedback.
-
One more thing to consider for option 1 is output standardization. We've discussed output standardization in the past as something we'd like to do -- for option 1, this would require maintaining more of a mapping between LLMs and expected output types. |
Beta Was this translation helpful? Give feedback.
-
Hi @zsimjee - litellm maintainer here
What are we missing currently? We should be 1:1 compatible with openai Happy to accelerate any pending work on this, from our end |
Beta Was this translation helpful? Give feedback.
-
Summary
This document explores problems with how guardrails currently expects LLM parameters to be passed through inputs. It suggests a strategy of standardizing and improving the way guardrails operates with LLM APIs.
Motivation
This task requires that we standardize our approach to calling LLMs. This is because it’s confusing to use guardrails right now with different models, and historically, we have not been able to keep up with changing interfaces from different libraries.
Interfaces
Different LLM libraries have different ways of constructing llm clients than those that work with guardrails, and this makes it harder to add guardrails to an existing project. An example of this is the new OpenAI 1.X standard. In this standard, users are expected to create a client, then use that client’s APIs to make requests out to OpenAI. The Guardrails way to do this is to not initialize the client, but instead to pass raw client creator pulled off the openai import, a pattern which is not used in any openai docs. The way message history is passed also differs between the two.
OpenAI Client
Guardrails Client
Recently, litellm was added to the guardrails project as a way to help standardize this situation. While this did make it easier to deal with different LLM apis, it still does not have parity with openai
Standardizing inputs
The main interface differences between Guardrails and OpenAI are the use of
prompt
andmsg_history
. Guardrails tries to be flexible by allowing either of these fields to be passed to both chat endpoints and regular completion endpoints. The package makes sure that in an invocation ofGuard.__call__
, one of these fields must be present. While initially a good usability feature, this may now be a cause for confusion. Guardrails also usesmodel
which is fairly standard. Other inputs includetemperature
andmax_tokens
, which are also standard. See Apendix A for a breakdown of how different LLMs accept these parameters.Detailed design
Guardrails will remove standard support for
prompt
,msg_history
, and other LLM arguments altogether.Currently, guardrails tries to find these input arguments to
To do these things consistently, guardrails standardizes those fields, and tries to map back and forth between these param types and downstream LLM param types. This is what causes a lot of confusion and compatability issues.
Using this option, guardrails can avoid these issues of mapping to client-specific params (i.e. get rid of
llm_providers
).Instead, guardrails should keep track of two lists of kwargs
guardrails.__call__
specific keywords - reask etc...prompt
,input
,instruction
,messages
,message_history
)Instead of mapping parameter names back and forth, guardrials will always maintain the params passed to the
__call__
function (i.e. closest to the original API) and make requests to the LLM API callable using those mapped values.This would change the call workflow from
to
Specifically, the workflow would follow these steps
__call__
guardrails
specific args (reask
, etc)This strategy would confer a few key benefits
Drawbacks
The goal of this project does not have significant drawbacks other than the cost of hte phased implementation to maintain backwards compatibility. There are a few drawbacks with this specific solution though:
Alternatives
Int his alternative option, guardrials standardizes on the LiteLLM style of input handling - accepting
messages
as a parameter. This negates the need for ANY mapping to occur within the guardrails package, and simplifies our approach. Instead, we can route all requests directly through LiteLLMPros
Cons:
Adoption Strategy
This may seem like a backwards incompatible change, but that can be managed as such
prompt
,msg_history
, andinstructions
as input params for prompt. We also implement the majority of the passthrough strategy.How we teach this
Docs must all be updated to reflect the new strategy. It’s still advantageous to lean heavily on LiteLLM where we can, and we should try to educate by pointing towards openai first, then litellm for more advanced usecases
Beta Was this translation helpful? Give feedback.
All reactions