CoolFace
Apppublic

HimanshuGoyal2004/Documentation-Agent

sourceHugging Facemitupdated 1y agoView on Hugging Face
1likes
App README

๐Ÿค– Self-Documentation Agent System

An AI-powered system that automatically analyzes, documents, and validates Python code using LangGraph workflows and Google's Gemini 2.5 Flash model.

๐Ÿš€ Features

  • โ€”Intelligent Documentation Detection: Automatically skips documentation if already present
  • โ€”Comprehensive Code Documentation: Generates detailed docstrings, inline comments, and warnings
  • โ€”Automated Code Testing: Executes code with various test scenarios and captures I/O behavior
  • โ€”Professional Output: Clean, business-appropriate formatting without excessive emojis
  • โ€”Library Research: Uses web search to understand unfamiliar libraries
  • โ€”Issue Identification: Flags potential syntax errors, logic problems, and security risks

๐Ÿ”ง How It Works

The system uses a simplified three-node LangGraph workflow:

  1. 1.Research Node: Analyzes code structure, identifies libraries, and checks existing documentation
  2. 2.Document Node: Adds comprehensive docstrings and inline comments using Google style
  3. 3.Analyze Node: Executes code with various test scenarios and identifies potential issues

๐Ÿ“‹ Requirements

To use this system, you'll need:

  • โ€”Google API Key: For accessing the Gemini 2.5 Flash model
  • โ€”Get it from Google AI Studio
  • โ€”Tavily API Key: For web search functionality during library research
  • โ€”Get it from Tavily

๐ŸŽฏ Use Cases

  • โ€”Code Review: Automatically document and analyze code before reviews
  • โ€”Legacy Code: Add documentation to undocumented codebases
  • โ€”Learning: Understand how code works through comprehensive analysis
  • โ€”Quality Assurance: Identify potential issues and improvements
  • โ€”Documentation Standards: Ensure consistent documentation across projects

๐Ÿ› ๏ธ Technologies

  • โ€”LangGraph: Workflow orchestration and state management
  • โ€”Google Gemini 2.5 Flash: Advanced language model for code analysis
  • โ€”Tavily Search: Web search for library research
  • โ€”Gradio: Interactive web interface
  • โ€”Python AST: Code structure analysis

๐Ÿ“– Example Output

Input Code

python
def divide_numbers(a, b):
    return a / b

Documented Output

python
def divide_numbers(a, b):
    """
    Divides two numbers.

    Args:
        a (float or int): The numerator.
        b (float or int): The denominator.

    Returns:
        float: The result of the division.

    Raises:
        ZeroDivisionError: If the denominator 'b' is zero.
    """
    # WARNING: This function will raise a ZeroDivisionError if 'b' is 0.
    # For robust applications, consider adding a try-except block or a check for b == 0.
    return a / b

Analysis Results

  • โ€”Issues Found: Division by zero risk
  • โ€”Test Results: Execution with various inputs
  • โ€”Recommendations: Add error handling
  • โ€”Usage Guidelines: Implementation best practices

๐Ÿ”’ Privacy & Security

  • โ€”API keys are handled securely and not stored
  • โ€”Code processing happens in isolated environments
  • โ€”No data is permanently stored or shared