mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
feat(vertex_ai_anthropic.py): support response_schema for vertex ai anthropic calls
allows passing response_schema for anthropic calls. supports schema validation.
This commit is contained in:
parent
432b7ae264
commit
aac912d3f8
6 changed files with 189 additions and 48 deletions
|
@ -13,7 +13,12 @@ def validate_schema(schema: dict, response: str):
|
|||
|
||||
from litellm import JSONSchemaValidationError
|
||||
|
||||
response_dict = json.loads(response)
|
||||
try:
|
||||
response_dict = json.loads(response)
|
||||
except json.JSONDecodeError:
|
||||
raise JSONSchemaValidationError(
|
||||
model="", llm_provider="", raw_response=response, schema=response
|
||||
)
|
||||
|
||||
try:
|
||||
validate(response_dict, schema=schema)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue