Loading repository data…
Loading repository data…
SniksaX / repository
An intelligent AI agent that automatically generates and validates documentation and executable examples for Python code.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
An AI-powered service that automatically generates documentation and validated, executable examples for Python code snippets.
This project uses a ReAct (Reasoning and Acting) agent built with the LangChain framework. The agent follows a strict, iterative process to ensure the quality of its output:
CodeAnalyzer tool to understand the purpose, parameters, dependencies, and return values of the input code.CodeExecutionEnvironment.This validation loop ensures that the generated code isn't just plausible—it's guaranteed to be runnable.
Clone the repository:
git clone git@github.com:SniksaX/AgenticAI.git
cd AgenticAI
Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Install dependencies:
pip install -r requirements.txt
(Note: You will need to create a requirements.txt file from the project's imports. It should include fastapi, uvicorn, langchain, langchain-openai, python-dotenv, and func-timeout.)
Set up environment variables:
Create a file named .env in the root of the project and add your OpenAI API key:
OPENAI_API_KEY="sk-..."
Launch the development server using Uvicorn:
uvicorn main:app --reload
The API will be available at http://127.0.0.1:8000. You can access the interactive Swagger UI documentation at http://127.0.0.1:8000/docs.
To ensure all components are working correctly, run the test suite:
pytest
You can send a POST request to the /process-code endpoint to have the agent document your code.
curlcurl -X 'POST' \
'http://127.0.0.1:8000/process-code' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"code_snippet": "def calculate_average(numbers):\n if not numbers:\n return 0\n return sum(numbers) / len(numbers)"
}'
The API will return a JSON object containing the status, the generated documentation (which includes the validated example), and the agent's thought process.
{
"status": "success",
"documentation": "```python\ndef calculate_average(numbers):\n \"\"\"\n Calculates the average of a list of numbers.\n\n Parameters:\n numbers (list of int or float): A list of numbers to average.\n\n Returns:\n float: The average of the numbers, or 0 if the list is empty.\n\n Example:\n >>> calculate_average([10, 20, 30])\n 20.0\n \"\"\"\n if not numbers:\n return 0\n return sum(numbers) / len(numbers)\n\n# Example usage\nresult = calculate_average([15, 25, 35, 45])\nprint(f\"The average is: {result}\")\n```",
"example_code": "See documentation for example (Agent combines them)",
"agent_trace": "Thought: I need to analyze the code...\nAction: CodeAnalyzer...\nObservation: ...\nThought: I will draft documentation and an example...\nAction: CodeExecutionEnvironment...\nObservation: EXECUTION_SUCCESS: The average is: 30.0\nThought: The example code has been successfully validated. I am now ready to provide the final answer.\nFinal Answer: ..."
}