Vibeleaderboard
← All Intel
Intel / repo

python-genai v3.4.0

Source
github.com
Author
release-please[bot]
Date

Context

Several fixes in version 3.4.0 of google-genai, the Python library Google DeepMind publishes for the Gemini API, change how it reads streamed responses (release notes). Three of the fixes concern one job: cutting the incoming stream into the separate JSON chunks the model sends. When a response streams as server-sent events, each chunk arrives on lines that begin with `data:`, and a blank line ends it, so splitting the stream in the wrong place breaks a chunk in two, and missing a boundary merges two chunks into one.

The library had relied on the line readers built into its HTTP clients. One fix makes it end a line only at a carriage return, a line feed or the two together. Its tests put the Unicode line and paragraph separators (U+2028 and U+2029) and the next-line character (U+0085) inside a model's text, characters that Python's general also treats as line breaks, and check that the text now arrives intact. Another fix removes a length cap on lines read through the optional aiohttp client. The old code read each line with a 4 MiB limit (2^22 bytes), and the new test streams an inline-data chunk, the form a response uses to carry media such as an image, more than twice that size and checks that it arrives whole. A third applies when a stream arrives as raw JSON lines instead: the library collects lines until the curly braces balance, and it now ignores braces inside JSON strings, so a chunk whose text contains a brace, as code often does, is no longer merged with the next one.

Other fixes are for asynchronous code. The retry delay for async file uploads used the blocking time.sleep, which paused every task on the event loop while it waited; it now awaits asyncio.sleep. The async httpx clients keep a separate connection pool for each event loop; the async client's finalizer, which runs when the client is garbage-collected, no longer schedules a close task that is never awaited; and the Vertex AI Live API looks up its credentials off the event loop and caches them.

The new features are mostly in the Interactions API, Gemini's newer interface for conversations and steps. The release adds types for tool search, which lets the model load tool definitions on demand instead of receiving all of them up front, and the JavaScript library's 3.4.0 adds the same types. Code that imports agent, webhook, trigger or environment names from google.genai.interactions now gets a DeprecationWarning; the commit says to import them from google.genai.agents, google.genai.webhooks, google.genai.triggers or google.genai.environments, because the old names may be removed in a future release.

Terms in this piece · Glossary
  • chunking — Splitting documents into passages small enough to embed and retrieve individually — the step that quietly determines whether retrieval works at all.
  • AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
  • embedding — A list of numbers representing a piece of text's meaning, so that similar meanings end up numerically close and can be searched.
  • streaming — Sending a model's response token by token as it is generated, so the reader sees text immediately instead of waiting for the whole answer.
More from release-please[bot]
Recommended reads
Comments

Checking sign-in…

Loading comments…