Skip to content

Commit 72c5ebf

Browse files
authored
Merge pull request #156 from pipecat-ai/mb/fix-google-summary
fix: update generate_summary in the Google adapter to use the google-…
2 parents 7fbf11a + d86d02c commit 72c5ebf

2 files changed

Lines changed: 49 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- Addded a new optional `name` field to `NodeConfig`. When using dynamic flows alongside
13-
"consolidated" functions that return a tuple (result, next node), giving the next node a `name` is
14-
helpful for debug logging. If you don't specify a `name`, an automatically-generated UUID is used.
12+
- Addded a new optional `name` field to `NodeConfig`. When using dynamic flows
13+
alongside "consolidated" functions that return a tuple (result, next node),
14+
giving the next node a `name` is helpful for debug logging. If you don't
15+
specify a `name`, an automatically-generated UUID is used.
1516

1617
- Added support for providing "consolidated" functions, which are responsible
1718
for both doing some work as well as specifying the next node to transition
@@ -30,7 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3031
result = await process(foo, bar)
3132

3233
# Specify next node (optional; this function may be a work-only function)
33-
# This is either a NodeConfig (for dynamic flows) or a node name (for static flows)
34+
# This is either a NodeConfig (for dynamic flows) or a node name (for
35+
# static flows)
3436
next_node = create_another_node()
3537

3638
return result, next_node
@@ -97,23 +99,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9799
)
98100
```
99101

100-
### Deprecated
101-
102-
- Deprecated `transition_to` and `transition_callback` in favor of "consolidated" `handler`s that
103-
return a tuple (result, next node). Alternatively, you could use "direct" functions and avoid
104-
using `FlowsFunctionSchema`s or function definition dicts entirely. See the "Added" section above
105-
for more details.
106-
107-
- Deprecated `set_node()` in favor of doing the following for dynamic flows:
108-
109-
- Prefer "consolidated" or "direct" functions that return a tuple (result, next node) over
110-
deprecated `transition_callback`s
111-
- Pass your initial node to `FlowManager.initialize()`
112-
- If you really need to set a node explicitly, use `set_node_from_config()`
113-
114-
In all of these cases, you can provide a `name` in your new node's config for debug logging
115-
purposes.
116-
117102
### Changed
118103

119104
- `functions` are now optional in the `NodeConfig`. Additionally, for AWS
@@ -128,16 +113,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
128113
be removed in a future version. The `tts_say` action now pushes a
129114
`TTSSpeakFrame`.
130115

116+
- Deprecated `transition_to` and `transition_callback` in favor of
117+
"consolidated" `handler`s that return a tuple (result, next node).
118+
Alternatively, you could use "direct" functions and avoid using
119+
`FlowsFunctionSchema`s or function definition dicts entirely. See the "Added"
120+
section above for more details.
121+
122+
- Deprecated `set_node()` in favor of doing the following for dynamic flows:
123+
124+
- Prefer "consolidated" or "direct" functions that return a tuple (result,
125+
next node) over deprecated `transition_callback`s
126+
- Pass your initial node to `FlowManager.initialize()`
127+
- If you really need to set a node explicitly, use `set_node_from_config()`
128+
129+
In all of these cases, you can provide a `name` in your new node's config for
130+
debug logging purposes.
131+
131132
### Fixed
132133

134+
- Fixed an issue where `RESET_WITH_SUMMARY` wasn't working for the
135+
`GeminiAdapter`. Now, the `GeminiAdapter` uses the `google-genai` package,
136+
aligning with the package used by `pipecat-ai`.
137+
133138
- Fixed an issue where if `run_in_parallel=False` was set for the LLM, the bot
134139
would trigger N completions for each sequential function call. Now, Flows
135140
uses Pipecat's internal function tracking to determine when there are more
136141
edge functions to call.
137142

138-
- Overhauled `pre_actions` and `post_actions` timing logic, making their timing more predictable and
139-
eliminating some bugs. For example, now `tts_say` actions will always run after the bot response,
140-
when used in `post_actions`.
143+
- Overhauled `pre_actions` and `post_actions` timing logic, making their timing
144+
more predictable and eliminating some bugs. For example, now `tts_say`
145+
actions will always run after the bot response, when used in `post_actions`.
141146

142147
## [0.0.17] - 2025-05-16
143148

src/pipecat_flows/adapters.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,30 @@ async def generate_summary(
462462
) -> Optional[str]:
463463
"""Generate summary using Google's API directly."""
464464
try:
465-
# Format messages for Gemini
465+
from google.genai.types import Content, GenerateContentConfig, Part
466+
467+
# Format conversation history as user message
466468
contents = [
467-
{
468-
"role": "user",
469-
"parts": [{"text": (f"{summary_prompt}\n\nConversation history: {messages}")}],
470-
}
469+
Content(role="user", parts=[Part(text=f"Conversation history: {messages}")])
471470
]
472471

473-
# Use non-streaming completion
474-
response = await llm._client.generate_content_async(contents=contents, stream=False)
472+
# Use summary_prompt as system instruction
473+
generation_config = GenerateContentConfig(system_instruction=summary_prompt)
475474

476-
return response.text
475+
# Use the new google-genai client's async method
476+
response = await llm._client.aio.models.generate_content(
477+
model=llm._model_name,
478+
contents=contents,
479+
config=generation_config,
480+
)
481+
482+
# Extract text from response
483+
if response.candidates and response.candidates[0].content:
484+
for part in response.candidates[0].content.parts:
485+
if part.text:
486+
return part.text
487+
488+
return None
477489

478490
except Exception as e:
479491
logger.error(f"Google summary generation failed: {e}", exc_info=True)

0 commit comments

Comments
 (0)