Neura AI
  • What is Neura?
    • Releases
      • Neura Artifacto UI v0.2.0 - Revolutionizing User Experience with Image Previews, Image Analysis, and
      • Neura AI v0.5.98 - Artifacto UI Updates, FLUX Pro Ultra & Telegram Formatting and Major System Up
      • Neura AI v0.5.97 - Llama 3.3 70b Versatile and Llama 3.3 70b SpecDec Integrations and Azure Blob
      • Neura AI v0.5.96 Dash Tracking, Telegram Hyperlinks and Get User Ids Improvements
      • Neura AI v0.5.95 - Core System Stability & Integration Improvements
      • Neura AI v0.5.9 - ReDeAct Agents' Action Handling and Decision-Making Optimization
      • Neura AI v0.5.8 - Faster, Smoother, More Reliable
      • Neura AI v0.5.7 Core Request-Response Handling Architecture Optimization
      • Neura AI v0.5.6 - Security Update and Bugs Fix
      • Neura AI v0.5.5 - Security Optimizations, Bugs Patches and Multi-Language Support, Flux 1.1 Pro
      • Neura AI v0.5.4 Optimized Relevant Context Retrieval, Eleven Labs Speech to Text and Enhanced Trello
      • Neura AI v0.5.3 - Telegram Text, Code and Image Format Enhancement - TTS and Upload Fallback Added
      • Neura AI v0.5.2 - Trello Integration, Llama3.1 Improvements, and Parallel API Call Strategy
      • Neura AI v0.5.1 - React Agents Bug Fix, Introducing Top Context To Fetch and Context Optimizations
      • Neura AI v0.5.0: Introducing Lexicon. Our Enhanced NLP Engine For Analysis and Classification
      • Neura AI v0.4.9 Bug Fixes, Sales Bot Optimizations and Context Improvements
      • Neura AI v0.4.8 - Improved User Interface and History Handling
      • Neura AI v0.4.7 - Context Management and Environment Optimizations
      • Neura AI v0.4.6 - Context Optimization and Chat History Metadata to Analysis
      • Neura AI v0.4.5: Enhanced RAG System and Improved Content Retrieval
      • Neura AI v0.4.4 - New Features: Docker Alerts and Sales Bot
      • Neura AI v0.4.3 - Slack Integration
      • Neura AI v0.4.2 - Enhanced Context Management and Group Collaboration
      • Neura AI v0.4.1 - Document Handling, Logging, and System Reliability
      • Neura AI v0.4.0: Introducing Reason-Act Agents, Multi Module Retry Logic and Real-Time Error Alerts
      • Neura AI v0.3.9: Voice Interaction Revolution
      • Neura AI v0.3.8 - Llama 3.1 Integration, Rust Migration, Speech-to-Text, 781 commits and more!
      • Neura AI v0.3.7 - Telegram Integration Features: Track Negative Feedback, and Intelligent Alerts
      • Neura AI v0.3.6 - Image-to-Video and Remove Background Feature
      • Neura AI v0.3.5 - In-painting and Search and Replace Image Processing
      • Neura AI v0.3.4 - Advanced RAG Context Management and Multi-Model Image Generation
      • Neura AI v0.3.3 - Store Data to Database | Optimized Entry Point Response and Discord New Triggers
      • Neura AI v0.3.2 - Improved Context Management and NLP Integration to Purge Context
      • Neura AI v0.3.1 - Enhanced Context and Response Time, Task Determination, Groq and Claude 3.5 Sonnet
      • Neura AI v0.3.0 Update: Chat History RAG, NLP Enhancements, and Multi-Language Image Processing
      • Neura AI v0.2.9 - Feedback and Sentiment Mechanism for Telegram Groups
      • Neura AI v0.2.8 - Telegram Integration - Text Formatting Enhancements
      • Neura AI v0.2.7 - Enhanced Analysis Process, 16_ID, Image Upload Processing, Token Usage Tracking
      • Neura AI v0.2.6 - GPT4o Integration, Enhanced API, URL Sanitizer, Additional Logging and Bugs Fixed
      • Neura AI v0.2.5 - Advanced API Rate Limiting and Exponential Backoff Integration
      • Neura AI v0.2.4 - Image Upload Handling, Generation Module and LLM Interaction Enhanced
      • Neura AI v0.2.3 - Bug Fix: Azure Blob Upload Bug Resolved
      • Neura AI - Enhanced AI-Driven Interaction Capabilities
      • Neura AI v0.2.1 - Updating Asynchronous Architecture, RAG Cosine
      • Neura AI v0.2.0 - Modularization of the API Endpoint, Bug fixes, and Azure Blob Migration
      • Neura AI v0.1.92 Improved Database Retrieval and Response Performance
      • Neura AI v0.1.91 - API v1.1 - Interact Endpoint Enhanced - Support For Multipart/Form-Data
      • Neura AI v0.1.9 - RAG Similarity | Initial Query Triggers Added | FE Improvements
      • Neura AI v0.1.8 - Image Generation Enhanced, New NLP Triggers, Additional Modularization
      • Neura AI v0.1.7 Image Analysis Improvement, Mint NFT Button Improvement, and Additional Triggers Ad
      • Neura AI 0.1.6 - Frontend Update, Integration of Additional NLP Triggers and STT
      • Neura AI v0.1.5 | NLP for image generation, dynamic styling for dark or light mode and more
      • Neura v0.1.4 | Img previews, API CORS+OPTIONS, user-icon added, generate images with user query+URL
      • Neura AI v0.1.3 | Successful Resolution of Socket.IO Issues and Frontend Modularization
      • Neura AI v0.1.2 | Integration of Multiple Endpoints with FastAPI and Httpx
      • Neura AI v0.1.1 | BE Architecture and FastAPI Migration
      • WIP -> Upload Button Integration
    • Scope and Goals
    • Modular Architecture
    • Context and Database (RAG)
    • Integrations
      • Telegram Oracle v0.1.0
        • Fana Telegram Oracle Agent v0.2.0 - Revamped Doc Update
        • Fana Telegram Oracle Agent v0.3.0
      • Trello
      • Discord
      • Slack
    • Applications
      • Neura Artifacto User Interface v0.3.0
      • Neura Autonomous Agents
      • Neura Transcribe (TSB)
      • Neura AI Insight Forge - Your WebGenius Scraper and FAQ Engine v0.2.0
      • Neura Email Sales Agent (ESA)
        • Neura Email Oracle Agent v0.1.1 - Enhancements to Self-Loop Email Handling and OOF Filters
    • API
    • Software Development Kits (SDK)
      • Rust
      • Typescript
    • Security and Authentication
    • Upcoming Features and Product Roadmap
    • Getting Started - Read.me
    • Project Diagram and Structure
Powered by GitBook
On this page
  • What's new?
  • Advanced Rate Limiting For Chat Generations
  • Advanced Rate Limiting For Image Generation
  • Robust Retry Mechanism with Tenacity:
  • Enhanced Media Handling:
  1. What is Neura?
  2. Releases

Neura AI v0.2.5 - Advanced API Rate Limiting and Exponential Backoff Integration

This is a critical update introducing enhanced security and reliability features in our API infrastructure, such as the integration of rate limiting and exponential backoff with robust retry mechanism

PreviousNeura AI v0.2.6 - GPT4o Integration, Enhanced API, URL Sanitizer, Additional Logging and Bugs FixedNextNeura AI v0.2.4 - Image Upload Handling, Generation Module and LLM Interaction Enhanced

Last updated 1 year ago


These features are designed to improve both the performance and security of our application. Once limit is reached, our application should throw a 429 Error Code - Rate limit reached for FANA LLM requests

What's new?

Advanced Rate Limiting For Chat Generations

  • Implementation: Utilizes FastAPILimiter integrated with a Redis backend to manage rate limiting effectively.

  • Functionality: Ensures that endpoint such as / are limited to a maximum of 30 requests per 60 seconds, preventing abuse and ensuring equitable resource usage with the for image generation.

  • Benefits: Protects the API from overuse and potential DDoS attacks, enhancing the security and availability of our services.

from fastapi_limiter.depends import RateLimiter

@router.get(
    "/",
    tags=["api_v1"],
    summary="Read Main Endpoint",
    dependencies=[Depends(RateLimiter(times=30, seconds=60))]
)
def read_main(api_key: str = Depends(get_api_key)):
    try:
        # Assuming fetch_data might fail
        data = fetch_data(api_key)
        return {"msg": "Hello from FANA LLM API V1", "data": data}
    except Exception as e:
        logging.error(f"Failed on attempt {retry_state.attempt_number}: {e}")
        raise HTTPException(status_code=500, detail="Service unavailable, please try again later.")

Advanced Rate Limiting For Image Generation

  • Implementation: Utilizes FastAPILimiter integrated with a Redis backend to manage rate limiting effectively.

  • Benefits: Protects the API from overuse and potential DDoS attacks, enhancing the security and availability of our services.

from fastapi_limiter.depends import RateLimiter

@router.get(
    "/",
    tags=["api_v1"],
    summary="Read Main Endpoint",
    dependencies=[Depends(RateLimiter(times=15, seconds=60))]
)
def read_main(api_key: str = Depends(get_api_key)):
    try:
        # Assuming fetch_data might fail
        data = fetch_data(api_key)
        return {"msg": "Hello from FANA LLM API V1", "data": data}
    except Exception as e:
        logging.error(f"Failed on attempt {retry_state.attempt_number}: {e}")
        raise HTTPException(status_code=500, detail="Service unavailable, please try again later.")

Robust Retry Mechanism with Tenacity:

  • Implementation: Uses the tenacity library to implement retries with exponential backoff.

  • Scope: Applied to critical API operations that may require resilience in face of transient issues.

  • Benefits: Increases the reliability of endpoint operations by automatically retrying failed operations, optimizing for both performance and reduced error rates.

  • Functionality: The system first waits 8 seconds to retry it, then 16 seconds for the next retry, and finally 64 seconds for the last retry. If all retries fail, the system will take appropriate actions, such as logging an error or notifying the user.

from tenacity import retry, stop_after_attempt, wait_exponential

@retry(wait=wait_exponential(multiplier=1, min=8, max=64), stop=stop_after_attempt(3))@retry(wait=wait_exponential(multiplier=1, min=8, max=64), stop=stop_after_attempt(3))
@router.post("/interact-with-llm/")

completion_with_backoff(model="gpt-3.5-turbo-16k-0613", messages=[{"role": "user", "content": "Once upon a time,"}])
  • Multiplier: Sets how much the wait time increases with each retry. A multiplier of 1 means each wait time is double the previous one.

  • Min and Max: The minimum wait time starts at 8 seconds, and it will not exceed 64 seconds regardless of the number of retries.

  • Stop After Attempt: Limits the number of retries to 3.

Enhanced Media Handling:

  • Update: Improvements in the LLM model interaction, now supporting a broader range of media types.

  • Impact: Allows users to interact more flexibly with the platform using different media formats, enhancing user experience.


Additional Information: For more details on configuring and utilizing the new rate limiting and retry features, please refer to our updated documentation or contact our support team.


Functionality: Ensures that endpoints such as / are limited to a maximum of 15 requests per 60 seconds, preventing abuse and ensuring equitable resource usage with the for image generation.

OpenAI rate limit
OpenAI rate limit