Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions google/generativeai/types/generation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,27 +351,27 @@ def rewrite_stream_error():
)


GENERATE_CONTENT_RESPONSE_DOC = """Instances of this class manage the response of the `generate_content_async` method.
GENERATE_CONTENT_RESPONSE_DOC = """Instances of this class manage the response of the `generate_content` method.

These are returned by `GenerativeModel.generate_content_async` and `ChatSession.send_message_async`.
These are returned by `GenerativeModel.generate_content` and `ChatSession.send_message`.
This object is based on the low level `glm.GenerateContentResponse` class which just has `prompt_feedback`
and `candidates` attributes. This class adds several quick accessors for common use cases.

The same object type is returned for both `stream=True/False`.

### Streaming

When you pass `stream=True` to `GenerativeModel.generate_content_async` or `ChatSession.send_message_async`,
When you pass `stream=True` to `GenerativeModel.generate_content` or `ChatSession.send_message`,
iterate over this object to receive chunks of the response:

```
response = model.generate_content_async(..., stream=True):
async for chunk in response:
response = model.generate_content(..., stream=True):
for chunk in response:
print(chunk.text)
```

`AsyncGenerateContentResponse.prompt_feedback` is available immediately but
`AsyncGenerateContentResponse.candidates`, and all the attributes derived from them (`.text`, `.parts`),
`GenerateContentResponse.prompt_feedback` is available immediately but
`GenerateContentResponse.candidates`, and all the attributes derived from them (`.text`, `.parts`),
are only available after the iteration is complete.
"""

Expand Down