googleapis / googleapis/python-genai

Possible to return BOTH structured (application/json) and unstructured (markdown) output?

Aperta
#839 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub
type: feature request type: question
Lingua principale
Python
Stelle
4k
Fork
1k
Merge medio
2g 12h
PR unite (30g)
41

Descrizione

Is it possible for Gemini request to return BOTH structured (application/json) and unstructured (markdown) output in a single API call? The use case:

(1) Structured output for backend business logic process and DB persistence.

(2) Unstructured (markdown) to show it on the UI, maybe for human-in-the-loop validation of the data returned by the model.

For example, I have the following string / object returned:
```
{"message":"{\n \"date_str\": \"28-07-2017\",\n \"vendor\": \"Walmart\",\n \"currency\": \"USD\",\n \"items\": [\n {\n \"name\": \"PET TOY\",\n \"amount\": 1.97\n },\n {\n \"name\": \"FLOPPY PUPPY\",\n \"amount\": 1.97\n },\n {\n \"name\": \"SSSUPREME S\",\n \"amount\": 4.97\n },\n {\n \"name\": \"2.5 SQUEAK\",\n \"amount\": 5.92\n },\n {\n \"name\": \"MUNCHY DMBEL\",\n \"amount\": 3.77\n },\n {\n \"name\": \"DOG TREAT\",\n \"amount\": 2.92\n },\n {\n \"name\": \"PED PCH 1\",\n \"amount\": 0.50\n },\n {\n \"name\": \"PED PCH 1\",\n \"amount\": 0.50\n },\n {\n \"name\": \"COUPON 23100\",\n \"amount\": 1.00\n },\n {\n \"name\": \"HNYMD SMORES\",\n \"amount\": 3.98\n },\n {\n \"name\": \"FRENCH DRSNG\",\n \"amount\": 1.98\n },\n {\n \"name\": \"3 ORANGES\",\n \"amount\": 5.47\n },\n {\n \"name\": \"BABY CARROTS\",\n \"amount\": 1.48\n },\n {\n \"name\": \"COLLARDS\",\n \"amount\": 1.24\n },\n {\n \"name\": \"CALZONE\",\n \"amount\": 2.50\n },\n {\n \"name\": \"MM RVW MNT\",\n \"amount\": 19.77\n },\n {\n \"name\": \"STKOBRLPLABL\",\n \"amount\": 1.97\n },\n {\n \"name\": \"STKOBRLPLABL\",\n \"amount\": 1.97\n },\n {\n \"name\": \"STKO SUNFLWR\",\n \"amount\": 0.97\n },\n {\n \"name\": \"STKO SUNFLWR\",\n \"amount\": 0.97\n },\n {\n \"name\": \"STKO SUNFLWR\",\n \"amount\": 0.97\n },\n {\n \"name\": \"STKO SUNFLWR\",\n \"amount\": 0.97\n },\n {\n \"name\": \"BLING BEADS\",\n \"amount\": 0.97\n },\n {\n \"name\": \"GREAT VALUE\",\n \"amount\": 9.97\n },\n {\n \"name\": \"LIPTON\",\n \"amount\": 4.48\n },\n {\n \"name\": \"DRY DOG\",\n \"amount\": 12.44\n }\n ],\n \"tax\": 4.59,\n \"total\": 98.21\n}"}
```
and I try to use `showdown` javascript library to convert it to markdown and `makeHtml` but to no avail. What I get on the UI is only an unformatted json string and it is difficult to verify if the model has missed anything or introduced any hallunication in it's reasoning.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con il comportamento delle richieste e delle risposte di Gemini descritto nell’issue, incluso l’esempio di output strutturato e il tentativo di conversione con Showdown. Determina se una singola chiamata API può restituire sia JSON sia Markdown e considera il lavoro completo quando la capacità o la limitazione è stata stabilita chiaramente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, python
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.