A FastAPI-powered application that executes system functions through natural language commands using Retrieval-Augmented Generation (RAG).
This API interprets everyday language instructions (like "open Chrome" or "check CPU usage") and dynamically retrieves and executes the corresponding system functions. Perfect for automating routine desktop tasks or building voice-controlled system tools without complex command syntax.
- ✅ Natural language processing for system function execution
- 🔍 RAG-based approach for intelligent function matching
- 📊 Function execution metrics and logging
- 🔐 Error handling and exception management
- 🌐 RESTful API with Swagger documentation
- 🧩 Modular design for easy extension with new functions
- Python 3.8+ - Core programming language
- FastAPI - Modern, high-performance web framework
- RAG (Retrieval-Augmented Generation) - For function mapping
- Vector Store - Function indexing and retrieval
- Uvicorn - ASGI server for running the API
function-execution-api/
├── api/
│ └── main.py # FastAPI application entry point
├── rag_engine/
│ └── vector_store.py # Function storage and retrieval
├── automation_functions/
│ └── system_functions.py # System function implementations
├── utils/
│ ├── code_generator.py # Dynamic code generation utilities
│ └── logger.py # Execution logging functionality
├── logs/
│ └── function_metrics.json # Execution metrics storage
├── requirements.txt # Project dependencies
└── README.md # Project documentation
- User Input: Send a natural language command to the API (e.g., "Open Chrome browser")
- Function Retrieval: The RAG engine matches the command to available functions in the vector store
- Code Generation: The system dynamically generates executable code for the matched function
- Execution: The function is executed and results are returned
- Logging: All executions are logged with metrics for performance analysis
┌──────────┐ ┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ User │──────▶ RAG Vector │──────▶ Dynamic Code │──────▶ System │
│ Query │ │ Store │ │ Generation │ │ Execution │
└──────────┘ └─────────────┘ └──────────────┘ └─────────────┘
│
┌──────────┐ ┌─────────────┐ │
│ API │◀─────┤ Execution │◀──────────────────────────────────┘
│ Response │ │ Metrics │
└──────────┘ └─────────────┘
- Python 3.8+
- pip (Python package manager)
- Virtual environment (recommended)
- Clone the repository
git clone https://github.com/yourusername/function-execution-api.git
cd function-execution-api- Create and activate virtual environment
# Create virtual environment
python -m venv venv
# Activate on Windows
venv\Scripts\activate
# Activate on macOS/Linux
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Run the API
uvicorn api.main:app --reload- Access the API
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
Using cURL:
curl -X 'POST' \
'http://127.0.0.1:8000/execute' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "Open Chrome"
}'Using Python requests:
import requests
response = requests.post(
"http://127.0.0.1:8000/execute",
json={"prompt": "Open Chrome"}
)
print(response.json())Current system functions include:
- Opening Google Chrome browser
- Opening system calculator
- Retrieving system resources (CPU/RAM usage)
- Running shell commands
To view execution metrics:
curl http://127.0.0.1:8000/metricsContributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.