How tt959/ecommerce-agent works
This is an e-commerce after-sales support agent. A client submits a chat message to the FastAPI service; the agent recalls user memory, classifies one or more intents, runs applicable order/knowledge/transfer actions, and generates a response. Session history is persisted, and long-term memory is extracted after the response. Separate branches cover document ingestion and offline evaluation. Relationships for unsampled implementation details are included only where the README or source index supports them.
Main entry points: main.py FastAPI API · graph.py Intent Classification · long_term_memory.py Long-Term Memory · rag_tool.py FAQ and Product RAG
Components 21
API and Sessions
- FastAPI API
src/main.py - Session History
src/memory.py
Agent Workflow
- Memory Recall
src/graph.py - Intent Classification
src/graph.py - Intent Signals
src/memory_signals.py - Parallel Tool Dispatch
src/graph.py - Response Generation
src/graph.py - Offline Evaluation
src/evaluation.py
Knowledge and Memory
- FAQ and Product RAG
src/rag_tool.py - Long-Term Memory
src/long_term_memory.py - Text Embeddings
src/embeddings.py - Redis Client
src/redis_client.py - Document Ingestion
src/document_loader.py - Knowledge Initialization
src/insert_data.py
Business Data
- Order Query
src/tools.py - Async Database Access
src/database.py
Other components
- Client
- Redis
- MySQL Orders
- Chat Model
- Milvus Collections
Connections 30
- Client → FastAPI API: sends request
README.md - FastAPI API → Session History: loads history
src/main.py - Session History → Redis: persists history
README.md - FastAPI API → Memory Recall: invokes agent
src/main.py - Memory Recall → Intent Classification: then classifies
README.md - Intent Classification → Intent Signals: checks signals
src/graph.py - Intent Classification → Chat Model: completes intents
README.md - Intent Classification → Parallel Tool Dispatch: routes intents
README.md - Parallel Tool Dispatch → Order Query: queries orders
src/graph.py - Order Query → Async Database Access: uses sessions
src/tools.py - Async Database Access → MySQL Orders: queries orders
README.md - Parallel Tool Dispatch → FAQ and Product RAG: searches knowledge
src/graph.py - Parallel Tool Dispatch → Response Generation: passes tool results
README.md - Memory Recall → Long-Term Memory: searches memories
src/graph.py - Response Generation → Long-Term Memory: uses recalled context
src/graph.py - Response Generation → Chat Model: generates reply
README.md - FAQ and Product RAG → Text Embeddings: embeds query
src/rag_tool.py - FAQ and Product RAG → Milvus Collections: searches collections
src/rag_tool.py - FAQ and Product RAG → Redis Client: uses cache
src/rag_tool.py - Long-Term Memory → Text Embeddings: embeds memories
src/long_term_memory.py - Long-Term Memory → Milvus Collections: stores and searches
src/long_term_memory.py - Redis Client → Redis: connects to
src/redis_client.py - FastAPI API → Long-Term Memory: writes after reply
src/main.py - FastAPI API → Document Ingestion: processes uploads
src/main.py - Document Ingestion → Text Embeddings: embeds chunks
src/document_loader.py - Document Ingestion → Milvus Collections: inserts chunks
src/document_loader.py - Knowledge Initialization → Text Embeddings: vectorizes seed data
src/insert_data.py - Knowledge Initialization → Milvus Collections: initializes knowledge
README.md - Offline Evaluation → Intent Classification: evaluates intents
src/evaluation.py - Offline Evaluation → Response Generation: judges answers
README.md