Installation

Environment Setup

  1. Clone and set up the repository:
git clone https://github.com/Shard-AI/Shard.git
cd Shard
  1. Configure your virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
  1. Configure environment variables:
cp .env.example .env

Edit .env with your credentials:

GEMINI_API_KEY=your_gemini_api_key_here
REDIS_HOSTNAME=localhost
REDIS_PORT=6379

Running the Services

API Server

uvicorn src.app:app --host 0.0.0.0 --port 8000 --reload

Async Worker

celery -A src.core.async_worker worker --loglevel=info --pool=threads

Basic Usage

API Usage

Run the API directly using curl:

curl --request POST -F "video=@path/to/your/video.mp4" http://localhost:8000/v1/interpret

SDK Usage

Video Interpretation

from src.sdk import Shard

# Initialize the client
client = Shard("your_api_key_here")

# Interpret a video
response = client.interpret("/absolute/path/to/video.mp4")
print("Interpretation:", response)

Prompt Adherence Analysis

# Analyze how well a video matches a prompt
prompt = "A person explaining machine learning concepts"
analysis = client.gauge_prompt_adherance("/absolute/path/to/video.mp4", prompt)
print("Prompt adherence analysis:", analysis)

Error Handling

try:
    response = client.interpret("/absolute/path/to/video.mp4")
except VideoNotFoundError:
    print("Video file not found")
except APIError as e:
    print(f"API error: {e}")