Spaces:
Runtime error
Runtime error
Handbook Generator (AI Engineering Assignment)
Same technology as the policy project: Google ADK, LiteLLM (OpenAI), and Streamlit. The UI talks to the ADK agent directly (no API). The agent uses a RAG tool (ChromaDB) to answer from uploaded PDFs.
Features
- PDF upload β Upload PDFs; text is extracted, chunked, embedded (OpenAI), stored in ChromaDB (local).
- Chat β ADK agent runs in the same process; agent calls RAG tool
query_uploaded_documentsand answers with the LLM (OpenAI via LiteLLM). - Handbook generation β Request a 20,000+ word handbook; generation uses RAG and runs section-by-section.
- Export β Download the handbook as Markdown.
Architecture
- Streamlit (
streamlit_app.py) β UI; imports runner_app to run the agent directly. - runner_app.py β ADK Runner + session;
run_chat(message)runs the agent (sync wrapper aroundrunner.run_async). - agent.py β ADK Agent (LiteLLM/OpenAI), tools =
[query_uploaded_documents]. - RAG (
rag.py+rag_tools.py) β ChromaDB + OpenAI embeddings.
Setup
1. Python
Use Python 3.10+.
2. Install dependencies
cd ass2
pip install -r requirements.txt
3. Environment
Create a .env file in ass2 (see .env.example):
OPENAI_API_KEY=sk-your-openai-api-key-here
MODEL=gpt-4o
Run (single command)
cd ass2
streamlit run streamlit_app.py
Open http://localhost:8501. No separate API server.
How to use
- Upload PDFs β In "Upload PDFs", select PDFs and click Index PDFs.
- Chat β In "Chat", ask questions; the ADK agent uses the RAG tool and answers from your documents.
- Generate handbook β In "Generate Handbook", enter a topic and click Generate handbook, then download as Markdown.
Project structure (all in ass2)
| File | Purpose |
|---|---|
streamlit_app.py |
Streamlit UI (upload, chat, handbook) |
runner_app.py |
ADK Runner + session; run_chat(message) for Streamlit |
agent.py |
ADK agent (LiteLLM/OpenAI) + RAG tool |
prompt.py |
Agent name, description, instruction |
rag_tools.py |
ADK tool: query_uploaded_documents |
callback.py |
ADK callbacks |
rag.py |
ChromaDB + OpenAI embeddings |
pdf_processor.py |
PDF text extraction and chunking |
handbook_generator.py |
20k-word handbook generation |
config.py |
Settings and paths |
Tech stack
- Agent: Google ADK, LiteLLM (OpenAI)
- RAG: OpenAI embeddings, ChromaDB (local)
- UI: Streamlit (agent runs in-process, no FastAPI)