googleapis / googleapis/google-cloud-java
Add built-in support for exposing the response schema as a structured object map
- 主要語言
- Java
- 星號
- 2.1k
- 分支
- 1.2k
- 平均合併
- 1 天 23 小時
- 30 天內合併 PR
- 157
描述
**Is your feature request related to a problem? Please describe.**
Currently, when using the Java Vertex AI SDK’s `generateContent()` (e.g. via `ContentMaker`), we only get back a raw JSON string. Client code must separately construct a JSON Schema, attach it in `GenerationConfig`, then manually parse the returned JSON—either via Jackson’s `ObjectMapper` or via Protobuf’s `JsonFormat`. This boilerplate is brittle, error-prone, and hides what fields the model will actually return.
**Describe the solution you’d like**
1. Expose the active response schema programmatically. For example:
```java
Schema schema = model.getResponseSchema();
```
or as metadata on `GenerateContentResponse`.
2. Provide a one-step parser that binds the response into a POJO, Map, or Protobuf message, e.g.
```java
MyResult result = response.getTypedContent(MyResult.class);
```
under the hood handling all JSON Schema validation and mapping.
**Describe alternatives you’ve considered**
* Continuing to manually wire up JSON Schema definitions + `GenerationConfig`.
* Writing custom helper utilities in each codebase to wrap `ObjectMapper` or `JsonFormat`.
* Using generic `Map` parsing and then casting fields at runtime.
**Additional context**
* Sample desired usage:
```java
Schema schema = model.getResponseSchema();
MyResponse resp = model.generateContent(prompt, config)
.getTypedContent(MyResponse.class);
```
* This would eliminate repetitive boilerplate, reduce parsing errors, and let developers discover response fields at compile time.
貢獻指南
研究方向
首先追蹤 issue 中指定的 Java Vertex AI SDK 進入點:generateContent()、ContentMaker、GenerationConfig 和 GenerateContentResponse。比較目前如何處理回應 schema 和 JSON,然後定義 schema 公開以及具型別 POJO、Map 或 Protobuf 解析所需的 API 和測試。完成的標準是:選定的回應中繼資料和解析行為都已明確規範,並由測試涵蓋。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- google-cloud, java
- 領域
- api, machine-learning
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 32/100