How mghayaz/generativeai-learn works
This repository is a collection of generative-AI learning examples, not one integrated application. Its most complete user-facing workflow is the speaking agent: a CLI starts a conversation, the workflow uses an LLM and may dispatch tool calls, and speech modules provide audio input/output. Separate examples demonstrate RAG, queued multimodal processing, persistent graph conversations, memory, and tool-using agents. The graph follows explicit imports and calls where excerpts show them; several unsampled subsystems are included from the file tree, but their internal links are omitted rather than inferred.
Main entry points: chat_loop.py Conversation loop · chat.py LLM generation · tool_handler.py Tool call handler · executor.py Tool executor
Components 34
Speaking agent
- App entry
genAI_Chapters/speaking_agent/app/main.py - Conversation loop
genAI_Chapters/speaking_agent/workflow/chat_loop.py - LLM generation
genAI_Chapters/speaking_agent/llms/chat.py - Gemini client
genAI_Chapters/speaking_agent/llms/client.py - Chat history
genAI_Chapters/speaking_agent/llms/history.py - System prompt
genAI_Chapters/speaking_agent/prompts/system.py - Tool schemas
genAI_Chapters/speaking_agent/models/schemas.py - Tool call handler
genAI_Chapters/speaking_agent/workflow/tool_handler.py - Tool executor
genAI_Chapters/speaking_agent/tools/executor.py - Tool policy
genAI_Chapters/speaking_agent/tools/policy.py - Tool registry
genAI_Chapters/speaking_agent/tools/registry.py - Schema builder
genAI_Chapters/speaking_agent/tools/schema_builder.py - Weather tool
genAI_Chapters/speaking_agent/tools/weather.py - Microphone input
genAI_Chapters/speaking_agent/speech/microphone.py - Speech recognition
genAI_Chapters/speaking_agent/speech/stt.py - Audio handling
genAI_Chapters/speaking_agent/speech/audio.py - Speech synthesis
genAI_Chapters/speaking_agent/speech/tts.py
Retrieval examples
- PDF indexing
genAI_Chapters/RAG/indexing_pdf.py - Document chunking
genAI_Chapters/RAG/chunking_with_langchain.py - Embedding and indexing
genAI_Chapters/RAG/embed_with_langchain.py - RAG query example
genAI_Chapters/RAG/united_RAG.py - Qdrant vector store
- Async RAG API
genAI_Chapters/RAG_Asyncio_and_multimodal/server.py - Redis job queue
genAI_Chapters/RAG_Asyncio_and_multimodal/client_line/rq.py - RAG worker
genAI_Chapters/RAG_Asyncio_and_multimodal/worker_line/worker.py
Agents and memory
- Coding and weather agent
genAI_Chapters/agenticAi/agent_to_code.py - Memory-aware agent
genAI_Chapters/memory/mem_agent.py - Memory stores
Graph and model examples
- Mongo-backed graph
genAI_Chapters/MongoDb_LangGraph/mongo_in_rag.py - MongoDB checkpoints
- LangGraph examples
genAI_Chapters/LangGraph
Other components
- CLI user
- Gemini service
- Redis
Connections 41
- CLI user → App entry: starts
genAI_Chapters/speaking_agent/app/main.py - App entry → Conversation loop: runs
genAI_Chapters/speaking_agent/app/main.py - Conversation loop → LLM generation: requests response
genAI_Chapters/speaking_agent/workflow/chat_loop.py - LLM generation → Gemini client: uses client
genAI_Chapters/speaking_agent/llms/chat.py - LLM generation → System prompt: sets instruction
genAI_Chapters/speaking_agent/llms/chat.py - LLM generation → Schema builder: builds tool config
genAI_Chapters/speaking_agent/llms/chat.py - Conversation loop → Chat history: updates history
genAI_Chapters/speaking_agent/workflow/chat_loop.py - Conversation loop → Tool call handler: handles calls
genAI_Chapters/speaking_agent/workflow/chat_loop.py - Tool call handler → Chat history: appends messages
genAI_Chapters/speaking_agent/workflow/tool_handler.py - Tool call handler → Tool executor: executes calls
genAI_Chapters/speaking_agent/workflow/tool_handler.py - Tool call handler → Tool schemas: returns summary
genAI_Chapters/speaking_agent/workflow/tool_handler.py - Tool executor → Tool policy: checks policy
genAI_Chapters/speaking_agent/tools/executor.py - Tool executor → Tool registry: resolves tool
genAI_Chapters/speaking_agent/tools/executor.py - Schema builder → Tool registry: uses registry
- Tool registry → Weather tool: registers tool
- CLI user → Microphone input: speaks
- Microphone input → Speech recognition: captures audio
- Speech recognition → Conversation loop: provides text
genAI_Chapters/speaking_agent/workflow/chat_loop.py - Conversation loop → Speech synthesis: speaks response
genAI_Chapters/speaking_agent/workflow/chat_loop.py - Speech synthesis → Audio handling: creates audio
- PDF indexing → Document chunking: prepares documents
- Document chunking → Embedding and indexing: chunks documents
- Embedding and indexing → Qdrant vector store: indexes vectors
- CLI user → RAG query example: asks question
genAI_Chapters/RAG/united_RAG.py - RAG query example → Qdrant vector store: searches chunks
genAI_Chapters/RAG/united_RAG.py - RAG query example → Gemini service: generates answer
genAI_Chapters/RAG/united_RAG.py - CLI user → Async RAG API: submits query
genAI_Chapters/RAG_Asyncio_and_multimodal/server.py - Async RAG API → Redis job queue: enqueues job
genAI_Chapters/RAG_Asyncio_and_multimodal/server.py - Async RAG API → RAG worker: queues worker task
genAI_Chapters/RAG_Asyncio_and_multimodal/server.py - Redis job queue → Redis: stores job
- RAG worker → Qdrant vector store: searches chunks
genAI_Chapters/RAG_Asyncio_and_multimodal/worker_line/worker.py - RAG worker → Gemini service: generates answer
genAI_Chapters/RAG_Asyncio_and_multimodal/worker_line/worker.py - CLI user → Coding and weather agent: requests task
genAI_Chapters/agenticAi/agent_to_code.py - Coding and weather agent → Gemini service: requests tool calls
genAI_Chapters/agenticAi/agent_to_code.py - Coding and weather agent → CLI user: returns tool result
genAI_Chapters/agenticAi/agent_to_code.py - CLI user → Memory-aware agent: asks question
genAI_Chapters/memory/mem_agent.py - Memory-aware agent → Memory stores: searches and adds
genAI_Chapters/memory/mem_agent.py - Memory-aware agent → Gemini service: generates response
genAI_Chapters/memory/mem_agent.py - Mongo-backed graph → Gemini service: invokes model
genAI_Chapters/MongoDb_LangGraph/mongo_in_rag.py - Mongo-backed graph → MongoDB checkpoints: persists checkpoints
genAI_Chapters/MongoDb_LangGraph/mongo_in_rag.py - CLI user → Mongo-backed graph: submits messages
genAI_Chapters/MongoDb_LangGraph/mongo_in_rag.py