googleapis / googleapis/python-genai

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

Offen
#839 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
type: feature request type: question
Vorherrschende Sprache
Python
Sterne
4k
Forks
1k
Ø Merge
2 T. 12 Std.
Gemergte PRs (30 T.)
41

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem in der Issue beschriebenen Verhalten von Gemini bei Requests und Responses, einschließlich des Beispiels für strukturierte Ausgaben und der versuchten Showdown-Konvertierung. Ermittle, ob ein einzelner API-Aufruf sowohl JSON als auch Markdown zurückgeben kann, und betrachte die Arbeit als abgeschlossen, sobald die Möglichkeit oder Einschränkung eindeutig festgestellt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, python
Bereich
api
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.