mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
docs(vertex.md): add 'response_schema' param to vertex docs
This commit is contained in:
parent
8d9352258f
commit
3dea5dce86
1 changed files with 39 additions and 0 deletions
|
|
@ -123,6 +123,45 @@ print(completion(**data))
|
|||
|
||||
### **JSON Schema**
|
||||
|
||||
From v`1.40.1+` LiteLLM supports sending `response_schema` as a param for Gemini-Pro-1.5 on Vertex AI.
|
||||
|
||||
```python
|
||||
from litellm import completion
|
||||
import json
|
||||
|
||||
## SETUP ENVIRONMENT
|
||||
# !gcloud auth application-default login - run this to add vertex credentials to your env
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "List 5 popular cookie recipes."
|
||||
}
|
||||
]
|
||||
|
||||
response_schema = {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"recipe_name": {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"required": ["recipe_name"],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
completion(
|
||||
model="vertex_ai_beta/gemini-1.5-pro",
|
||||
messages=messages,
|
||||
response_format={"type": "json_object", "response_schema": response_schema} # 👈 KEY CHANGE
|
||||
)
|
||||
|
||||
print(json.loads(completion.choices[0].message.content))
|
||||
```
|
||||
|
||||
```python
|
||||
from litellm import completion
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue