Skip to content

Commit

Permalink
Merge pull request #752 from pipecat-ai/mb/google-context-message-con…
Browse files Browse the repository at this point in the history
…version

Use Google Gemini message format when adding message to the LLM context
  • Loading branch information
markbackman authored Nov 27, 2024
2 parents 98c0a6e + 3c19a7a commit c5324df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated STT and TTS services with language options that match the supported
languages for each service.

### Fixed

- Fixed Google Gemini message handling to properly convert appended messages to Gemini's required format

## [0.0.49] - 2024-11-17

### Added
Expand Down
16 changes: 16 additions & 0 deletions src/pipecat/services/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,22 @@ def set_messages(self, messages: List):
self._messages[:] = messages
self._restructure_from_openai_messages()

def add_messages(self, messages: List):
# Convert each message individually
converted_messages = []
for msg in messages:
if isinstance(msg, glm.Content):
# Already in Gemini format
converted_messages.append(msg)
else:
# Convert from standard format to Gemini format
converted = self.from_standard_message(msg)
if converted is not None:
converted_messages.append(converted)

# Add the converted messages to our existing messages
self._messages.extend(converted_messages)

def get_messages_for_logging(self):
msgs = []
for message in self.messages:
Expand Down

0 comments on commit c5324df

Please sign in to comment.