Live Recording Studio
Capture your screen in real-time with professional-grade recording capabilities
AI Analysis Lab
Upload images for intelligent design and content analysis
PNG, JPG, GIF up to 10MB
#!/usr/bin/env python3 """Cicero Cola - Design Studio Screen Analysis Platform""" import os import asyncio import tempfile import base64 from pathlib import Path from typing import Optional from PIL import Image from loguru import logger import uvicorn from fastapi import FastAPI, File, UploadFile, Form, HTTPException from fastapi.staticfiles import StaticFiles from fastapi.responses import HTMLResponse, JSONResponse from fastapi.middleware.cors import CORSMiddleware from pydantic_ai import Agent from pydantic_ai.models.gemini import GeminiModel from pydantic_ai.messages import BinaryContent from dotenv import load_dotenv # Load environment variables load_dotenv() def setup_environment(): """Setup environment variables and configurations.""" hf_token = os.environ.get("HF_TOKEN") gemini_key = os.environ.get("GEMINI_API_KEY") if hf_token: print(f"✅ HF_TOKEN loaded...") else: print("⚠️ HF_TOKEN not found in environment") if gemini_key: print(f"✅ GEMINI_API_KEY loaded...") else: print("⚠️ GEMINI_API_KEY not found in environment") return hf_token, gemini_key async def analyze_image_with_ai(image_data: bytes, question: str, api_key: str) -> str: """Analyze image using pydantic_ai with BinaryContent.""" try: # Set the API key in environment for Gemini os.environ['GEMINI_API_KEY'] = api_key # Create agent agent = Agent('gemini-2.0-flash-exp') logger.info(f"Agent created with Gemini model") # Create binary content for the image image_content = BinaryContent( data=image_data, media_type='image/png' ) # Run the agent with image and question result = await agent.run([question, image_content]) logger.info(f"Analysis completed successfully") return result.data except Exception as e: logger.error(f"Analysis failed: {str(e)}") return f"Analysis failed: {str(e)}" # Initialize FastAPI app app = FastAPI(title="Cicero Passa a Cola", description="Screen Analysis Platform") # Configure CORS origins = [ "http://localhost", "https://localhost", "http://localhost:7864", "https://localhost:7864", "http://127.0.0.1:7864", "https://127.0.0.1:7864", "http://localhost:8864", "https://localhost:8864", "http://127.0.0.1:8864", "https://127.0.0.1:8864", "https://cicero.im", "http://cicero.im", "https://huggingface.co", "http://huggingface.co", "https://*.huggingface.co", "http://*.huggingface.co", ] app.add_middleware( CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Setup environment hf_token, gemini_key = setup_environment() @app.get("/", response_class=HTMLResponse) async def get_main_page(): """Serve the main HTML page with Cicero Cola design studio interface.""" html_content = f"""
Capture your screen in real-time with professional-grade recording capabilities
Upload images for intelligent design and content analysis