A dependency graph analyzer using smolagents
Project description
Naive Knowledge Base
A dependency graph analyzer using smolagents for building and analyzing code dependencies.
Features
- ๐ Dependency Graph Generation: Automatically generate dependency graphs from source code
- ๐ค AI-Powered Analysis: Uses smolagents for intelligent code analysis
- ๐ Multiple Language Support: Support for Java and other languages
- ๐ณ Directory Tree Visualization: Generate visual representations of project structure
- ๐ File Operations: Read, write, and manage files programmatically
Installation
From Source
git clone https://github.com/yourusername/naive-knowledge-base.git
cd naive-knowledge-base
pip install -e .
From PyPI (when published)
pip install naive-knowledge-base
Requirements
- Python 3.8+
- OpenAI API key (or compatible API)
Configuration
Create a .env file in your project directory with the following:
OPENAI_API_KEY=your_api_key_here
# Or configure your API endpoint
API_BASE_URL=your_api_base_url
Usage
Command Line Interface
After installation, you can use the naive-kb command:
# Basic usage
naive-kb /path/to/source/directory
# Specify file extensions
naive-kb /path/to/source/directory java
# Specify directories to ignore
naive-kb /path/to/source/directory java "target,.git,test,node_modules"
Python API
from naive_knowledge_base import run_analysis
# Run dependency graph analysis
result = run_analysis(
source_directory="/path/to/source",
file_extensions="java",
ignore_dirs="target,.git,test"
)
Advanced Usage
from smolagents import CodeAgent, ToolCallingAgent
from naive_knowledge_base.api_models import FlowApiModel
from naive_knowledge_base.tools import (
save_content_to_file,
read_file_content,
delete_folder_or_file,
generate_folder_tree
)
from naive_knowledge_base.agents.dependency_graph import generate_dependency_graph
# Create custom agents
model = FlowApiModel(model_id="gpt-4.1", temperature=0.5)
dependency_agent = ToolCallingAgent(
tools=[generate_dependency_graph],
model=model,
max_steps=7,
name="dependency_graph_agent"
)
manager_agent = CodeAgent(
managed_agents=[dependency_agent],
model=model,
tools=[read_file_content, save_content_to_file],
max_steps=30,
name="tech_lead_agent"
)
# Run analysis
result = manager_agent.run("Analyze dependencies in /path/to/source")
Package Structure
naive_knowledge_base/
โโโ agents/
โ โโโ common/ # Common agent utilities
โ โ โโโ base.py
โ โ โโโ exceptions.py
โ โ โโโ logging.py
โ โ โโโ utils.py
โ โโโ dependency_graph/ # Dependency graph analysis
โ โโโ agent.py
โ โโโ model.py
โโโ api_models/ # API model integrations
โ โโโ flow_api_model.py
โโโ tools/ # Agent tools
โโโ io.py # File I/O operations
โโโ tree.py # Directory tree generation
Development
Setup Development Environment
# Clone the repository
git clone https://github.com/yourusername/naive-knowledge-base.git
cd naive-knowledge-base
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
Running Tests
pytest tests/
Code Formatting
# Format code
black .
isort .
# Check code quality
pylint naive_knowledge_base/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with smolagents
- Uses OpenAI API for AI-powered analysis
Support
For issues and questions, please file an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file naive_knowledge_base-0.1.5.tar.gz.
File metadata
- Download URL: naive_knowledge_base-0.1.5.tar.gz
- Upload date:
- Size: 24.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee392b877d3932d497a973aba2366945e0749d3171c7ebdd8d332e069acf7528
|
|
| MD5 |
95a8e7054692b3e372ade8bc122ce989
|
|
| BLAKE2b-256 |
74bee04af83a24ba9792277502b3d24ec3a2edae614507f08f8e2682c9919e88
|
File details
Details for the file naive_knowledge_base-0.1.5-py3-none-any.whl.
File metadata
- Download URL: naive_knowledge_base-0.1.5-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6991537a8c033708f18550d923b55a1576d25394042d5d40d9ace26bf8b7ce3
|
|
| MD5 |
cf3d788c26a2432dbb639b9768af8688
|
|
| BLAKE2b-256 |
1019aa5ea6394f65412f6dd94b885720bd5edd2eaf8ce3e9461700a7ac14784b
|