mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Add transcription fields to session events
This change introduces `input_transcription` and `output_transcription` fields to session events, enabling the storage and retrieval of transcription data in both the database and Vertex AI session services. Closes #3172 Co-authored-by: Hangfei Lin <hangfei@google.com> PiperOrigin-RevId: 834366848
This commit is contained in:
committed by
Copybara-Service
parent
0ac35b23dc
commit
3ad30a58f9
@@ -271,6 +271,12 @@ class StorageEvent(Base):
|
|||||||
)
|
)
|
||||||
error_message: Mapped[str] = mapped_column(String(1024), nullable=True)
|
error_message: Mapped[str] = mapped_column(String(1024), nullable=True)
|
||||||
interrupted: Mapped[bool] = mapped_column(Boolean, nullable=True)
|
interrupted: Mapped[bool] = mapped_column(Boolean, nullable=True)
|
||||||
|
input_transcription: Mapped[dict[str, Any]] = mapped_column(
|
||||||
|
DynamicJSON, nullable=True
|
||||||
|
)
|
||||||
|
output_transcription: Mapped[dict[str, Any]] = mapped_column(
|
||||||
|
DynamicJSON, nullable=True
|
||||||
|
)
|
||||||
|
|
||||||
storage_session: Mapped[StorageSession] = relationship(
|
storage_session: Mapped[StorageSession] = relationship(
|
||||||
"StorageSession",
|
"StorageSession",
|
||||||
@@ -337,6 +343,14 @@ class StorageEvent(Base):
|
|||||||
storage_event.citation_metadata = event.citation_metadata.model_dump(
|
storage_event.citation_metadata = event.citation_metadata.model_dump(
|
||||||
exclude_none=True, mode="json"
|
exclude_none=True, mode="json"
|
||||||
)
|
)
|
||||||
|
if event.input_transcription:
|
||||||
|
storage_event.input_transcription = event.input_transcription.model_dump(
|
||||||
|
exclude_none=True, mode="json"
|
||||||
|
)
|
||||||
|
if event.output_transcription:
|
||||||
|
storage_event.output_transcription = (
|
||||||
|
event.output_transcription.model_dump(exclude_none=True, mode="json")
|
||||||
|
)
|
||||||
return storage_event
|
return storage_event
|
||||||
|
|
||||||
def to_event(self) -> Event:
|
def to_event(self) -> Event:
|
||||||
@@ -366,6 +380,12 @@ class StorageEvent(Base):
|
|||||||
citation_metadata=_session_util.decode_model(
|
citation_metadata=_session_util.decode_model(
|
||||||
self.citation_metadata, types.CitationMetadata
|
self.citation_metadata, types.CitationMetadata
|
||||||
),
|
),
|
||||||
|
input_transcription=_session_util.decode_model(
|
||||||
|
self.input_transcription, types.Transcription
|
||||||
|
),
|
||||||
|
output_transcription=_session_util.decode_model(
|
||||||
|
self.output_transcription, types.Transcription
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -512,6 +512,14 @@ async def test_append_event_complete(service_type, tmp_path):
|
|||||||
),
|
),
|
||||||
citation_metadata=types.CitationMetadata(),
|
citation_metadata=types.CitationMetadata(),
|
||||||
custom_metadata={'custom_key': 'custom_value'},
|
custom_metadata={'custom_key': 'custom_value'},
|
||||||
|
input_transcription=types.Transcription(
|
||||||
|
text='input transcription',
|
||||||
|
finished=True,
|
||||||
|
),
|
||||||
|
output_transcription=types.Transcription(
|
||||||
|
text='output transcription',
|
||||||
|
finished=True,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
await session_service.append_event(session=session, event=event)
|
await session_service.append_event(session=session, event=event)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user