Skip to content

Commit 8f16366

Browse files
authored
Feat add docstrings gemini fullstack (#200)
* feat: add docstring gemini fullstack, replace diagram * feat: add docstring gemini fullstack, replace diagram * feat: add docstring gemini fullstack, replace diagram
1 parent 641e715 commit 8f16366

File tree

5 files changed

+52
-28
lines changed

5 files changed

+52
-28
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ generate-lock:
1313
lint:
1414
uv run ruff check . --config pyproject.toml --diff
1515
uv run ruff format . --check --config pyproject.toml --diff
16-
uv run mypy --config-file pyproject.toml ./agents ./src/cli ./tests ./src/frontends/streamlit ./src/frontends/streamlit_adk
16+
uv run mypy --config-file pyproject.toml ./agents ./src/cli ./tests ./src/frontends/streamlit
1717

1818
lint-templated-agents:
1919
uv run tests/integration/test_template_linting.py

agents/adk_gemini_fullstack/README.md

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,29 @@
22

33
The **Gemini Fullstack Agent Development Kit (ADK) Quickstart** is a production-ready blueprint for building a sophisticated, fullstack research agent with Gemini. It's built to demonstrate how the ADK helps structure complex agentic workflows, build modular agents, and incorporate critical Human-in-the-Loop (HITL) steps.
44

5-
<div style="display: flex; align-items: center; justify-content: space-between;">
6-
<table style="width: 50%;">
7-
<thead>
8-
<tr>
9-
<th colspan="2">Key Features</th>
10-
</tr>
11-
</thead>
12-
<tbody>
13-
<tr>
14-
<td>🏗️</td>
15-
<td><strong>Fullstack & Production-Ready:</strong> A complete React frontend and ADK-powered FastAPI backend, with deployment options for <a href="https://cloud.google.com/run">Google Cloud Run</a> and <a href="https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/overview">Vertex AI Agent Engine</a>.</td>
16-
</tr>
17-
<tr>
18-
<td>🧠</td>
19-
<td><strong>Advanced Agentic Workflow:</strong> The agent uses Gemini to <strong>strategize</strong> a multi-step plan, <strong>reflect</strong> on findings to identify gaps, and <strong>synthesize</strong> a final, comprehensive report.</td>
20-
</tr>
21-
<tr>
22-
<td>🔄</td>
23-
<td><strong>Iterative & Human-in-the-Loop Research:</strong> Involves the user for plan approval, then autonomously loops through searching (via Gemini function calling) and refining its results until it has gathered sufficient information.</td>
24-
</tr>
25-
</tbody>
26-
</table>
27-
<div style="width: 45%;">
28-
<img src="../../docs/images/adk_gemini_fullstack_preview.png" width="100%" alt="Gemini Fullstack ADK Preview">
29-
</div>
30-
</div>
5+
<table>
6+
<thead>
7+
<tr>
8+
<th colspan="2">Key Features</th>
9+
</tr>
10+
</thead>
11+
<tbody>
12+
<tr>
13+
<td>🏗️</td>
14+
<td><strong>Fullstack & Production-Ready:</strong> A complete React frontend and ADK-powered FastAPI backend, with deployment options for <a href="https://cloud.google.com/run">Google Cloud Run</a> and <a href="https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/overview">Vertex AI Agent Engine</a>.</td>
15+
</tr>
16+
<tr>
17+
<td>🧠</td>
18+
<td><strong>Advanced Agentic Workflow:</strong> The agent uses Gemini to <strong>strategize</strong> a multi-step plan, <strong>reflect</strong> on findings to identify gaps, and <strong>synthesize</strong> a final, comprehensive report.</td>
19+
</tr>
20+
<tr>
21+
<td>🔄</td>
22+
<td><strong>Iterative & Human-in-the-Loop Research:</strong> Involves the user for plan approval, then autonomously loops through searching (via Gemini function calling) and refining its results until it has gathered sufficient information.</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
<img src="../../docs/images/adk_gemini_fullstack_preview.png" alt="Gemini Fullstack ADK Preview">
3128

3229
This project adapts concepts from the [Gemini FullStack LangGraph Quickstart](https://github.com/google-gemini/gemini-fullstack-langgraph-quickstart) for the frontend app.
3330

agents/adk_gemini_fullstack/app/agent.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@
2626

2727
# --- Structured Output Models ---
2828
class SearchQuery(BaseModel):
29+
"""Model representing a specific search query for web search."""
30+
2931
search_query: str = Field(
3032
description="A highly specific and targeted query for web search."
3133
)
3234

3335

3436
class Feedback(BaseModel):
37+
"""Model for providing evaluation feedback on research quality."""
38+
3539
grade: Literal["pass", "fail"] = Field(
3640
description="Evaluation result. 'pass' if the research is sufficient, 'fail' if it needs revision."
3741
)
@@ -46,6 +50,17 @@ class Feedback(BaseModel):
4650

4751
# --- Callbacks ---
4852
def collect_research_sources_callback(callback_context: CallbackContext) -> None:
53+
"""Collects and organizes web-based research sources and their supported claims from agent events.
54+
55+
This function processes the agent's `session.events` to extract web source details (URLs,
56+
titles, domains from `grounding_chunks`) and associated text segments with confidence scores
57+
(from `grounding_supports`). The aggregated source information and a mapping of URLs to short
58+
IDs are cumulatively stored in `callback_context.state`.
59+
60+
Args:
61+
callback_context (CallbackContext): The context object providing access to the agent's
62+
session events and persistent state.
63+
"""
4964
session = callback_context._invocation_context.session
5065
url_to_short_id = callback_context.state.get("url_to_short_id", {})
5166
sources = callback_context.state.get("sources", {})
@@ -99,6 +114,18 @@ def collect_research_sources_callback(callback_context: CallbackContext) -> None
99114
def citation_replacement_callback(
100115
callback_context: CallbackContext,
101116
) -> genai_types.Content:
117+
"""Replaces citation tags in a report with Markdown-formatted links.
118+
119+
Processes 'final_cited_report' from context state, converting tags like
120+
`<cite source="src-N"/>` into hyperlinks using source information from
121+
`callback_context.state["sources"]`. Also fixes spacing around punctuation.
122+
123+
Args:
124+
callback_context (CallbackContext): Contains the report and source information.
125+
126+
Returns:
127+
genai_types.Content: The processed report with Markdown citation links.
128+
"""
102129
final_report = callback_context.state.get("final_cited_report", "")
103130
sources = callback_context.state.get("sources", {})
104131

158 KB
Loading

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ log_cli_date_format = "%Y-%m-%d %H:%M:%S"
7272
[tool.ruff]
7373
line-length = 88
7474
target-version = "py310"
75-
include = ["./agents/**/*.py", "src/cli/**/*.py", "tests/**/*.py", "src/frontends/streamlit/**/*.py", "src/frontends/streamlit_adk/**/*.py"]
75+
include = ["./agents/**/*.py", "src/cli/**/*.py", "tests/**/*.py", "src/frontends/streamlit/**/*.py"]
7676
exclude = ["./agents/agentic_rag/**/*.py"]
7777

7878
[tool.ruff.lint]

0 commit comments

Comments
 (0)