Spaces:
Sleeping
Sleeping
| title: Fair Election Reporting RAG Chatbot | |
| emoji: π³οΈ | |
| colorFrom: blue | |
| colorTo: indigo | |
| sdk: streamlit | |
| sdk_version: "1.39.0" | |
| app_file: RAGμ±λ΄_λ°°ν¬.py | |
| pinned: false | |
| license: mit | |
| # π³οΈ Fair Election Reporting Guide RAG Chatbot | |
| This retrieval-augmented generation (RAG) chatbot uses the Internet Election News | |
| Deliberation Commission's approximately 105-page **2026 Fair Election Reporting Guide**. | |
| It finds relevant information in the guide and answers questions **with source page numbers**. | |
| ## How to Use | |
| 1. Select a sample question in the sidebar, or enter your own question in the input field at the bottom. | |
| 2. Verify the `[νμ΄μ§ N]` citation shown with the answer against the original guide. | |
| 3. Ask follow-up questions; the chatbot uses the previous context to respond naturally (multi-turn conversation). | |
| 4. To start over, click **ποΈ λν μ΄κΈ°ν** in the sidebar. | |
| ## Technology Stack | |
| | Component | Technology | | |
| |---|---| | |
| | Frontend | Streamlit | | |
| | Embedding model | Gemini Embedding 001 (768 dimensions) | | |
| | Vector DB | Chroma (prebuilt persistent store) | | |
| | Generative model | Gemini 2.5 Flash-Lite | | |
| | Deployment | Hugging Face Spaces | | |
| ## How It Works | |
| ``` | |
| μ§λ¬Έ μ λ ₯ | |
| β | |
| Gemini EmbeddingμΌλ‘ 벑ν°ν (task_type=retrieval_query) | |
| β | |
| Chroma DBμμ μ½μ¬μΈ μ μ¬λ Top-5 μ²ν¬ κ²μ | |
| β | |
| κ²μ κ²°κ³Ό + μμ€ν ν둬ννΈ + λν μ΄λ ₯ β Gemini 2.5 Flash-Lite | |
| β | |
| μΆμ² νμ΄μ§κ° νμλ νκ΅μ΄ λ΅λ³ μμ± | |
| ``` | |
| ## Environment Variables | |
| Add the following entry under **Settings β Variables and secrets** in the Space: | |
| - `GEMINI_API_KEY` β Obtain from Google AI Studio (https://aistudio.google.com/apikey) | |
| ## Run Locally | |
| 1. Install the dependencies (a virtual environment is recommended). | |
| ```bash | |
| pip install -r requirements.txt | |
| ``` | |
| 2. Create a `.env` file in the same directory and add the following line. | |
| ``` | |
| GEMINI_API_KEY=λ³ΈμΈμ_Gemini_API_ν€ | |
| ``` | |
| 3. Make sure the prebuilt `chroma_election_db/` directory is in the same location. | |
| 4. Run the app with Streamlit rather than invoking Python directly. | |
| ```bash | |
| streamlit run RAGμ±λ΄_λ°°ν¬.py | |
| ``` | |
| If the browser does not open automatically, open http://localhost:8501 in your browser. | |
| ## File Structure | |
| ``` | |
| . | |
| βββ RAGμ±λ΄_λ°°ν¬.py # λ©μΈ μ± (Streamlit μ§μ μ ) | |
| βββ requirements.txt # μμ‘΄ ν¨ν€μ§ | |
| βββ README.md # μ΄ νμΌ | |
| βββ chroma_election_db/ # μ¬μ λΉλλ λ²‘ν° DB | |
| βββ chroma.sqlite3 | |
| βββ <UUID ν΄λ>/ | |
| ``` | |
| The vector DB must be generated in advance with a separate build script. | |
| The app does not perform chunking or embedding at runtime. | |
| ## Notes | |
| - The chatbot's answers are based on the guide, but verify the **original guide** before using them for final decisions or citations. | |
| - On the free tier, the Space may go to sleep after a period of inactivity, so the first request may take approximately 30 seconds. | |
| - Separate usage limits and pricing policies apply to Gemini API calls. | |