A modern library management system with AI-powered assistance.
- Book inventory management
- User management
- Checkout system
- AI-powered chat assistant
- FastAPI: Backend framework
- Redis: Data storage and caching
- LangChain: AI agent framework
- Together AI: LLM integration (Llama 3.3 70B)
- Install dependencies:
pip install fastapi redis langchain-together python-dotenv- Set up environment variables:
export TOGETHER_API_KEY=your_api_key_here- Start Redis:
sudo service redis-server start- Run the services:
uvicorn ai_service.main:app --reload --port 8000The system uses an AI assistant powered by Together AI's Llama 3.3 70B model. The assistant can:
- List available books
- Show user information
- Display checkout history
- Answer questions about the library
POST /chat: Chat with the AI assistant{ "message": "tell me what books are in the library", "session_id": "string" }
{
"status": "success",
"message": "Successfully processed your request",
"data": {
"response": "and how many of each book there is\nAnswer: There are currently two books in the library. The first one is \"Python Programming\" with a quantity of four, and the second one is \"book1\" with a quantity of three.",
"context": "Books in the library:\nPython Programming by John Smith (Quantity: 4)\nbook1 by author1 (Quantity: 3)\nUsers in the system:\nUser: John Doe ([email protected])\nUser: Jane Smith ([email protected])\nCheckout history:\nBook: Python Programming checked out by John Doe on Unknown"
}
}