guardrails
guardrails copied to clipboard
non-working input standardization
This does not currently work.
This pr attempts to use input/output mapping to deal with LLMs in a more generic way. What I've discovered is that there's simply too much going on with both our existing implementation as well as in individual LLM clients. I think that overhauling to this level is too big a change for the minor version update with regards to the risk and testing surface area involved.
This PR is missing a few key parts:
- mapping inputs for the injection of schema and reask instructions
- dealing with function calling
- testing around streaming, async
Fundamentally, I do think this approach can work, and is a better mapping solution than the one that we currently have since in some ways it's "looser". It does not include recreating clients or trying to type-match into them, which I think is a huge benefit from a maintainability perspective.
All that being said, I would propose a difference in deliverables for 0.4.3 that I think are still achievable, help with debug scenarios, and keep backwards compatability without being too huge a change. However, I only think these changes are appropriate if we do necessary pruning on 0.5.0.
0.4.3
- make the
__call__
llm_api
callable optional. When it is optional, we pass through information to a LiteLLM client we create internally - expose a
naked_llm_call
function onguard
. This function would have inputs styled the same way we style__call__
inputs, but purely uses our internal mapping to make a call to the LLM without guarding. This would help users debug and translate from their call pattern to the guard-style call pattern.
0.5.0
- delete all custom mappings in llm_providers other than OpenAICallable, LiteLLMCallable, and Sync/AsycnBaseCallable
- make clear in docs that those callables are the only supported ones. If you have a callable other than those and don't want to wrap in a BaseCallable, then orchestrate your own llm api callable and
- remove msg_history, prompt, instructions. Expect
messages
for BaseCallable. For everything else, pass through args as is - in OpenAI, cohere, and anthropic, never recreate a client
- get rid of old openai versions across the codebase
- create 1 doc notebook with examples for each llm type present in llms.py
- support streaming and asycn for openai and litellm callables natively but through a similar output mapping strategy as found in this PR.
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This PR was closed because it has been stalled for 14 days with no activity.