How danf57/agentic_ai_tesis works
Project Type and Purpose
• This is a full-stack AI-agent application built for a thesis in Computer Science.
• It consists of a client layer (agent interface + Streamlit UI), a backend server that exposes APIs and hosts a vector database, and a knowledge-population pipeline.
File Structure Analysis
• Top-level directories:
• client: Python scripts for the agent client (agent_client.py), a Streamlit UI (ui_streamlit.py), and an LLM factory helper.
• server: code for hosting the API (my_server.py), a knowledge ingestion/population script, and a prebuilt Reddit dataset JSON.
• config: YAML files for Chroma vector DB, model settings, and general settings.
• tests: unit tests covering the agent logic, LLM factory, tools, and vector DB.
• Key configuration files: chroma.yaml (vector DB settings), models.yaml (model parameters), settings.yaml (app-level settings).
• Build/deploy scripts aren’t present, implying manual startup (e.g., python server/my_server.py).
README Insights
• Brief description: “agent for my thesis.”
Main Components
a. Client Layer
• Streamlit UI (client/ui_streamlit.py): web interface for user input and output display.
• Agent Client (client/agent_client.py): orchestrates calls to the backend, sends queries, receives and processes responses.
• LLM Factory (client/utils/llm_factory.py): abstracts creation/configuration of LLM instances (e.g., OpenAI, local models).
b. Backend Layer
• API Server (server/my_server.py): REST (or HTTP) endpoints for query processing, middleware for authentication (if any), orchestrates vector DB lookups and LLM calls.
• Vector Database (Chroma): stores embeddings of knowledge base documents for similarity search. Configuration loaded from config/chroma.yaml.
• Knowledge Population Script (server/knowledge/populate_vector.py): offline/one-time job that ingests reddit_dataset_final_1492_posts.json, computes embeddings, and populates the vector DB.
c. Data & Configuration
• Config Service: loads models.yaml and settings.yaml at startup to parameterize LLM calls, endpoint settings, and vector DB parameters.
• Dataset Storage: raw JSON file under server/knowledge/.
d. External Services
• LLM Provider: external API calls (e.g., OpenAI) or local inference servers.
• (Optional) Authentication or Logging services if added in future.
Interactions and Data Flows
• User → Streamlit UI: inputs prompt.
• UI → Agent Client: forwards prompt.
• Agent Client → API Server: HTTP request with query payload.
• API Server → Vector DB: similarity search to retrieve top-k relevant docs.
• API Server → LLM Factory → LLM Provider: constructs prompt with retrieved docs, sends to model, obtains completion.
• API Server → Agent Client: returns LLM response.
• Agent Client → UI: displays the result.
Architectural Patterns and Principles
• Layered Architecture: client layer, API layer, persistence/inference layer.
• Factory Pattern: used for decoupling LLM instantiation (llm_factory.py).
• Configuration-Driven Design: YAML files for easy swapping of models and DB backends.
• Separation of Concerns: distinct knowledge ingestion pipeline vs. query-time processing.