An AI-powered agent that processes human queries and generates executable codebases or text responses based on the query's suitability.
- Query Processing: Enter natural language queries to describe what you want to build
- File Upload Support: Upload PDF, TXT, or DOCX files with additional context
- Intelligent Output: Automatically determines whether to generate code or provide text responses
- Code Generation: Creates well-structured, production-ready codebases with proper organization
- Template System: Pre-built query templates for common use cases
- Simple UI: Clean, minimalist interface with excellent UX
simple_agent/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI application
│ ├── config.py # Configuration settings
│ ├── agent/
│ │ ├── __init__.py
│ │ └── agent.py # Core agent logic
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── file_processor.py # File upload processing
│ │ └── output_manager.py # Output generation
│ └── static/
│ ├── index.html # Frontend UI
│ ├── style.css # Styling
│ └── script.js # Frontend logic
├── outputs/ # Generated outputs directory
├── requirements.txt # Python dependencies
├── dockerfile # Python Standard dockerfile
└── README.md
- Python 3.8 or higher
- pip (Python package manager)
-
Clone or navigate to the project directory:
cd simple_agent -
Create a virtual environment (recommended):
python -m venv venv # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.envfile in the project root:OPENAI_API_KEY=your_openai_api_key_here # OR ANTHROPIC_API_KEY=your_anthropic_api_key_here # OR GOOGLE_API_KEY=your_google_api_key_here
Note: You need at least one API key (OpenAI, Anthropic, or Google Gemini) for the agent to work. The agent will use APIs in the following priority order: OpenAI > Anthropic > Google Gemini. If no API key is provided, the agent will use a fallback mode with basic code generation.
-
Run the application:
python -m app.main
Or using uvicorn directly:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
-
Access the application:
Open your browser and navigate to:
http://localhost:8000
-
Enter a Query: Type your request in the query textarea. For example:
- "Create a simple web application with a todo list feature"
- "Build a REST API with user authentication"
- "Generate a Python script for data analysis"
-
Upload Context (Optional): Upload a PDF, TXT, or DOCX file with additional requirements or context.
-
Use Templates (Optional): Click "Load Template" to see pre-built query templates and select one.
-
Submit: Click "Process Query" to generate the output.
-
Download: Once processing is complete, download the generated codebase (ZIP) or text response (TXT).
Code Generation Queries:
- "Create a FastAPI application with user authentication and JWT tokens"
- "Build a React component library with TypeScript"
- "Generate a Python script to analyze CSV files and create visualizations"
Text Response Queries:
- "Explain how machine learning works"
- "What is the difference between REST and GraphQL?"
- "Describe the software development lifecycle"
Edit app/config.py to customize:
- API Keys: Set via environment variables or
.envfile - Model Selection: Choose default LLM model
- Output Settings: Configure output directory and file size limits
- Code Generation: Adjust thresholds and enable/disable features
Main UI page
Process a query and generate output
- Body:
multipart/form-dataquery(string, required): User queryfile(file, optional): Uploaded file
Download generated output file
Get list of available query templates
The SimpleAgent class:
- Analyzes queries to determine if code generation is appropriate
- Detects programming languages and frameworks
- Generates codebases using LLM APIs (OpenAI/Anthropic/Google Gemini)
- Falls back to basic templates if APIs are unavailable
- Codebases: Generated as ZIP files with proper directory structure
- Text Responses: Generated as TXT files with formatted content
- All outputs are stored in the
outputs/directory
- Maintainable Code: Modular structure with clear separation of concerns
- Extensible Design: Easy to add new features and integrations
- Error Handling: Comprehensive error handling throughout
- Type Hints: Python type hints for better code clarity
- Documentation: Inline comments and docstrings
- Ensure your
.envfile is in the project root - Verify API keys are correctly set
- Check API key permissions and quotas
- Maximum file size: 10MB
- Supported formats: PDF, TXT, MD, DOCX
- Ensure files are not corrupted
- Check
outputs/directory permissions - Verify sufficient disk space
- Review application logs for errors
Potential features for extension:
- Support for more file formats
- Additional LLM providers
- Code execution and testing
- Version control integration
- Multi-language support
- Advanced code analysis
This project is open source and available for use and modification.
Contributions are welcome! Please ensure:
- Code follows existing style and patterns
- New features include appropriate tests
- Documentation is updated
SimpleAgent v1.0.0 - Built with FastAPI & AI