googleapis / googleapis/python-genai

System Instruction Error

Offen
#425 13 Kommentare 2 Reaktionen 1 zugewiesene Person Beansprucht von @jaycee-li Auf GitHub ansehen
priority: p2 type: bug
Vorherrschende Sprache
Python
Sterne
4k
Forks
1k
Ø Merge
2 T. 12 Std.
Gemergte PRs (30 T.)
41

Beschreibung

I kept trying this pattern:

```python
from google import genai
from google.genai import types
client = genai.Client()

response = client.models.generate_content_stream(
model='gemini-2.0-flash',
contents='Tell me a story in 100 words.',
config=types.GenerateContentConfig(
system_instruction='you are a story teller for kids under 5 years old',
max_output_tokens= 400,
temperature= 0
)
)
```

but I got this error from the API non stop (Invalid JSON payload received. Unknown name \\"systemInstruction\\"):

```text
Error in stream_chat_response: API Error 400: b'{\n "error": {\n "code": 400,\n "message": "Invalid JSON payload received. Unknown name \\"systemInstruction\\": Cannot find field.",\n "status": "INVALID_ARGUMENT",\n "details": [\n {\n "@type": "type.googleapis.com/google.rpc.BadRequest",\n "fieldViolations": [\n {\n "description": "Invalid JSON payload received. Unknown name \\"systemInstruction\\": Cannot find field."\n }\n ]\n }\n ]\n }\n}\n'
```

The old SDK works perfectly: https://github.com/google-gemini/generative-ai-python

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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