1. 06 Feb, 2026 40 commits
    • Stefy Lanza (nextime / spora )'s avatar
      Add comprehensive tool calls support for Google and Anthropic providers · 60ca20d2
      Stefy Lanza (nextime / spora ) authored
      GoogleProviderHandler enhancements:
      - Process all parts in response content (not just first part)
      - Extract and combine all text parts
      - Detect and convert Google function_call to OpenAI tool_calls format
      - Generate unique call IDs for tool calls
      - Handle function responses for debugging
      - Set content to None when tool_calls are present (OpenAI convention)
      - Add comprehensive logging for tool call detection and conversion
      - Support both text and function/tool calls in same response
      - Validate response against ChatCompletionResponse Pydantic model
      - Add detailed response structure logging
      
      AnthropicProviderHandler enhancements:
      - Process all content blocks (not just text)
      - Detect and convert Anthropic tool_use blocks to OpenAI tool_calls format
      - Generate unique call IDs for tool calls
      - Combine all text parts from multiple blocks
      - Set content to None when tool_calls are present (OpenAI convention)
      - Add comprehensive logging for tool_use detection and conversion
      - Validate response against ChatCompletionResponse Pydantic model
      - Add detailed response structure logging
      
      Both handlers now properly translate provider-specific function calling
      formats to OpenAI-compatible tool_calls structure, ensuring clients receive
      valid structured responses with proper schema validation.
      60ca20d2
    • Stefy Lanza (nextime / spora )'s avatar
      Add comprehensive debug logging for Google GenAI response parsing · 627f1407
      Stefy Lanza (nextime / spora ) authored
      - Log response type and all attributes
      - Log candidates structure and length
      - Log candidate attributes and content structure
      - Log parts structure and first part details
      - Log raw text extraction and parsing steps
      - Log final extracted text and finish reason
      - Add error logging with full stack trace for exceptions
      
      This will help identify where the parsing is failing when responses
      show as 'parsed=None' and clients receive nothing.
      627f1407
    • Stefy Lanza (nextime / spora )'s avatar
      Fix Google GenAI response translation to OpenAI format · 9c5d68d9
      Stefy Lanza (nextime / spora ) authored
      - Properly extract finish_reason from candidate object and map to OpenAI format
      - Correctly extract usage metadata from response.usage_metadata structure
      - Extract prompt_token_count, candidates_token_count, and total_token_count
      - Add logging for usage metadata extraction
      - Handle Google finish reasons: STOP, MAX_TOKENS, SAFETY, RECITATION, OTHER
      
      This fixes the issue where Gemini responses were arriving corrupted to
      OpenAI-compatible clients due to incorrect parsing of the new Google GenAI
      SDK response structure.
      9c5d68d9
    • Stefy Lanza (nextime / spora )'s avatar
      Fix: Translate Google and Anthropic responses to OpenAI format · 3a46b7ad
      Stefy Lanza (nextime / spora ) authored
      - Google: Parse formatted responses with JSON structure (e.g., 'assistant: [{'type': 'text', 'text': '...'}]')
      - Anthropic: Extract text from content blocks and map stop_reason to finish_reason
      - Both handlers now return properly formatted OpenAI-compatible responses
      - Ensures clients receive correctly structured messages without malformed content
      3a46b7ad
    • Stefy Lanza (nextime / spora )'s avatar
      Add AISBF_DEBUG environment variable for conditional message logging · d0cdc55a
      Stefy Lanza (nextime / spora ) authored
      - Added AISBF_DEBUG check to control verbose message content logging
      - Messages are only dumped when AISBF_DEBUG=true/1/yes
      - Otherwise only message count is logged
      - Applies to Google, OpenAI, and Anthropic provider handlers
      - Reduces log verbosity in production while maintaining debug capability
      d0cdc55a
    • Stefy Lanza (nextime / spora )'s avatar
      Fix: Extract text from nested Google GenAI response structure · 631d4c4d
      Stefy Lanza (nextime / spora ) authored
      - Fixed GoogleProviderHandler to properly extract text from response.candidates[0].content.parts[0].text
      - Added error handling for text extraction
      - Resolves client error 'Cannot read properties of undefined (reading '0')'
      - The Google GenAI SDK returns nested response structure, not direct .text property
      631d4c4d
    • Stefy Lanza (nextime / spora )'s avatar
      Fix provider handler errors · 871fcdaf
      Stefy Lanza (nextime / spora ) authored
      - Fixed GoogleProviderHandler to return OpenAI-style response format
      - Added tools and tool_choice parameters to OllamaProviderHandler (accepted but ignored)
      - Fixed OpenAI message building to properly handle tool messages with tool_call_id
      - Fixed max_tokens handling to avoid passing null values to APIs
      - Converted Ollama response to OpenAI-style format for consistency
      
      This fixes the following errors:
      - 'Cannot read properties of undefined (reading '0')' - Google response format issue
      - 'OllamaProviderHandler.handle_request() got an unexpected keyword argument 'tools''
      - 'for 'role:tool' the following must be satisfied[('messages.23.tool_call_id' : property 'tool_call_id' is missing)]'
      - 'Invalid input: expected number, received null' for max_tokens parameter
      871fcdaf
    • Stefy Lanza (nextime / spora )'s avatar
      Try to fix... · ef580a2b
      Stefy Lanza (nextime / spora ) authored
      ef580a2b
    • Stefy Lanza (nextime / spora )'s avatar
      Add tool_call_id field to Message model · 38a58f51
      Stefy Lanza (nextime / spora ) authored
      - Add optional tool_call_id field to Message model
      - Required for tool response messages (role:tool)
      - Identifies which tool call the response is for
      - Fixes 400 errors for missing tool_call_id in tool messages
      38a58f51
    • Stefy Lanza (nextime / spora )'s avatar
      Fix missing autoselect_config parameter in streaming request · 948f7b63
      Stefy Lanza (nextime / spora ) authored
      - Pass autoselect_config to _get_model_selection in handle_autoselect_streaming_request
      - Fixes TypeError: missing 1 required positional argument
      - Ensures streaming autoselect requests use the configured selection_model
      948f7b63
    • Stefy Lanza (nextime / spora )'s avatar
      Add tool_calls field and make content optional in Message model · 11082190
      Stefy Lanza (nextime / spora ) authored
      - Add optional tool_calls field to Message model
      - Make content field optional with default None
      - Allows assistant messages with tool_calls instead of content
      - Fixes 422 validation errors for tool call messages
      - Supports OpenAI message format with function calls
      11082190
    • Stefy Lanza (nextime / spora )'s avatar
      Fix exception handler to use RequestValidationError · bd5b2939
      Stefy Lanza (nextime / spora ) authored
      - Import RequestValidationError from fastapi.exceptions
      - Update exception handler to catch RequestValidationError instead of status code
      - Add console logging for immediate visibility of validation errors
      - Log validation error details using exc.errors() method
      bd5b2939
    • Stefy Lanza (nextime / spora )'s avatar
      Add exception handler for 422 validation errors · dce9a861
      Stefy Lanza (nextime / spora ) authored
      - Add exception handler to catch and log validation errors
      - Log request path, method, headers, and raw body
      - Log validation error details from FastAPI
      - Helps diagnose why requests are failing validation
      dce9a861
    • Stefy Lanza (nextime / spora )'s avatar
      Update start_proxy.sh to use 127.0.0.1:17765 by default · 9fea17b2
      Stefy Lanza (nextime / spora ) authored
      - Change host from 0.0.0.0 to 127.0.0.1 for improved security
      - Change port from 8000 to 17765 to match main.py default
      - Ensures consistency between development and production modes
      9fea17b2
    • Stefy Lanza (nextime / spora )'s avatar
      Add debug logging for autoselect request validation · 78bd7ea5
      Stefy Lanza (nextime / spora ) authored
      - Log raw request body before validation to diagnose 422 errors
      - Log request headers and path for debugging
      - Make Message content field more flexible with List type
      - Helps identify validation issues in incoming requests
      78bd7ea5
    • Stefy Lanza (nextime / spora )'s avatar
      Make selection_model field optional with default value · b560e363
      Stefy Lanza (nextime / spora ) authored
      - Set default value for selection_model to 'general' in AutoselectConfig
      - Maintains backward compatibility with existing configuration files
      - Prevents 422 errors when loading configs without selection_model field
      b560e363
    • Stefy Lanza (nextime / spora )'s avatar
      Use selection_model field from autoselect configuration · 3b6feed8
      Stefy Lanza (nextime / spora ) authored
      - Add selection_model field to AutoselectConfig model
      - Update _get_model_selection to use autoselect_config.selection_model instead of hardcoded 'general'
      - Update handle_autoselect_request to log selection_model from config
      - Update handle_autoselect_streaming_request to log selection_model from config
      - Allows flexible configuration of which rotation to use for model selection
      3b6feed8
    • Stefy Lanza (nextime / spora )'s avatar
      Add selection_model field to autoselect configuration · dde30272
      Stefy Lanza (nextime / spora ) authored
      - Add selection_model field to specify which rotation to use for model selection
      - Default value is 'general' rotation
      - Allows explicit control over which rotation models are available for autoselect
      - Provides flexibility in configuring autoselect behavior
      dde30272
    • Stefy Lanza (nextime / spora )'s avatar
      Increase max retries for rotation and autoselect models from 2 to 5 · 7fcfacfe
      Stefy Lanza (nextime / spora ) authored
      - Changed max_retries from 2 to 5 in RotationHandler.handle_rotation_request
      - Provides more opportunities to find a working model when errors occur
      - Especially helpful for tool call errors and other transient failures
      - Improves reliability of rotation and autoselect model selection
      7fcfacfe
    • Stefy Lanza (nextime / spora )'s avatar
      Add support for tools and tool_choice with retry on tool call errors · e4148fcf
      Stefy Lanza (nextime / spora ) authored
      - Add tools and tool_choice fields to ChatCompletionRequest model
      - Update OpenAIProviderHandler to accept and pass tools/tool_choice parameters
      - Update handlers to pass tools/tool_choice from request to provider
      - Treat tool call errors during streaming as provider failures
      - Record failure and re-raise to trigger retry with next model in rotation
      - Allows proper tool/function calling support through the proxy
      - Resolves 'Tool choice is none, but model called a tool' error by retrying with another model
      e4148fcf
    • Stefy Lanza (nextime / spora )'s avatar
      Add debug logging for streaming chunk serialization errors · 9840590a
      Stefy Lanza (nextime / spora ) authored
      - Log chunk type and content before serialization attempt
      - Log chunk type and content when serialization fails
      - Helps diagnose 'Tool choice is none, but model called a tool' errors
      - Apply debug logging to both RequestHandler and AutoselectHandler streaming methods
      9840590a
    • Stefy Lanza (nextime / spora )'s avatar
      Handle tool call errors during streaming response serialization · fccf6bca
      Stefy Lanza (nextime / spora ) authored
      - Add try-catch around chunk serialization in stream_generator functions
      - Skip chunks that fail to serialize (e.g., tool calls without tool_choice)
      - Log warnings for chunk serialization errors
      - Prevent streaming failures when models attempt tool calls without proper configuration
      - Apply fix to both RequestHandler and AutoselectHandler streaming methods
      fccf6bca
    • Stefy Lanza (nextime / spora )'s avatar
      Update documentation with detailed descriptions of rotations and autoselect models · 08361f16
      Stefy Lanza (nextime / spora ) authored
      - Add Key Features section to README.md
      - Describe Rotation Models with weighted load balancing and automatic failover
      - Describe Autoselect Models with AI-powered content analysis
      - Update Rotation Endpoints with detailed model descriptions
      - Update Autoselect Endpoints with detailed model descriptions
      - Add comprehensive Rotation Models section to DOCUMENTATION.md
      - Add comprehensive Autoselect Models section to DOCUMENTATION.md
      - Include example use cases for both rotation and autoselect models
      - Update overview with key features and capabilities
      - Document fallback behavior to 'general' when autoselect can't choose a model
      08361f16
    • Stefy Lanza (nextime / spora )'s avatar
      Bump version to 0.3.0 · 7f71e9d7
      Stefy Lanza (nextime / spora ) authored
      - Update version to 0.3.0 in setup.py, pyproject.toml, and aisbf/__init__.py
      7f71e9d7
    • Stefy Lanza (nextime / spora )'s avatar
      Change default listening address to 127.0.0.1:17765 · 0fb18e5c
      Stefy Lanza (nextime / spora ) authored
      - Update host from 0.0.0.0 to 127.0.0.1 for localhost-only access
      - Update port from 8000 to 17765
      - Update log message to reflect new address
      0fb18e5c
    • Stefy Lanza (nextime / spora )'s avatar
      Make autoselect skill file more explicit about model selection output · bec2198c
      Stefy Lanza (nextime / spora ) authored
      - Add prominent ABSOLUTELY CRITICAL section emphasizing ONLY output requirement
      - Explicitly state NO additional text, explanations, or commentary
      - Add repeated warnings about outputting nothing except the single tag
      - Clarify that any extra text will cause system failure
      - Add examples of what NOT to include in response
      bec2198c
    • Stefy Lanza (nextime / spora )'s avatar
      Fix streaming response serialization in handlers · 218a35ee
      Stefy Lanza (nextime / spora ) authored
      - Properly serialize Stream chunks to JSON format
      - Convert ChatCompletionChunk objects using model_dump()
      - Apply fix to both RequestHandler and AutoselectHandler streaming methods
      - Resolves socket.send() exceptions during streaming
      218a35ee
    • Stefy Lanza (nextime / spora )'s avatar
      Fix streaming response error in OpenAIProviderHandler · 029c0668
      Stefy Lanza (nextime / spora ) authored
      - Fixed AttributeError when stream=True is passed to OpenAI client
      - Changed return type to Union[Dict, object] to support streaming
      - Added conditional check to return Stream object for streaming requests
      - Bumped version to 0.2.7
      029c0668
    • Stefy Lanza (nextime / spora )'s avatar
    • Stefy Lanza (nextime / spora )'s avatar
      Bump version to 0.2.6 · 0e11175f
      Stefy Lanza (nextime / spora ) authored
      0e11175f
    • Stefy Lanza (nextime / spora )'s avatar
    • Stefy Lanza (nextime / spora )'s avatar
      Bump version to 0.2.5 · e1743674
      Stefy Lanza (nextime / spora ) authored
      e1743674
    • Stefy Lanza (nextime / spora )'s avatar
      Fix KeyError when successful model is not updated after retry · c02b723f
      Stefy Lanza (nextime / spora ) authored
      - Add successful_model variable to track which model actually worked
      - Update successful_model when request succeeds in retry loop
      - Log which model was successfully used
      - Prevents KeyError when trying to access provider_id from selected_model
      - Ensures proper model tracking across retry attempts
      c02b723f
    • Stefy Lanza (nextime / spora )'s avatar
      Add retry logic for rotation requests on failure or timeout · 02d66b50
      Stefy Lanza (nextime / spora ) authored
      - Try up to 2 different models when a request fails or times out
      - Track which models have been tried to avoid repeating failures
      - Log each attempt with attempt number and model details
      - Record failures and rate limit providers automatically
      - Provide detailed error logging for each failed attempt
      - Return comprehensive error message when all retries are exhausted
      - Include last error in final error response for debugging
      02d66b50
    • Stefy Lanza (nextime / spora )'s avatar
      Add validation warnings when loading rotations.json · 0470bf4b
      Stefy Lanza (nextime / spora ) authored
      - Validate that all providers referenced in rotations exist in providers.json
      - Log visible warnings with !!! CONFIGURATION WARNING !!! markers
      - Show available providers when a referenced provider is missing
      - Indicate that missing providers will be skipped during requests
      - Provide guidance on how to fix the configuration issue
      - Log successful validation with checkmarks for available providers
      0470bf4b
    • Stefy Lanza (nextime / spora )'s avatar
      Add error handling for missing providers in rotation configuration · fbfab4ba
      Stefy Lanza (nextime / spora ) authored
      - Check if provider exists in configuration before creating handler
      - Log error with available providers when provider is not found
      - Skip providers that don't exist instead of crashing
      - Prevents AttributeError when rotation references non-existent provider
      fbfab4ba
    • Stefy Lanza (nextime / spora )'s avatar
      Add new autoselect API endpoints at /api/autoselect · 1545c2cc
      Stefy Lanza (nextime / spora ) authored
      - Add GET /api/autoselect endpoint to list all available autoselect configurations
      - Add POST /api/autoselect/chat/completions endpoint for autoselect chat completions
      - Model name in request now selects the specific autoselect configuration
      - Add GET /api/autoselect/models endpoint to list all models across all autoselect configurations
      - Maintain backward compatibility with existing /api/{provider_id} endpoints
      - Follows same pattern as rotation endpoints for consistency
      1545c2cc
    • Stefy Lanza (nextime / spora )'s avatar
      Add new rotation API endpoints at /api/rotations · 9f5592c4
      Stefy Lanza (nextime / spora ) authored
      - Add GET /api/rotations endpoint to list all available rotations
      - Add POST /api/rotations/chat/completions endpoint for rotation chat completions
      - Model name in request now selects the specific rotation (coding, general, etc.)
      - Add GET /api/rotations/models endpoint to list all models across all rotations
      - Update root endpoint to show available rotations and autoselect options
      - Maintain backward compatibility with existing /api/{provider_id} endpoints
      9f5592c4
    • Stefy Lanza (nextime / spora )'s avatar
      Add comprehensive debug logging for provider state and autoselect model selection · 3ffc2bcf
      Stefy Lanza (nextime / spora ) authored
      Provider State Logging (providers.py):
      - Add detailed logging when provider failures are recorded
      - Show failure count and remaining failures before disable
      - Log provider disable events with cooldown period details
      - Log provider re-enable events after successful requests
      - Track and display previous failure counts
      
      Autoselect Model Selection Logging (handlers.py):
      - Add detailed logging for autoselect model selection process
      - Show available models and their descriptions
      - Display user prompt information and length
      - Log AI model selection request and response
      - Show model validation and fallback logic
      - Indicate whether selection was AI-selected or fallback
      - Add logging for both streaming and non-streaming requests
      - Display final model choice with selection method
      3ffc2bcf
    • Stefy Lanza (nextime / spora )'s avatar
      Add comprehensive debug logging for rotation model selection · 684dc1f0
      Stefy Lanza (nextime / spora ) authored
      - Add detailed logging for provider scanning process
      - Show which providers are skipped and why (rate limited/deactivated)
      - Display model details including weight, rate limit, and provider
      - Add priority-based selection visualization
      - Show sorted models by weight in descending order
      - Indicate whether selection was random or deterministic
      - Add clear section headers for different stages of selection
      - Provide final selection summary with all relevant details
      684dc1f0