Commit 865238f7 authored by Your Name's avatar Your Name

Version 0.9.4 - Fix setup.py data_files and update documentation

- Fixed ImportError: count_messages_tokens missing by correcting setup.py data_files structure
- Split data_files into separate entries to preserve subdirectory structure (aisbf/, aisbf/providers/, aisbf/providers/kiro/, aisbf/auth/)
- Added 6 missing dashboard templates (user_index.html, user_providers.html, etc.)
- Removed install_requires from setup.py (dependencies managed via venv)
- Updated aisbf.sh to only install requirements on first venv creation
- Added Kiro-cli and Kilocode OAuth2 provider support documentation
- Removed duplicate entries in documentation (Token Usage Analytics, Claude OAuth2)
- Provider module refactoring documentation updates
- Version bumped to 0.9.4
parent 72969cb2
......@@ -62,9 +62,9 @@ aisbf/
│ ├── openai.py # OpenAIProviderHandler
│ ├── anthropic.py # AnthropicProviderHandler
│ ├── claude.py # ClaudeProviderHandler (OAuth2-based)
│ ├── kilo.py # KiloProviderHandler (OAuth2-based)
│ ├── kilo.py # KiloProviderHandler (OAuth2-based, supports Kilocode)
│ ├── ollama.py # OllamaProviderHandler
│ └── kiro/ # Kiro provider (subpackage)
│ └── kiro/ # Kiro provider (subpackage, supports kiro-cli)
│ ├── __init__.py
│ ├── handler.py
│ ├── converters.py
......@@ -74,7 +74,8 @@ aisbf/
│ └── utils.py
├── config/ # Configuration files directory
│ ├── providers.json # Default provider configurations
│ └── rotations.json # Default rotation configurations
│ ├── rotations.json # Default rotation configurations
│ └── autoselect.json # Default autoselect configurations
├── main.py # FastAPI application entry point
├── setup.py # Installation script with custom install logic
├── pyproject.toml # Modern packaging configuration for PyPI
......@@ -82,11 +83,13 @@ aisbf/
├── build.sh # Build script for PyPI packages
├── clean.sh # Clean script for build artifacts
├── start_proxy.sh # Development start script
├── aisbf.sh # Alternative start script
├── aisbf.sh # Production start script with venv support
├── requirements.txt # Python dependencies
├── PYPI.md # PyPI publishing guide
├── DOCUMENTATION.md # Complete API documentation
└── README.md # Project documentation
├── README.md # Project documentation
├── CHANGELOG.md # Version history
└── AI.PROMPT # AI-assisted development guidelines
```
## Module Structure
......@@ -96,7 +99,7 @@ Exports all main components:
- `config`, `Config`, `ProviderConfig`, `RotationConfig`, `AppConfig`
- `Message`, `ChatCompletionRequest`, `ChatCompletionResponse`, `Model`, `Provider`, `ErrorTracking`
- `BaseProviderHandler`, `GoogleProviderHandler`, `OpenAIProviderHandler`, `AnthropicProviderHandler`, `OllamaProviderHandler`, `get_provider_handler`, `PROVIDER_HANDLERS`
- `RequestHandler`, `RotationHandler`
- `RequestHandler`, `RotationHandler`, `AutoselectHandler`
### aisbf/config.py
Configuration management with smart file location detection:
......@@ -121,22 +124,23 @@ Provider handler implementations, split into individual modules:
- `google.py` - `GoogleProviderHandler` - Google GenAI integration
- `openai.py` - `OpenAIProviderHandler` - OpenAI API integration
- `anthropic.py` - `AnthropicProviderHandler` - Anthropic API key integration
- `claude.py` - `ClaudeProviderHandler` - Claude OAuth2 integration
- `kilo.py` - `KiloProviderHandler` - Kilo Gateway OAuth2 integration
- `claude.py` - `ClaudeProviderHandler` - Claude OAuth2 integration (fully working)
- `kilo.py` - `KiloProviderHandler` - Kilo OAuth2/Device Authorization Grant integration
- `ollama.py` - `OllamaProviderHandler` - Ollama local integration
- `kiro/` - `KiroProviderHandler` - Kiro/Amazon Q Developer integration (subpackage)
- `kiro/` - `KiroProviderHandler` - Kiro/Amazon Q Developer integration (subpackage, supports kiro-cli)
- `__init__.py` - Re-exports all handlers, `PROVIDER_HANDLERS` dict, `get_provider_handler()` factory
### aisbf/auth/ (package)
Authentication modules:
- `kiro.py` - `KiroAuthManager` for Kiro/Amazon Q Developer auth
- `claude.py` - `ClaudeAuth` for Claude OAuth2 PKCE flow (was `aisbf/claude_auth.py`)
- `kilo.py` - `KiloOAuth2` for Kilo Device Authorization Grant (was `aisbf/kilo_oauth2.py`)
- `claude.py` - `ClaudeAuth` for Claude OAuth2 PKCE flow (fully working with token refresh)
- `kilo.py` - `KiloOAuth2` for Kilo Device Authorization Grant (Kilocode support)
### aisbf/handlers.py
Request handling logic:
- `RequestHandler` - Handles chat completions and model lists
- `RotationHandler` - Handles provider rotation
- `AutoselectHandler` - Handles AI-powered model selection
- Supports both streaming and non-streaming responses
### main.py
......@@ -147,6 +151,7 @@ FastAPI application:
- `POST /api/{provider_id}/chat/completions` - Chat completions
- `GET /api/{provider_id}/models` - List models
- Supports both providers and rotations
- Multi-user support with user-specific API endpoints
- CORS enabled for all origins
## Installation Process
......@@ -162,11 +167,13 @@ python setup.py install
```
Automatically adds `--user` flag for non-root users.
Installs to:
- `~/.local/lib/python*/site-packages/aisbf/` - Package
- `~/.local/aisbf-venv/` - Virtual environment
- `~/.local/share/aisbf/` - Config files and main.py
- `~/.local/bin/aisbf` - Executable script
**Installation Structure:**
- Package files installed to: `~/.local/share/aisbf/aisbf/` (preserves subdirectory structure)
- Config files and main.py: `~/.local/share/aisbf/`
- Virtual environment: `~/.local/share/aisbf/venv/`
- Requirements installed only on first venv creation
**Note:** Dependencies from requirements.txt are only installed when creating the virtual environment for the first time. Subsequent starts do not re-run pip install to avoid unnecessary upgrades. The venv is only recreated if it doesn't exist.
### System-wide Installation from Source (requires root)
```bash
......@@ -731,6 +738,19 @@ This AI.PROMPT file is automatically updated when significant changes are made t
### Recent Updates
**2026-04-03 - Version 0.9.4 - Setup.py Fixes and Documentation Updates**
- Fixed setup.py data_files structure to preserve subdirectory structure during installation
- Split data_files into separate entries for each subpackage (aisbf/, aisbf/providers/, aisbf/providers/kiro/, aisbf/auth/)
- Added 6 missing dashboard templates to setup.py (user_index.html, user_providers.html, etc.)
- Removed install_requires from setup.py since pypy creates a virtualenv with its own dependencies
- Updated aisbf.sh to only install requirements on first venv creation
- Provider module refactoring: Split monolithic providers into individual files
- Added Kiro-cli provider support, enhanced Claude Code OAuth2, and Kilocode OAuth2 support
- Updated README.md with Kiro-cli and Kilocode configuration examples
- Removed duplicate entries in documentation (Token Usage Analytics, Claude OAuth2)
- Updated CHANGELOG.md with all new features and fixes
- Version bumped to 0.9.4
**2026-04-03 - Provider Module Refactoring (Phase 2)**
- Split monolithic `aisbf/providers/__init__.py` (301K chars) into individual module files
- Created `aisbf/providers/base.py` with shared utilities: `BaseProviderHandler`, `AnthropicFormatConverter`, `AdaptiveRateLimiter`, `AISBF_DEBUG`
......
......@@ -7,7 +7,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.9.2] - 2026-04-03
## [0.9.4] - 2026-04-03
### Added
- **Provider Module Refactoring (Phase 2)**: Split monolithic providers module into individual files for better maintainability
- Created aisbf/providers/base.py with shared utilities (BaseProviderHandler, AnthropicFormatConverter, AdaptiveRateLimiter)
- Created individual handler files: google.py, openai.py, anthropic.py, claude.py, kilo.py, ollama.py
- Moved auth modules to aisbf/auth/ subpackage (claude.py, kilo.py, kiro.py)
- Created kiro subpackage with handler, converters, models, parsers, utils
- All existing imports continue to work (backward compatible)
- **Kiro-cli Provider Support**: Full support for Kiro (Amazon Q Developer) CLI authentication
- Device Authorization Grant flow matching official kiro-cli
- SQLite database-based credential storage
- Dashboard integration with authentication UI
- **Claude Code (OAuth2) Enhancements**: Fully working OAuth2 PKCE authentication
- Automatic token refresh with refresh token rotation
- Chrome extension for remote server callback interception
- Proxy-aware extension serving for reverse proxy deployments
- Support for nginx, caddy, and other reverse proxies
- **Kilocode OAuth2 Support**: OAuth2 Device Authorization Grant for Kilo Code
- Automatic token refresh
- Dashboard integration with authentication UI
- **Multi-User Dashboard Templates**: Added missing dashboard templates for user management
- user_index.html, user_providers.html, user_rotations.html
- user_autoselects.html, user_tokens.html, rate_limits.html
### Fixed
- **Setup.py Data Files Structure**: Fixed incorrect file path handling in data_files that caused files to be installed flat instead of preserving subdirectory structure
- Split data_files into separate entries for each subpackage (aisbf/, aisbf/providers/, aisbf/providers/kiro/, aisbf/auth/)
- Properly preserves module structure during installation
- **Missing Template Files**: Added 6 missing dashboard templates to setup.py data_files
- **Virtual Environment Dependencies**: Removed install_requires from setup.py since pypy creates a virtualenv with its own dependencies
- **aisbf.sh Update Logic**: Removed automatic update_venv calls from start_server() and start_daemon() functions
- **Documentation Duplicates**: Removed duplicate entries for Token Usage Analytics and Claude OAuth2 in documentation
### Changed
- **Version Bump**: Updated version to 0.9.4 in setup.py and pyproject.toml
## [0.9.3] - 2026-04-03
- **Setup.py Data Files Structure**: Fixed incorrect file path handling in data_files that caused files to be installed flat instead of preserving subdirectory structure
- Split data_files into separate entries for each subpackage (aisbf/, aisbf/providers/, aisbf/providers/kiro/, aisbf/auth/)
- Properly preserves module structure during installation
- **Missing Template Files**: Added 6 missing dashboard templates to setup.py data_files
- user_index.html, user_providers.html, user_rotations.html, user_autoselects.html, user_tokens.html, rate_limits.html
- **Virtual Environment Dependencies**: Removed install_requires from setup.py since pypy creates a virtualenv with its own dependencies
- **aisbf.sh Update Logic**: Removed automatic update_venv calls from start_server() and start_daemon() functions
- Dependencies from requirements.txt now only installed when creating venv for the first time
- Existing venv remains unchanged unless explicitly upgraded
### Changed
- **Version Bump**: Updated version to 0.9.3 in setup.py and pyproject.toml
### Added
- **User-Specific API Endpoints**: New API endpoints for authenticated users to access their own configurations
......
......@@ -6,8 +6,10 @@ AISBF is a modular proxy server for managing multiple AI provider integrations.
### Key Features
- **Multi-Provider Support**: Unified interface for Google, OpenAI, Anthropic, Claude Code (OAuth2), Ollama, and Kiro (Amazon Q Developer)
- **Multi-Provider Support**: Unified interface for Google, OpenAI, Anthropic, Claude Code (OAuth2), Ollama, Kiro (Amazon Q Developer), Kiro-cli, and Kilocode (OAuth2)
- **Claude OAuth2 Authentication**: Full OAuth2 PKCE flow for Claude Code with automatic token refresh, Chrome extension for remote servers, and curl_cffi TLS fingerprinting support
- **Kiro-cli Support**: Full support for Amazon Q Developer CLI authentication with Device Authorization Grant
- **Kilocode OAuth2 Authentication**: OAuth2 Device Authorization Grant for Kilo Code with automatic token refresh
- **Rotation Models**: Intelligent load balancing across multiple providers with weighted model selection and automatic failover
- **Autoselect Models**: AI-powered model selection that analyzes request content to route to the most appropriate specialized model
- **Streaming Support**: Full support for streaming responses from all providers with proper serialization
......@@ -17,8 +19,7 @@ AISBF is a modular proxy server for managing multiple AI provider integrations.
- **Persistent Database**: SQLite-based tracking of token usage, context dimensions, and model embeddings with automatic cleanup
- **Multi-User Support**: User management with isolated configurations, role-based access control, and API token management
- **Security**: Default localhost-only access for improved security
- **Token Usage Analytics**: Comprehensive analytics dashboard with token usage tracking, cost estimation, model performance comparison, and optimization recommendations
- **Token Usage Analytics**: Comprehensive analytics dashboard for tracking token usage, costs, and performance with charts and export functionality
- **Token Usage Analytics**: Comprehensive analytics dashboard with token usage tracking, cost estimation, model performance comparison, and export functionality
## Author
......
......@@ -24,8 +24,9 @@ Access the dashboard at `http://localhost:17765/dashboard` (default credentials:
## Key Features
- **Multi-Provider Support**: Unified interface for Google, OpenAI, Anthropic, Ollama, Kiro (Amazon Q Developer), and Claude Code (OAuth2)
- **Multi-Provider Support**: Unified interface for Google, OpenAI, Anthropic, Ollama, Kiro (Amazon Q Developer), Kiro-cli, Claude Code (OAuth2), and Kilocode (OAuth2)
- **Claude OAuth2 Authentication**: Full OAuth2 PKCE flow for Claude Code with automatic token refresh and Chrome extension for remote servers
- **Kilocode OAuth2 Authentication**: OAuth2 Device Authorization Grant for Kilo Code with automatic token refresh
- **Rotation Models**: Weighted load balancing across multiple providers with automatic failover
- **Autoselect Models**: AI-powered model selection based on content analysis and request characteristics
- **Semantic Classification**: Fast hybrid BM25 + semantic model selection using sentence transformers (optional)
......@@ -131,7 +132,92 @@ See [`PYPI.md`](PYPI.md) for detailed instructions on publishing to PyPI.
- Claude Code (OAuth2 authentication via claude.ai)
- Ollama (direct HTTP)
- Kiro (Amazon Q Developer / AWS CodeWhisperer)
- Kiro-cli (Amazon Q Developer CLI authentication)
- Kilocode (OAuth2 Device Authorization Grant)
### Kiro-cli Provider Support
AISBF supports Kiro (Amazon Q Developer) via kiro-cli authentication using Device Authorization Grant flow:
#### Features
- Full OAuth2 Device Authorization Grant flow matching official kiro-cli
- Automatic token refresh
- SQLite database-based credential storage
- Dashboard integration with authentication UI
- Credentials stored in user-configured SQLite database path
#### Setup
1. Add kiro-cli provider to configuration (via dashboard or `~/.aisbf/providers.json`)
2. Configure sqlite_db path pointing to kiro-cli credentials database
3. Use kiro-cli models via API: `kiro-cli/anthropic.claude-3-5-sonnet-20241022-v2:0`
#### Configuration Example
```json
{
"providers": {
"kiro-cli": {
"id": "kiro-cli",
"name": "Kiro-cli (Amazon Q Developer)",
"endpoint": "https://q.us-east-1.amazonaws.com",
"type": "kiro",
"api_key_required": false,
"kiro_config": {
"region": "us-east-1",
"sqlite_db": "~/.config/kiro/kiro.db"
},
"models": [
{
"name": "anthropic.claude-3-5-sonnet-20241022-v2:0",
"context_size": 200000
}
]
}
}
}
```
### Kilocode OAuth2 Authentication
AISBF supports Kilo Code as a provider using OAuth2 Device Authorization Grant:
#### Features
- Full OAuth2 Device Authorization Grant flow
- Automatic token refresh with refresh token rotation
- Dashboard integration with authentication UI
- Proxy-aware callback handling
- Credentials stored in `~/.aisbf/kilo_credentials.json`
#### Setup
1. Add kilocode provider to configuration (via dashboard or `~/.aisbf/providers.json`)
2. Click "Authenticate with Kilo" in dashboard
3. Complete device authorization flow
4. Use kilocode models via API: `kilocode/<model>`
#### Configuration Example
```json
{
"providers": {
"kilocode": {
"id": "kilocode",
"name": "Kilo Code (OAuth2)",
"endpoint": "https://api.kilo.dev/v1",
"type": "kilo",
"api_key_required": false,
"kilo_config": {
"credentials_file": "~/.aisbf/kilo_credentials.json"
},
"models": [
{
"name": "kilo/free",
"context_size": 100000
}
]
}
}
}
```
See [`KILO_OAUTH2.md`](KILO_OAUTH2.md) for detailed setup instructions.
## Configuration
### SSL/TLS Configuration
......
......@@ -140,9 +140,6 @@ start_server() {
# Ensure venv exists
ensure_venv
# Update venv packages silently
update_venv
# Get port from config
PORT=$(get_port)
......@@ -186,9 +183,6 @@ start_daemon() {
# Ensure venv exists
ensure_venv
# Update venv packages silently
update_venv
# Get port from config
PORT=$(get_port)
......
......@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "aisbf"
version = "0.9.2"
version = "0.9.4"
description = "AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations"
readme = "README.md"
license = "GPL-3.0-or-later"
......
......@@ -49,7 +49,7 @@ class InstallCommand(_install):
setup(
name="aisbf",
version="0.9.1",
version="0.9.4",
author="AISBF Contributors",
author_email="stefy@nexlab.net",
description="AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations",
......@@ -71,7 +71,8 @@ setup(
"Operating System :: OS Independent",
],
python_requires=">=3.8",
install_requires=requirements,
# Dependencies are installed separately via requirements.txt (e.g., in virtualenv)
# install_requires=requirements,
include_package_data=True,
package_data={
"aisbf": ["*.json"],
......@@ -94,10 +95,25 @@ setup(
'config/aisbf.json',
]),
# Install aisbf package to share directory for venv installation
# Main aisbf module files
('share/aisbf/aisbf', [
'aisbf/__init__.py',
'aisbf/config.py',
'aisbf/models.py',
'aisbf/handlers.py',
'aisbf/context.py',
'aisbf/utils.py',
'aisbf/database.py',
'aisbf/mcp.py',
'aisbf/tor.py',
'aisbf/batching.py',
'aisbf/cache.py',
'aisbf/classifier.py',
'aisbf/streaming_optimization.py',
'aisbf/analytics.py',
]),
# aisbf.providers subpackage
('share/aisbf/aisbf/providers', [
'aisbf/providers/__init__.py',
'aisbf/providers/base.py',
'aisbf/providers/google.py',
......@@ -106,16 +122,9 @@ setup(
'aisbf/providers/claude.py',
'aisbf/providers/kilo.py',
'aisbf/providers/ollama.py',
'aisbf/handlers.py',
'aisbf/context.py',
'aisbf/utils.py',
'aisbf/database.py',
'aisbf/mcp.py',
'aisbf/tor.py',
'aisbf/auth/__init__.py',
'aisbf/auth/kiro.py',
'aisbf/auth/claude.py',
'aisbf/auth/kilo.py',
]),
# aisbf.providers.kiro subpackage
('share/aisbf/aisbf/providers/kiro', [
'aisbf/providers/kiro/__init__.py',
'aisbf/providers/kiro/handler.py',
'aisbf/providers/kiro/converters.py',
......@@ -123,11 +132,13 @@ setup(
'aisbf/providers/kiro/models.py',
'aisbf/providers/kiro/parsers.py',
'aisbf/providers/kiro/utils.py',
'aisbf/batching.py',
'aisbf/cache.py',
'aisbf/classifier.py',
'aisbf/streaming_optimization.py',
'aisbf/analytics.py',
]),
# aisbf.auth subpackage
('share/aisbf/aisbf/auth', [
'aisbf/auth/__init__.py',
'aisbf/auth/kiro.py',
'aisbf/auth/claude.py',
'aisbf/auth/kilo.py',
]),
# Install dashboard templates
('share/aisbf/templates', [
......@@ -144,6 +155,12 @@ setup(
'templates/dashboard/prompts.html',
'templates/dashboard/docs.html',
'templates/dashboard/analytics.html',
'templates/dashboard/user_index.html',
'templates/dashboard/user_providers.html',
'templates/dashboard/user_rotations.html',
'templates/dashboard/user_autoselects.html',
'templates/dashboard/user_tokens.html',
'templates/dashboard/rate_limits.html',
]),
],
entry_points={
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment