QuickAnswer Serper Agent is a lightweight, modular AI question-answering application that combines an LLM, live Google search, short-term conversational memory, and a clean Streamlit chat interface.
The project is designed to answer user queries by intelligently deciding when to use web search via the Google Serper API, then generating concise, context-aware responses using a Groq-hosted LLM. It supports streaming responses, thread-based memory, and a clean modular architecture that makes the repository easy to maintain, extend, and showcase.
This repository is built to look and feel like a real-world production-oriented AI application rather than a single-file prototype.
Traditional chatbot demos often fail in two important ways:
- they rely only on the LLM's static knowledge
- they are written as monolithic scripts that are hard to scale or maintain
This project addresses both issues by:
- integrating real-time web search for fresher answers
- using LangGraph checkpointer-based memory for multi-turn interactions
- implementing a modular architecture with clear separation of concerns
- providing a streaming chat UI for a more natural user experience
It is especially useful as a portfolio project for demonstrating practical skills in:
- LLM application engineering
- tool-augmented agents
- memory-aware AI workflows
- Streamlit-based product prototyping
- clean Python project organization
- LLM-powered conversational assistant
- Google Serper web search integration
- LangGraph short-term memory with thread-based context
- Streaming token-by-token responses
- Modular production-style codebase
- Reusable service and UI components
- Environment-based configuration
- GitHub-ready clean project structure
- Easy extension for more tools, persistent memory, or deployment
- Python
- Streamlit
- LangChain
- LangGraph
- Groq API
- Google Serper API
langchain-groqlangchain-communitypydantic-settingspython-dotenv
The system follows a modular agent-driven workflow:
- The user enters a question in the Streamlit chat UI.
- The request is passed to the chat service layer.
- The agent receives the user message along with a
thread_id. - The LLM decides whether a web search is needed.
- If required, the agent uses the Google Serper search tool.
- Search results are passed back to the LLM.
- The LLM generates a concise final answer.
- The answer is streamed back to the UI token by token.
- The conversation context is stored in memory for follow-up queries.
User Query
↓
Streamlit UI
↓
Chat Service
↓
Agent Builder
↓
LLM + Search Tool + Memory
↓
Streaming Response
↓
Chat UI Rendering
This project is intentionally structured in a modular way to support future growth.
- LLM Layer: initializes the Groq chat model
- Tool Layer: exposes Google Serper as an agent tool
- Memory Layer: manages thread-based conversational memory
- Prompt Layer: defines the system behavior and response rules
- Agent Builder: combines model, tools, prompt, and memory
- Service Layer: orchestrates streaming responses
- UI Layer: handles Streamlit rendering and chat state
This project currently uses in-memory checkpointing for simplicity and fast local development. For production, this can be replaced with a persistent backend such as PostgreSQL or another supported storage layer.
quickanswer-serper-agent/
├── app/
│ ├── main.py # Streamlit entrypoint
│ ├── __init__.py
│ ├── config/
│ │ ├── __init__.py
│ │ └── settings.py # Environment variables and app config
│ ├── agent/
│ │ ├── __init__.py
│ │ ├── llm.py # ChatGroq initialization
│ │ ├── toolkit.py # Google Serper search tool
│ │ ├── memory.py # Checkpointer and thread memory
│ │ ├── prompt.py # System prompt
│ │ └── builder.py # Agent construction
│ ├── services/
│ │ ├── __init__.py
│ │ └── chat_service.py # Streaming response orchestration
│ ├── ui/
│ │ ├── __init__.py
│ │ └── components.py # Reusable Streamlit UI components
│ └── utils/
│ ├── __init__.py
│ └── logger.py # Logging utility
├── .env
├── .env.example
├── .gitignore
├── requirements.txt
├── README.md
└── run.py # Optional launcher
git clone https://github.com/[YOUR_GITHUB_USERNAME]/[YOUR_REPOSITORY_NAME].git
cd [YOUR_REPOSITORY_NAME]python -m venv .venv
.venv\Scripts\Activate.ps1python -m venv .venv
source .venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root:
GROQ_API_KEY=your_groq_api_key
SERPER_API_KEY=your_serper_api_key
MODEL_NAME=openai/gpt-oss-20b
APP_TITLE=QuickAnswer - Q&A Bot with Google Serper API
APP_DESCRIPTION=Ask any question and the bot will use Google Serper to search the web.You can also copy from the example file:
cp .env.example .envOn Windows, create .env manually if needed.
streamlit run app/main.pyOr:
streamlit run run.py- factual questions that benefit from live web search
- follow-up questions that depend on previous conversation context
- short knowledge queries requiring concise answers
User: Who won the FIFA World Cup in 2022?
Assistant: Argentina won the 2022 FIFA World Cup.
User: Who was the captain?
Assistant: Lionel Messi was the captain of Argentina.
Streamlit application entrypoint. Initializes session state, loads the agent, renders chat history, and handles user input.
Loads environment variables and centralizes runtime configuration such as API keys, model name, and UI labels.
Initializes the Groq LLM client used by the agent.
Defines the Google Serper search tool exposed to the agent.
Manages checkpointer-based thread memory for multi-turn chat.
Contains the system prompt that controls assistant behavior.
Creates the final agent by combining the model, tools, prompt, and memory.
Streams the final assistant response and filters internal tool messages from the UI.
Contains reusable Streamlit components for chat rendering and layout.
Provides basic logging support for debugging and visibility.
Input
What is the capital of Japan?
Output
Tokyo is the capital of Japan.
Input
Who won the most recent Ballon d'Or?
Output
[Example output here based on live search results]
Input
Did he win the World Cup too?
Output
[Context-aware follow-up answer using memory]
| Variable | Description |
|---|---|
GROQ_API_KEY |
API key for Groq model access |
SERPER_API_KEY |
API key for Google Serper search |
MODEL_NAME |
LLM model name |
APP_TITLE |
UI title shown in Streamlit |
APP_DESCRIPTION |
Short app description in the UI |
This project currently targets local development and portfolio demonstration.
- Streamlit Community Cloud
- Render
- Railway
- Dockerized VPS deployment
- Hugging Face Spaces with UI adaptation if needed
- move from in-memory memory to persistent storage
- add structured error handling
- improve observability and tracing
- secure secrets through environment-based deployment configuration
- Add persistent memory backend
- Add citation-style answer formatting
- Add tool usage logging and monitoring
- Add source links in the final response
- Add conversation export feature
- Add multi-tool support beyond Google search
- Add authentication and user-based chat sessions
- Containerize with Docker
- Deploy public demo
Contributions are welcome.
If you would like to improve the project:
- Fork the repository
- Create a new feature branch
- Make your changes
- Commit with a clear message
- Open a pull request
Example:
git checkout -b feature/improve-streaming
git commit -m "Improve streaming response handling"
git push origin feature/improve-streamingThis project demonstrates:
- practical LLM application engineering
- tool-augmented agent design
- conversational memory handling
- streaming response pipelines
- modular Python architecture for AI applications