OptimusPrime
OptimusPrime is a Python-based utility directory designed to interface with NVIDIA’s NIM (NVIDIA Inference Microservices) APIs. It provides a straightforward implementation using the standard openai Python SDK to interact with NVIDIA’s hosted large language models (LLMs).
Features
- NVIDIA NIM Integration: Connects directly to
https://integrate.api.nvidia.com/v1to run models hosted on DGX Cloud. - Code Review AI: The included
reviewer.pyscript demonstrates using NVIDIA hosted LLMs to automatically review Python functions for bugs, performance issues, and best practice violations. - Isolated Environment: Uses
uvfor fast and reliable Python virtual environment and dependency management. - Astro Static Documentation: Compiles Markdown documentation and review results directly into zero-JS static HTML/CSS ready for Appwrite Sites deployment.
Prerequisites
- Python 3.8+
- uv (Extremely fast Python package installer and resolver)
- An active NVIDIA API Key
Setup
-
Set your API Key: Export your NVIDIA API key as an environment variable in your terminal session:
export NVIDIA_API_KEY="your_api_key_here" -
Initialize the Virtual Environment: Navigate into the
OptimusPrimedirectory and create a virtual environment usinguv:cd OptimusPrime uv venv source .venv/bin/activate -
Install Dependencies: Install the required packages listed in
requirements.txt:uv pip install -r requirements.txt
Usage
To run the automated code reviewer:
python reviewer.py
What happens under the hood?
- The script initializes the
OpenAIclient pointingbase_urlto NVIDIA’s API (https://integrate.api.nvidia.com/v1). - It sends a sample Python function to the model specified by
NVIDIA_MODEL(defaulting tometa/llama-3.3-70b-instruct). - It uses a low
temperature(0.2) to ensure deterministic and factual code review output. - The API response is parsed and written to
src/pages/review.mdfor instant Astro static site compilation.
Static Site Build & Appwrite Sites Deployment
To compile static HTML/CSS assets into dist/:
npm run build
This outputs a zero-JS bundle ready for Appwrite Sites deployment (dist/index.html and dist/review/index.html).