How wannabeasmartguy/gpt-gradio-agent works
Project type and purpose
• This is a Python-based, full-stack desktop/web application built on Gradio that provides:
• A chatbox interface to interact with GPT (Azure or OpenAI) or a local LLM (Ollama)
• A GPT-driven, RAG-capable knowledge-base management module (CRUD + embedding + retrieval + reranking)
• DALL·E-3 image generation via Azure OpenAI
• Bing-powered web search integration with history tracking
File structure
• Top-level entrypoint: GPT-Gradio-Agent.py launches the Gradio UI
• “Agent/” folder: core agent logic (agent.py, agent_tools.py)
• “vecstore/” folder: vector store implementation (embedding, searching, reranking, templating)
• “embedding model/”: placeholder for local Hugging Face embedding models
• “local_llm/ollama.py”: adapter to run a local LLM via Ollama
• “pic_gen/”: DALL·E-3 image generation logic
• “search_his/”: persistence for RAG search history
• “knowledge base/”: storage for user’s document collections
• “gga_utils/”, “text_splitter/”, “style/”, “locale/”: shared utilities, text-chunking, CSS styling, i18n
README for additional insights
• Gradio frontend binds to several “pages” or “tabs”: Chat, Knowledge Base, Image Gen, RAG Search
• Supports both cloud APIs (Azure OpenAI + Bing Search) and fully local LLM/embed pipelines
Main components
a. Frontend Layer (Gradio UI)
• Chat Tab
• Knowledge Base Manager Tab
• Image Generation Tab
• RAG Search Tab
b. Backend Layer (Python modules)
• ChatController (orchestrates Agent.agent.py + gga_utils + vecstore.search_engine)
• KBController (CRUD on “knowledge base/” files + embedding via vecstore.vecstore)
• ImageGenController (pic_gen.pic_gen.py → Azure DALL·E API)
• SearchController (search_his + vecstore.reranker + Bing Search API)
c. Data Layer
• Local file system: “knowledge base/”, “search_his/”
• Vector Store: persistent embeddings (vecstore/vecstore.py; stores index on disk)
d. External Services
• Azure OpenAI API (chat completions, embeddings, DALL·E-3)
• Bing Web Search API
• Optional Hugging Face local embedding model
• Optional Ollama local LLM
Relationships and interactions
• User → Gradio UI → appropriate Controller
• Controller ↔ Agent & vecstore modules for RAG workflows
• Controller → Azure OpenAI or local LLM for chat
• Controller → Azure OpenAI for DALL·E-3 image generation
• Controller → Bing Search API → reranker → UI
• Controller ↔ local files (KB CRUD & history persistence)
Architectural patterns & design principles
• Modular Monolith: separate folders for each concern (Chat, KB, Embedding, Search, Image Gen)
• RAG pipeline: Text splitter → Embed → Vector index → Retrieve → Rerank → LLM prompt
• Adapter pattern: local_llm/ollama.py abstracts LLM backend; embedding_model folder abstracts HF models
4. Inside Backend layer, group modules by function:
– ChatController → Agent.agent.py → gga_utils
– KBController → text_splitter → vecstore.vecstore/search_engine
– ImageGenController → pic_gen.pic_gen.py
– SearchController → search_his + vecstore.reranker → Bing Search
Final reminder
• Be very detailed: capture each module folder as a component
This structure will give stakeholders and new team members an accurate, high-level overview of how GPT-Gradio-Agent is organized and how its pieces interact end-to-end.