Spaces:
Runtime error
A newer version of the Gradio SDK is available:
6.5.1
API Update Changelog - October 31, 2025
Summary
Migrated from AI-powered auto-categorization to direct categorical data input API. This update removes external AI API dependencies (Perplexity and Gemini) and provides a more straightforward, efficient prediction service.
Changes Made
π΄ Removed Features
AI API Integrations
- β Perplexity Sonar Reasoning Pro (business categorization)
- β Gemini Pro Vision (pattern detection)
- β All external API calls and dependencies
Functions Removed
analyze_images_with_perplexity()- Previously used for auto-categorizing business contextdetect_pattern_with_gemini()- Previously used for detecting A/B test patternsload_pattern_descriptions()- Pattern data loader (no longer needed)image_to_base64()- Image conversion for API callspredict_with_auto_categorization()- Main auto-prediction function
Dependencies Removed
requestslibrary (no external HTTP calls)base64module (no image encoding needed)BytesIOfrom io module (no in-memory buffer needed)concurrent.futures(no parallel API calls needed)
Configuration Removed
PERPLEXITY_API_KEYenvironment variablePERPLEXITY_API_URLconstantGEMINI_API_KEYenvironment variableGEMINI_API_URLconstantpattern_descriptionsglobal variable
π’ Added Features
New Main Function
predict_with_categorical_data()- Accepts images + categorical data directly- Clean, focused API with no external dependencies
- Faster response times (no network latency)
Enhanced Response Format
- Simplified JSON structure
- Clear separation of prediction results, provided categories, and processing info
- All confidence metrics included in single response
Updated Gradio Interface
- Renamed "π€ Smart Auto-Prediction" tab to "π― API Prediction"
- Updated descriptions to reflect direct input requirement
- Cleaner UI focused on manual categorical selection
π Modified Features
predict_single()
- No changes to core functionality
- Still handles image processing, OCR, and model inference
- Returns same detailed prediction results
get_confidence_data()
- No changes - still uses Industry + Page Type for confidence scoring
- Maintains same fallback logic
Gradio Interface Layout
- Tab 1: "π― API Prediction" (replaces auto-prediction)
- Tab 2: "π Manual Selection" (unchanged)
- Tab 3: "Batch Prediction from CSV" (unchanged)
File Changes
Modified Files
app.py
- Removed ~400 lines of AI API code
- Added new
predict_with_categorical_data()function - Updated Gradio interface
- Cleaned up imports
requirements.txt
- Removed:
requests - Kept all other dependencies (torch, transformers, gradio, etc.)
- Removed:
README.md
- Updated overview section
- Removed AI architecture section
- Removed API key requirements
- Added reference to API_USAGE_UPDATED.md
New Files
API_USAGE_UPDATED.md
- Complete API documentation
- Input/output specifications
- Example usage code
- Migration guide
CHANGELOG_API_UPDATE.md (this file)
- Detailed change log
- Migration instructions
API Changes
Before (Auto-Categorization)
# Input: Only images
result = predict_with_auto_categorization(
control_image=control_img,
variant_image=variant_img
)
# Output: Included auto-detected categories and patterns
{
"predictionResults": {...},
"autoDetectedCategories": {...},
"detectedPattern": {...},
"processingInfo": {...}
}
After (Direct Input)
# Input: Images + Categorical data
result = predict_with_categorical_data(
control_image=control_img,
variant_image=variant_img,
business_model="SaaS",
customer_type="B2B",
conversion_type="High-Intent Lead Gen",
industry="B2B Software & Tech",
page_type="Awareness & Discovery"
)
# Output: Prediction with provided categories
{
"predictionResults": {...},
"providedCategories": {...},
"processingInfo": {...}
}
Migration Guide
For Existing Users
If you were using the auto-categorization feature:
Determine Categories: You'll need to provide categorical data explicitly
- Business Model (4 options)
- Customer Type (4 options)
- Conversion Type (6 options)
- Industry (14 options)
- Page Type (5 options)
Update API Calls: Change from
predict_with_auto_categorization()topredict_with_categorical_data()Update Response Handling:
- Remove pattern detection logic
- Use
providedCategoriesinstead ofautoDetectedCategories
Remove API Keys: No longer need PERPLEXITY_API_KEY or GEMINI_API_KEY
Benefits of Migration
β Faster: No external API latency (2-4s vs 10-15s previously) β Cheaper: No external API costs β Simpler: Direct input/output, no complex AI logic β More Reliable: No dependency on external services β More Control: User decides categorization instead of AI
Performance Comparison
Before (With AI APIs)
- Average processing time: 10-15 seconds
- External API calls: 2 (Perplexity + Gemini)
- Cost per prediction: ~$0.01-0.02
- Failure points: 3 (Perplexity, Gemini, Model)
After (Direct Input)
- Average processing time: 2-4 seconds
- External API calls: 0
- Cost per prediction: GPU compute only
- Failure points: 1 (Model only)
Testing Recommendations
- Verify categorical mappings: Ensure all category values match expected options
- Test confidence scoring: Verify Industry + Page Type combinations return correct stats
- Batch testing: Test with multiple samples to ensure consistency
- Error handling: Test with invalid categories to ensure proper error messages
Support
For issues or questions:
- See
API_USAGE_UPDATED.mdfor detailed documentation - Check
confidence_scores.jsonfor available category combinations - Review
README.mdfor general information
Version Info
- Previous Version: Auto-categorization with Perplexity + Gemini
- Current Version: Direct categorical input
- Update Date: October 31, 2025
- Breaking Changes: Yes (API signature changed)