0xPlaygrounds / 0xPlaygrounds/rig

feat: Use gRPC APIs for Gemini + xAI

Đang mở
#1,201 8 bình luận 5 reaction 0 người được giao Xem trên GitHub
feat
Ngôn ngữ chính
Rust
Star
8.6k
Fork
959
Merge trung bình
4 giờ 32 phút
Pull request đã merge (30 ngày)
117

Mô tả

## Feature Request
Use the gRPC API for the Rig model providers that expose gRPC APIs (currently Google (Gemini Direct API) and xAI)

Docs + proto sources:
- Google Gemini Direct API (REST/gRPC) docs:
- https://ai.google.dev/gemini-api/docs/partner-integration
- Google proto source (Gemini / Generative Language API):
- https://github.com/googleapis/googleapis/blob/master/google/ai/generativelanguage/v1beta/generative_service.proto
- xAI gRPC docs + proto sources:
- https://docs.x.ai/docs/grpc-reference
- https://github.com/xai-org/xai-proto
- https://github.com/xai-org/xai-proto/blob/736b835b0c0dd93698664732daad49f87a2fbc6f/proto/xai/api/v1/chat.proto

### Motivation
- Protobuf is strongly typed, more performant to de/serialize than JSON, smaller than JSON, easy to generate via the `tonic` crate and backwards compatible

### Proposal
- Use the gRPC backend for the existing `gemini` and `xai` providers instead of the current REST backend
- Implementation outline:
- Use `tonic` + `prost` (or equivalent) to generate clients from the upstream protos.
- Google:
- Generate a client for `google.ai.generativelanguage.v1beta.GenerativeService` from the googleapis proto.
- Attach `x-goog-api-key` (and optionally `x-goog-api-client` for identification) metadata headers.
- xAI:
- Generate clients from `xai-org/xai-proto` and connect to `api.x.ai` with `Authorization: Bearer ` metadata.
- Map Rig’s existing request/response types to/from the proto messages; preserve existing streaming APIs (`stream_prompt`, etc.) by adapting gRPC streaming responses into Rig’s stream types.

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

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

Hướng nghiên cứu

The issue requires generating gRPC clients from the provided proto files for Google Gemini and xAI using the `tonic` and `prost` crates. Start by examining the existing `gemini` and `xai` provider implementations in the codebase to understand the current REST API integration. Then, map Rig's request/response types to the generated proto messages, ensuring streaming support is maintained. Testing will involve verifying the new gRPC connections work with the respective authentication headers.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
grpc, rust
Lĩnh vực
ai-infra-agents, api, backend
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
40/100

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.