From cafe2243b5cfb941271d6fffd6f92914cf799baa Mon Sep 17 00:00:00 2001 From: Shahin Saadati Date: Mon, 8 Dec 2025 16:02:35 -0800 Subject: [PATCH 1/3] Formatted podcast_transcript_agent with black and isort. --- .../podcast_transcript_agent/__init__.py | 1 - .../podcast_transcript_agent/agent.py | 3 ++- .../models/podcast_plan.py | 7 ++++++- .../models/podcast_topics.py | 5 +++++ .../models/podcast_transcript.py | 17 ++++++++++++++--- .../podcast_episode_planner/__init__.py | 1 - .../sub_agents/podcast_episode_planner/agent.py | 6 +++--- .../sub_agents/podcast_topics/__init__.py | 3 --- .../sub_agents/podcast_topics/agent.py | 7 ++++--- .../podcast_transcript_writer/__init__.py | 2 -- .../podcast_transcript_writer/agent.py | 10 +++++----- .../tests/test_agents.py | 17 +++++++---------- 12 files changed, 46 insertions(+), 33 deletions(-) diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/__init__.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/__init__.py index 8ce90a27b..c48963cdc 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/__init__.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/__init__.py @@ -13,4 +13,3 @@ # limitations under the License. from . import agent - diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/agent.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/agent.py index 1a5563516..0cdaccd96 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/agent.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/agent.py @@ -13,8 +13,9 @@ # limitations under the License. from google.adk.agents import SequentialAgent -from .sub_agents.podcast_topics import podcast_topics_agent + from .sub_agents.podcast_episode_planner import podcast_episode_planner_agent +from .sub_agents.podcast_topics import podcast_topics_agent from .sub_agents.podcast_transcript_writer import ( podcast_transcript_writer_agent, ) diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_plan.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_plan.py index 1a8ceca70..e0154ccd6 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_plan.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_plan.py @@ -13,16 +13,21 @@ # limitations under the License. from typing import List -from pydantic import BaseModel + from podcast_transcript_agent.models.podcast_transcript import PodcastSpeaker +from pydantic import BaseModel + class Segment(BaseModel): """A model for a 'main_segment', which includes a title.""" + title: str script_points: List[str] + class PodcastEpisodePlan(BaseModel): """Represents the entire episode, containing a title and a list of segments.""" + episode_title: str speakers: List[PodcastSpeaker] segments: List[Segment] diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_topics.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_topics.py index 62e6ed6f5..82b4eb88d 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_topics.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_topics.py @@ -13,15 +13,20 @@ # limitations under the License. from typing import List + from pydantic import BaseModel + class Topic(BaseModel): """A model for a podcast topic, which includes a title, description, and key facts.""" + topic_name: str description: str key_facts: list[str] + class PodcastTopics(BaseModel): """A model for the main topic and sub-topics of a podcast episode.""" + main_topic: str sub_topics: List[Topic] diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_transcript.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_transcript.py index f92775cde..39fcf32e5 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_transcript.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/models/podcast_transcript.py @@ -14,35 +14,46 @@ from typing import List + from pydantic import BaseModel + class SpeakerDialogue(BaseModel): """A model for a speaker's dialogue, including the speaker's ID and the text of the dialogue.""" + speaker_id: str text: str + class PodcastSegment(BaseModel): """A model for a podcast segment, which includes a title, start and end times of the segment (in seconds), and a list of speaker dialogues.""" + segment_title: str title: str start_time: float end_time: float speaker_dialogues: List[SpeakerDialogue] + class PodcastSpeaker(BaseModel): """A model for a podcast speaker, including their ID, name, and role.""" + speaker_id: str name: str role: str - + + class PodcastMetadata(BaseModel): """A model for the podcast's metadata, including the episode title, duration, and summary.""" + episode_title: str duration_seconds: int summary: str + class PodcastTranscript(BaseModel): """A model for a podcast transcript, which includes metadata, speakers, and segments.""" - metadata: PodcastMetadata + + metadata: PodcastMetadata speakers: List[PodcastSpeaker] - segments: List[PodcastSegment] \ No newline at end of file + segments: List[PodcastSegment] diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/__init__.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/__init__.py index ff4d1c9e5..85e8f180f 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/__init__.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/__init__.py @@ -13,4 +13,3 @@ # limitations under the License. from .agent import podcast_episode_planner_agent - diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/agent.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/agent.py index 083144cd1..f3ad118ac 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/agent.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/agent.py @@ -13,9 +13,9 @@ # limitations under the License. from google.adk.agents import Agent -from . import prompt from podcast_transcript_agent.models.podcast_plan import PodcastEpisodePlan +from . import prompt podcast_episode_planner_agent = Agent( name="podcast_episode_planner_agent", @@ -23,5 +23,5 @@ description="Plans the podcast episode based on extracted topics", instruction=prompt.PODCAST_EPISODE_PLANNER_PROMPT, output_schema=PodcastEpisodePlan, - output_key="podcast_episode_plan" -) \ No newline at end of file + output_key="podcast_episode_plan", +) diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/__init__.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/__init__.py index 0c0288112..a63b64047 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/__init__.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/__init__.py @@ -13,6 +13,3 @@ # limitations under the License. from .agent import podcast_topics_agent - - - diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/agent.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/agent.py index 9887f9708..9072051ec 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/agent.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/agent.py @@ -13,14 +13,15 @@ # limitations under the License. from google.adk.agents import Agent -from . import prompt from podcast_transcript_agent.models.podcast_topics import PodcastTopics +from . import prompt + podcast_topics_agent = Agent( name="podcast_topics_agent", model="gemini-2.5-flash", description="Extracts podcast topics from provided input", - instruction= prompt.TOPIC_EXTRACTION_PROMPT, + instruction=prompt.TOPIC_EXTRACTION_PROMPT, output_schema=PodcastTopics, - output_key="podcast_topics" + output_key="podcast_topics", ) diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/__init__.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/__init__.py index 539f1cea3..eaab42ba9 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/__init__.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/__init__.py @@ -13,5 +13,3 @@ # limitations under the License. from .agent import podcast_transcript_writer_agent - - diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/agent.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/agent.py index 35cd80dd3..1bbf7da14 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/agent.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/agent.py @@ -13,15 +13,15 @@ # limitations under the License. from google.adk.agents import Agent -from . import prompt from podcast_transcript_agent.models.podcast_transcript import PodcastTranscript -podcast_transcript_writer_agent = Agent( +from . import prompt + +podcast_transcript_writer_agent = Agent( name="podcast_transcript_writer_agent", model="gemini-2.5-flash", description="Writes the podcast transcript based on the podcast plan", instruction=prompt.PODCAST_TRANSCRIPT_WRITER_PROMPT, output_schema=PodcastTranscript, - output_key="podcast_episode_transcript" - ) - + output_key="podcast_episode_transcript", +) diff --git a/python/agents/podcast_transcript_agent/tests/test_agents.py b/python/agents/podcast_transcript_agent/tests/test_agents.py index 135504430..025e29cf6 100644 --- a/python/agents/podcast_transcript_agent/tests/test_agents.py +++ b/python/agents/podcast_transcript_agent/tests/test_agents.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json +from pathlib import Path + +import dotenv import pytest from google.adk.runners import InMemoryRunner -from podcast_transcript_agent.agent import podcast_transcript_agent -from pathlib import Path from google.genai import types -import dotenv -import json +from podcast_transcript_agent.agent import podcast_transcript_agent @pytest.fixture(scope="session", autouse=True) @@ -46,9 +47,7 @@ async def test_run_with_txt(): ) ), types.Part( - inline_data=types.Blob( - mime_type="text/plain", data=file_content - ) + inline_data=types.Blob(mime_type="text/plain", data=file_content) ), ] ) @@ -75,6 +74,4 @@ async def test_run_with_txt(): if data["metadata"]["duration_seconds"] > 0: found_valid_transcript = True - assert ( - found_valid_transcript - ), "No final event found with valid transcript metadata" + assert found_valid_transcript, "No final event found with valid transcript metadata" From 167c182fd42efdf40147feb4ea7c9f1136219937 Mon Sep 17 00:00:00 2001 From: Shahin Saadati Date: Mon, 8 Dec 2025 16:05:11 -0800 Subject: [PATCH 2/3] Reformatted the podcast-transcript-agent sample by ensuring black, isort, and flake8 pass --- .../podcast_transcript_agent/__init__.py | 2 +- .../sub_agents/podcast_episode_planner/__init__.py | 2 +- .../sub_agents/podcast_topics/__init__.py | 2 +- .../sub_agents/podcast_transcript_writer/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/__init__.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/__init__.py index c48963cdc..626296e25 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/__init__.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from . import agent +from . import agent # noqa: F401 diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/__init__.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/__init__.py index 85e8f180f..5887755a4 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/__init__.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_episode_planner/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .agent import podcast_episode_planner_agent +from .agent import podcast_episode_planner_agent # noqa: F401 diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/__init__.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/__init__.py index a63b64047..beb5e68f4 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/__init__.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_topics/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .agent import podcast_topics_agent +from .agent import podcast_topics_agent # noqa: F401 diff --git a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/__init__.py b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/__init__.py index eaab42ba9..c99122a2f 100644 --- a/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/__init__.py +++ b/python/agents/podcast_transcript_agent/podcast_transcript_agent/sub_agents/podcast_transcript_writer/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .agent import podcast_transcript_writer_agent +from .agent import podcast_transcript_writer_agent # noqa: F401 From a5477fa1f417b9f69ca451d7144c923edd97ca7e Mon Sep 17 00:00:00 2001 From: Shahin Saadati Date: Thu, 8 Jan 2026 13:48:11 -0800 Subject: [PATCH 3/3] Applied " black . --line-length 80" --- .../agents/podcast_transcript_agent/tests/test_agents.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/agents/podcast_transcript_agent/tests/test_agents.py b/python/agents/podcast_transcript_agent/tests/test_agents.py index 025e29cf6..c8355b31c 100644 --- a/python/agents/podcast_transcript_agent/tests/test_agents.py +++ b/python/agents/podcast_transcript_agent/tests/test_agents.py @@ -47,7 +47,9 @@ async def test_run_with_txt(): ) ), types.Part( - inline_data=types.Blob(mime_type="text/plain", data=file_content) + inline_data=types.Blob( + mime_type="text/plain", data=file_content + ) ), ] ) @@ -74,4 +76,6 @@ async def test_run_with_txt(): if data["metadata"]["duration_seconds"] > 0: found_valid_transcript = True - assert found_valid_transcript, "No final event found with valid transcript metadata" + assert ( + found_valid_transcript + ), "No final event found with valid transcript metadata"