Skip to main content

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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

naive_knowledge_base-0.1.1.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

naive_knowledge_base-0.1.1-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file naive_knowledge_base-0.1.1.tar.gz.

File metadata

  • Download URL: naive_knowledge_base-0.1.1.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for naive_knowledge_base-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b112afcf9a61c7df13cf6f0dddc51fb7c6ac06e3a3a0018abeee5818f8f72864
MD5 42d22fd0158fea485167136a3d1b30c6
BLAKE2b-256 c0f34898b53e9eb30e3b0f5a14b929772c872601f2def3b42b1eff82a19634ef

See more details on using hashes here.

File details

Details for the file naive_knowledge_base-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for naive_knowledge_base-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4610a9a97e630ed8f47800c71dc1cd6c4ffe7b0ae3585eff1fb343ec2c54c9c8
MD5 811c164afcf0f3d6c4290406bea2e59f
BLAKE2b-256 c90b1c6b8cc145816a533c73a7bf7a64522e5e4bcb47f54bfe981157fe010fc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page