googleapis / googleapis/google-cloud-java
Add built-in support for exposing the response schema as a structured object map
- Linguagem predominante
- Java
- Estrelas
- 2.1k
- Forks
- 1.2k
- Merge médio
- 1d 23h
- PRs com merge (30d)
- 157
Descrição
**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.
Guia de contribuição
Direção de pesquisa
Comece rastreando os pontos de entrada do Java Vertex AI SDK mencionados na issue: generateContent(), ContentMaker, GenerationConfig e GenerateContentResponse. Compare como os schemas de resposta e o JSON são tratados atualmente e, em seguida, defina a API e os testes necessários para a exposição do schema e o parsing de POJO, Map ou Protobuf tipados. A tarefa estará concluída quando os metadados de resposta selecionados e o comportamento de parsing estiverem especificados e cobertos por testes.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- google-cloud, java
- Domínio
- api, machine-learning
- Tipo de issue
- Funcionalidade
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 32/100