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
18 changes: 2 additions & 16 deletions pipelines/google/google_gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
author_url: https://github.com/owndev/
project_url: https://github.com/owndev/Open-WebUI-Functions
funding_url: https://github.com/sponsors/owndev
version: 1.9.0
version: 1.9.1
required_open_webui_version: 0.6.26
license: Apache License 2.0
description: Highly optimized Google Gemini pipeline with advanced image generation capabilities, intelligent compression, and streamlined processing workflows.
Expand Down Expand Up @@ -1786,8 +1786,6 @@ async def _process_grounding_metadata(
grounding_metadata_list: List[types.GroundingMetadata],
text: str,
__event_emitter__: Callable,
*,
emit_replace: bool = True,
):
"""Process and emit grounding metadata events."""
grounding_chunks = []
Expand Down Expand Up @@ -1855,17 +1853,8 @@ async def _process_grounding_metadata(
cited_chunks.append(text_bytes[last_byte_index:].decode(ENCODING))

replaced_text = "".join(cited_chunks)
if emit_replace:
await __event_emitter__(
{
"type": "replace",
"data": {"content": replaced_text},
}
)

# Return the transformed text when requested by caller
if not emit_replace:
return replaced_text if replaced_text is not None else text
return replaced_text if replaced_text is not None else text

async def _handle_streaming_response(
self,
Expand Down Expand Up @@ -2003,12 +1992,10 @@ async def emit_chat_event(event_type: str, data: Dict[str, Any]) -> None:
# After processing all chunks, handle grounding data
final_answer_text = "".join(answer_chunks)
if grounding_metadata_list and __event_emitter__:
# Don't emit replace here; we'll compose final content below
cited = await self._process_grounding_metadata(
grounding_metadata_list,
final_answer_text,
__event_emitter__,
emit_replace=False,
)
final_answer_text = cited or final_answer_text

Expand Down Expand Up @@ -2386,7 +2373,6 @@ async def get_response():
grounding_metadata_list,
final_answer,
__event_emitter__,
emit_replace=False,
)
final_answer = cited or final_answer

Expand Down