Skip to content

Commit

Permalink
update ai services & readme
Browse files Browse the repository at this point in the history
  • Loading branch information
habibasseiss committed Feb 16, 2025
1 parent df77553 commit 0e22bf0
Show file tree
Hide file tree
Showing 6 changed files with 603 additions and 210 deletions.
17 changes: 17 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
DATABASE_URL=
SECRET_KEY=

AWS_ACCESS_KEY_ID=
AWS_ENDPOINT_URL_S3=
AWS_REGION=
AWS_SECRET_ACCESS_KEY=
BUCKET_NAME=

CORS_ORIGINS=
FORWARDED_ALLOW_IPS=

GOOGLE_API_KEY=
TOGETHER_API_KEY=
HYPERBOLIC_API_KEY=

AUTH_TOKEN=
121 changes: 120 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,123 @@
# VisuLinx API

A robust FastAPI-based backend service for managing organizations, projects, and file processing with secure authentication.

## 🚀 Features

- **User Management**: Secure user authentication and authorization
- **Organization Management**: Create and manage organizations with multiple users
- **Project Management**: Organize work into projects within organizations
- **File Processing**: Handle file uploads with S3 integration
- **Preferences System**: Flexible system-wide preferences management
- **RESTful API**: Modern, fast, and well-documented API endpoints
- **CORS Support**: Configured for cross-origin resource sharing

## 🏗 Project Structure

```
app/
├── api.py # FastAPI application configuration
├── database.py # Database connection and settings
├── models.py # SQLAlchemy ORM models
├── routers/ # API route handlers
├── schemas.py # Pydantic models for request/response
├── security.py # Authentication and authorization
├── services/ # Business logic services
└── settings.py # Application settings
```

## 🔧 Technical Stack

- **Framework**: FastAPI
- **Database**: SQLAlchemy ORM
- **Authentication**: JWT-based authentication
- **Storage**: AWS S3 integration
- **Data Validation**: Pydantic
- **API Documentation**: Automatic OpenAPI/Swagger docs

## 💻 Key Components

### Models
- **User**: Manages user accounts and authentication
- **Organization**: Handles multi-user organizations
- **Project**: Organizes work within organizations
- **File**: Manages file uploads and processing
- **Preference**: Stores system-wide preferences

### API Endpoints
- `/users`: User management endpoints
- `/auth`: Authentication endpoints
- `/organizations`: Organization management
- `/projects`: Project-related operations
- `/preferences`: System preferences management

### 🤖 AI Services

The project integrates with multiple AI providers for advanced image analysis and object detection:

#### Supported AI Providers
- **Together AI**: Uses the Qwen2-VL-72B-Instruct model for high-quality visual analysis
- **Hyperbolic AI**: Implements the same Qwen model through a different API endpoint
- **Google Gemini**: Utilizes Gemini 1.5 Pro for advanced image processing

#### Features
- **Object Detection**: Extract bounding boxes for objects in images
- **Image Processing**: Automatic image resizing and compression for optimal AI processing
- **Multi-Provider Support**: Fallback options across different AI services
- **Standardized Interface**: Consistent API across all providers through the `AiService` abstract base class

#### Configuration
The AI services require the following environment variables:
```
GOOGLE_API_KEY= # For Gemini AI
TOGETHER_API_KEY= # For Together AI
HYPERBOLIC_API_KEY= # For Hyperbolic AI
```

## 🔒 Security Features

- Secure password hashing
- JWT token-based authentication
- Role-based access control
- CORS middleware configuration

## 🚀 Getting Started

### Prerequisites

- Python >= 3.13
- uv (Python package installer)

### Installation

1. Clone the repository
2. Install dependencies using uv:
```bash
uv sync
```
3. Configure environment variables
4. Run the application:
```bash
uv run fastapi dev
```

## 📝 API Documentation

Once the server is running, access the API documentation at:
- Swagger UI: `http://localhost:8000/docs`

## 🤝 Contributing

1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request

## 📄 License

MIT License

## Autogenerate migration

```sh
Expand All @@ -8,4 +128,3 @@ uv run alembic revision --autogenerate -m "add ... table"

```sh
python -c "import secrets; print(secrets.token_urlsafe(32))"
```
4 changes: 3 additions & 1 deletion app/routers/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ async def extract_bounding_boxes(
if document.contents is not None
}

bounding_boxes = ai_service.extract_bounding_boxes(
ai = ai_service.GeminiAiService()

bounding_boxes = ai.extract_bounding_boxes(
image_url=download_url,
document_contents=document_contents,
system_prompt=preferences['system_prompt'],
Expand Down
Loading

0 comments on commit 0e22bf0

Please sign in to comment.