Skip to content

Latest commit

 

History

History
151 lines (88 loc) · 1.92 KB

File metadata and controls

151 lines (88 loc) · 1.92 KB

AI Interview Assistant - Backend Service

FastAPI backend service providing vision analysis API.

Quick Start

1. Install Dependencies

# Create virtual environment (recommended)
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

2. Configure Environment Variables

Copy .env.example to .env and fill in your OpenAI API Key:

cp .env.example .env

Edit .env file:

OPENAI_API_KEY=sk-your-api-key-here
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o

3. Start Service

python start.py

Or run directly:

python main.py

Or use uvicorn:

uvicorn main:app --host 127.0.0.1 --port 8000 --reload

API Endpoints

Health Check

GET /health

Vision Analysis

POST /api/vision_query

Request body:

{
  "image_base64": "base64_encoded_image_string",
  "prompt": "Please analyze this image (optional)"
}

Response:

{
  "answer": "AI analysis result",
  "success": true,
  "error": ""
}

API Documentation

After starting the service, visit the following addresses to view auto-generated API documentation:

Supported Models

  • gpt-4o (recommended)
  • gpt-4-turbo
  • gpt-4-vision-preview

Troubleshooting

1. API Key Error

Ensure OPENAI_API_KEY in .env file is correctly configured.

2. Module Not Found

Ensure all dependencies are installed:

pip install -r requirements.txt

3. Port Already in Use

Modify PORT configuration in .env file, or specify in command line:

PORT=8001 python start.py

Development

Add New API Endpoints

Add new route functions in main.py.

Modify Vision Analysis Logic

Edit vision.py file.