googleapis / googleapis/python-aiplatform

Add support for custom headers in vertexai.init function

Đang mở
#3,526 0 bình luận 8 reaction 0 người được giao Xem trên GitHub
api: vertex-ai
Ngôn ngữ chính
Python
Star
905
Fork
465
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
44

Mô tả

**Is your feature request related to a problem? Please describe.**
I cannot find option for adding custom headers to VertexAI Gemini API.

**Describe the solution you'd like**
I'm trying to implement proxy between end client and VertexAI Gemini API. In my implementation custom HTTP headers are must have requirement. I would like to ask for adding option to vertexai.init or any other place to add HTTP headers, similar as it is in genai gemini library.
**Describe alternatives you've considered**
Actually there are no alternatives. Headers are must have.
**Additional context**
Example for custom headers in google.generativeai (https://github.com/google/generative-ai-python)
```
import google.generativeai as genai
genai.configure(
api_key="mytoken",
transport="rest",
client_options={
"api_endpoint": "https://my/custom/proxy"
},
default_metadata=tuple(my_headers.items()),
)
```

My proposal for vertexai.init:
```
import vertexai
from vertexai.generative_models import GenerativeModel
vertexai.init(
api_endpoint="https://my/custom/proxy",
api_transport="rest",
default_metadata=tuple(my_headers.items()), # New argument
)

multimodal_model = GenerativeModel("gemini-1.0-pro-vision")
response = multimodal_model.generate_content(
[
"How are you",
]
)
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.