mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-14 09:51:25 -06:00
don't send content with empty text to LLM
PiperOrigin-RevId: 753869699
This commit is contained in:
parent
6c0a0d69ca
commit
d387ab0c38
@ -15,9 +15,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from typing import AsyncGenerator
|
from typing import AsyncGenerator, Generator, Optional
|
||||||
from typing import Generator
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from google.genai import types
|
from google.genai import types
|
||||||
from typing_extensions import override
|
from typing_extensions import override
|
||||||
@ -202,8 +200,14 @@ def _get_contents(
|
|||||||
# Parse the events, leaving the contents and the function calls and
|
# Parse the events, leaving the contents and the function calls and
|
||||||
# responses from the current agent.
|
# responses from the current agent.
|
||||||
for event in events:
|
for event in events:
|
||||||
if not event.content or not event.content.role:
|
if (
|
||||||
# Skip events without content, or generated neither by user nor by model.
|
not event.content
|
||||||
|
or not event.content.role
|
||||||
|
or not event.content.parts
|
||||||
|
or event.content.parts[0].text == ''
|
||||||
|
):
|
||||||
|
# Skip events without content, or generated neither by user nor by model
|
||||||
|
# or has empty text.
|
||||||
# E.g. events purely for mutating session states.
|
# E.g. events purely for mutating session states.
|
||||||
continue
|
continue
|
||||||
if not _is_event_belongs_to_branch(current_branch, event):
|
if not _is_event_belongs_to_branch(current_branch, event):
|
||||||
|
Loading…
Reference in New Issue
Block a user