docs(vertex.md): add vertex ai grounding to docs

This commit is contained in:
Krrish Dholakia 2024-07-08 21:45:17 -07:00
parent 458e4d6a70
commit aec5c20a0d

View file

@ -330,6 +330,51 @@ Return a `list[Recipe]`
completion(model="vertex_ai_beta/gemini-1.5-flash-preview-0514", messages=messages, response_format={ "type": "json_object" }) completion(model="vertex_ai_beta/gemini-1.5-flash-preview-0514", messages=messages, response_format={ "type": "json_object" })
``` ```
### **Grounding**
Add Google Search Result grounding to vertex ai calls.
<Tabs>
<TabItem value="sdk" label="SDK">
```python
from litellm import completion
## SETUP ENVIRONMENT
# !gcloud auth application-default login - run this to add vertex credentials to your env
tools = [{"googleSearchRetrieval": {}}] # 👈 ADD GOOGLE SEARCH
resp = litellm.completion(
model="vertex_ai_beta/gemini-1.0-pro-001",
messages=[{"role": "user", "content": "Who won the world cup?"}],
tools=tools,
)
print(resp)
```
</TabItem>
<TabItem value="proxy" label="PROXY">
```bash
curl http://0.0.0.0:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Who won the world cup?"}],
"tools": [
{
"googleSearchResults": {}
}
]
}'
```
</TabItem>
</Tabs>
## Pre-requisites ## Pre-requisites
* `pip install google-cloud-aiplatform` (pre-installed on proxy docker image) * `pip install google-cloud-aiplatform` (pre-installed on proxy docker image)
* Authentication: * Authentication: