[FEAT] Implement day2-04 ReAct Agent with llama-index on Vertex AI - #31
Merged
Conversation
Collaborator
Author
|
ちょっとアレンジできないか考え中 |
Migrate ReAct Agent tutorial from Anthropic Claude to Vertex AI Gemini using llama-index framework. ## Changes - Add llama-index dependencies (core, llms-gemini, embeddings-gemini) - Implement complete notebook.py with 19 cells: - Section 1: Calculator tools (multiply, add) with ReActAgent - Section 2: RAG with QueryEngine tools (Uber/Lyft 10K filings) - Create comprehensive README.md with setup, usage, and hands-on tasks - Add helper module src/agent.py with tool functions - Remove plan.md as implementation is complete ## Technical Stack - LLM: Gemini 2.5 Flash (Vertex AI) - Embeddings: Gemini text-embedding-004 - Framework: llama-index ReActAgent - Tools: FunctionTool, QueryEngineTool ## Reference Based on: https://platform.claude.com/cookbook/third-party-llamaindex-react-agent Adapted for Vertex AI (Anthropic Claude → Google Gemini) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix f-string without placeholders (F541) - Apply ruff format to notebook.py and src/agent.py - Add trailing commas and fix line lengths Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ShuN6211
force-pushed
the
feat/day2-04-react-agent-llama-index
branch
from
April 27, 2026 07:08
06a7c5d to
930d3ed
Compare
The VectorStoreIndex cell had no dependency on the Settings cell, so marimo could execute it before embed_model was configured, causing it to fall back to the default OpenAI embeddings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The old llama-index-llms-gemini package uses the deprecated google.generativeai SDK which causes PERMISSION_DENIED on Vertex AI. Migrate to llama-index-llms-google-genai and llama-index-embeddings-google-genai with vertexai_config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ReActAgent.from_tools() was removed in llama-index-core 0.14. Use the new workflow-based API: ReActAgent(tools=..., llm=...) from llama_index.core.agent.workflow. Agent calls are now async (await agent.run()) and response is at response.response.content. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SimpleDirectoryReader was reading PDFs as raw binary because the PDF reader dependencies were missing. This caused RAG queries to fail with "context is unreadable" responses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add PDF parsing explanation (pypdf + llama-index-readers-file) - Add VectorStoreIndex 3-step process explanation (chunking, embedding, storage) - Remove Function Calling comparison sections - Add .gitignore for data/ directory Changes: - notebook.py: Add PDF data size info and VectorStoreIndex explanation cells - README.md: Update learning objectives, remove comparison section - .gitignore: Exclude data/ directory Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ShuN6211
force-pushed
the
feat/day2-04-react-agent-llama-index
branch
from
April 27, 2026 11:41
3ee8175 to
96ff411
Compare
Changed from showing first 800 characters to full prompt (2041 chars) to avoid cutting off in the middle of important instructions. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed from markdown code blocks to "--- system prompt ---" delimiter for better readability in the notebook. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Use stream_events() to capture and display the ReAct agent's reasoning process (Thought, Action, Observation) for both calculator and RAG agents. Changes: - notebook.py: Collect events and display in markdown with code blocks - notebook_script.py: Stream events and print to console in real-time - Set verbose=False (was True) since stream_events provides better output Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Move VectorStoreIndex chunking explanation from explain_chunking.py reference to README.md - Add comprehensive "VectorStoreIndex のチャンキング詳細" section in README - Update notebook.py to reference README instead of explain_chunking.py explain_chunking.py and test_rag.py remain as local development tools (not in git). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…zation 参加者がカスタマイズできるプロダクション品質の ReAct エージェントベースラインを追加 主な機能: - Tool開発: 新しいツールの追加方法(subtract の例で動作確認済み) - Prompt Tuning: エージェントの動作・口調変更(カスタムプロンプト例付き) - LLMパラメータ調整: temperature, model の変更方法 技術スタック: - 純粋な Python パッケージ(marimo なし) - main.py エントリポイント(uv run main.py で実行) - プロダクション品質コード(型ヒント、完全な docstring) - モジュール化された構造(src/tools.py, src/agent.py) 他の day2 モジュールとの違い: - notebook.py なし(スクリプト実行のみ) - 教育的ログなし(クリーンな出力) - カスタマイズに焦点を当てた設計 04-react-agent の修正: - black フォーマット適用 - ruff E402 対応(nest_asyncio.apply() の後のインポート) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ShuN6211
commented
Apr 27, 2026
day2/04-react-agent/README.md: - Remove QueryEngineツールの作成 section (Line 147) - Remove ストリーミングレスポンス task (Line 183) - Remove メモリ不足 section (Line 310) day2/07-own_agent/README.md: - Remove "プロダクション品質" from description (Line 3) - Simplify temperature descriptions (Line 275, 277) - Change section title from "エージェントが無限ループする" to "Trouble shoot" (Line 441) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Use explicit re-export (as syntax) instead of __all__ to satisfy ruff lint Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrate ReAct Agent tutorial from Anthropic Claude to Vertex AI Gemini using llama-index framework.
Changes
Dependencies
llama-index-core>=0.13.0llama-index-llms-gemini>=0.4.0llama-index-embeddings-gemini>=0.2.0Implementation
src/agent.pywith tool functions and utilitiesplan.mdas implementation is completeFeatures
agent.get_prompts()to view internal promptsTechnical Stack
Reference
Based on: https://platform.claude.com/cookbook/third-party-llamaindex-react-agent
Adapted for Vertex AI (Anthropic Claude → Google Gemini)
Test Plan
uv syncpython -m py_compile)Verification
cd day2/04-react-agent uv sync uv run marimo edit notebook.py🤖 Generated with Claude Code