A Python application that uses AI to analyze sales data and provide insights. It leverages Qwen model through DashScope API, integrates with Kuzu graph database, and provides both API and CLI interfaces for interactive data analysis.
- Reads sales data from parquet files
- Uses AI agent to analyze data characteristics and distributions
- Provides batch data fetching capability for large datasets
- Generates comprehensive analysis conclusions, trends, and recommendations
- Implements RAG (Retrieval-Augmented Generation) using Kuzu graph database
- Supports memory management and context-aware processing
- Offers both API and CLI interfaces for user interaction
-
Create a
.envfile with the following variables:BAILIAN_API_KEY=your_api_key_here KUZU_PATH=path_to_kuzu_database EMBEDDING_BASE_URL=embedding_model_api_base_url -
Install dependencies using:
pip install -e .
Run the application in API mode with:
python -m ad_agentOr using the provided script:
ad-agentRun the application in interactive CLI mode with:
cli-agentThe application provides:
- Data loading and processing from parquet files
- AI-powered analysis using Qwen models via DashScope API
- Knowledge graph storage and retrieval using Kuzu database
- Context-aware conversation with memory management
- Interactive command-line interface for user queries
Key dependencies include:
- pandas and pyarrow for data processing
- pydantic-ai for AI model integration
- agento for agent framework
- kuzu for graph database functionality
- logfire for logging and instrumentation
- sqlite-vec for vector storage
src/ad_agent/: Main source code directory__init__.py: Entry point functionscli.py: Command-line interface implementationllm_api.py: LLM API and agent implementationmodels.py: Qwen model configurationlog_config.py: Logging configurationmem/: Memory management componentsrag_datagov/: RAG implementation with Kuzu graphgraph/: Graph-related utilities