Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ PORT=8000
MAX_TIMEOUT=600000

# CORS Configuration
CORS_ORIGINS=["*"]
CORS_ORIGINS=["*"]

# Rate Limiting Configuration
RATE_LIMIT_ENABLED=true
RATE_LIMIT_PER_MINUTE=30
RATE_LIMIT_CHAT_PER_MINUTE=10
RATE_LIMIT_DEBUG_PER_MINUTE=2
RATE_LIMIT_AUTH_PER_MINUTE=10
RATE_LIMIT_SESSION_PER_MINUTE=15
RATE_LIMIT_HEALTH_PER_MINUTE=30
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2025-07-06

### 🎉 Major Features

- **OpenAI Function Calling Support** - Full implementation of OpenAI's function calling format
- Complete compatibility with OpenAI's `tools` and `tool_choice` parameters
- Support for legacy `functions` and `function_call` format
- All 9 Claude tools available through OpenAI-compatible interface
- Tool response handling with proper `tool_calls` format
- GET /v1/tools endpoint to list available tools

### 🔧 Technical Improvements

- Added comprehensive tool mapping system (OpenAI names → Claude tools)
- Implemented tool execution handler with proper error handling
- Enhanced Swagger/OpenAPI documentation with tool schemas
- Added production-ready test suite for tool functionality
- Improved message handling for tool responses

### 📚 Documentation

- Updated README with complete function calling examples
- Added tool usage documentation with all three supported formats
- Created comprehensive examples in `examples/tools_example.py`
- Enhanced API documentation with tool-related endpoints

### 🧪 Testing

- Created extensive test suite for tool functionality
- Added actual execution demonstrations
- Implemented production readiness checks
- Verified all tool mappings and structures

## [1.0.0] - Previous Release

- Initial release with core OpenAI compatibility
- Session management and continuity
- Multi-provider authentication support
- Streaming and non-streaming responses
87 changes: 87 additions & 0 deletions MERGE_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Merge Summary: Security & Performance Improvements

## Successfully Merged from Upstream

### 1. **Security Enhancements** ✅
- **CVE Fix**: Updated `python-multipart` from 0.0.12 to 0.0.18 to resolve critical security vulnerabilities
- **Rate Limiting**: Implemented comprehensive rate limiting for all endpoints
- Chat completions: 10 requests/minute
- Debug endpoint: 2 requests/minute
- Auth status: 10 requests/minute
- Health check: 30 requests/minute
- Sessions: 15 requests/minute
- **API Key Verification**: Added authentication check to `/v1/models` endpoint

### 2. **New Features** ✅
- `rate_limiter.py`: Complete rate limiting implementation using SlowAPI
- Configurable via environment variables
- JSON error responses with retry-after headers
- Per-endpoint customizable limits

### 3. **Updated Dependencies** ✅
- `python-multipart`: ^0.0.12 → ^0.0.18 (security fix)
- `slowapi`: ^0.1.9 (new dependency for rate limiting)

## Your Existing Features Preserved

All your enhancements remain intact:
- ✅ OpenAI function calling support
- ✅ Swagger UI integration
- ✅ Enhanced session management
- ✅ Tool handler and registry
- ✅ Enhanced parameter validation

## Testing Recommendations

1. **Test Rate Limiting**:
```bash
# Test rate limit on chat endpoint
for i in {1..15}; do
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "claude-3-5-sonnet-20241022", "messages": [{"role": "user", "content": "Hi"}]}'
done
```

2. **Verify Function Calling Still Works**:
```bash
# Test with your existing function calling code
python test_tools.py
```

3. **Check Swagger UI**:
- Visit http://localhost:8000/docs
- Ensure all endpoints are documented

4. **Test Security**:
- Verify API key protection works if configured
- Check rate limiting responses return proper JSON

## Environment Variables

Add these to your `.env` file:
```bash
# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_CHAT_PER_MINUTE=10
RATE_LIMIT_DEBUG_PER_MINUTE=2
RATE_LIMIT_AUTH_PER_MINUTE=10
RATE_LIMIT_SESSION_PER_MINUTE=15
RATE_LIMIT_HEALTH_PER_MINUTE=30
```

## Next Steps

1. Install new dependencies:
```bash
pip install slowapi
```

2. Test the merged features thoroughly

3. Push to your branch:
```bash
git push origin merge-upstream-improvements
```

4. Create a pull request to review changes before merging to main/production
96 changes: 96 additions & 0 deletions MISSING_UPSTREAM_FEATURES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Missing Upstream Features & Improvements

## Features Not Yet Merged from Original Repository

### 1. **GitHub Actions Workflows** 🤖
The upstream has two GitHub Actions for automated code review:

- **`.github/workflows/claude-code-review.yml`**: Automated PR code reviews using Claude
- **`.github/workflows/claude.yml`**: Claude PR assistant workflow

These provide:
- Automatic code review on pull requests
- AI-powered suggestions and improvements
- Automated security checks

### 2. **Docker Improvements** 🐳
While you have your own Docker setup, the upstream has:

- **Standard `docker-compose.yml`**: Simpler compose file for basic deployment
- **Different Dockerfile approach**: Their Dockerfile might have optimizations

Your setup appears more advanced with:
- `docker-compose.dev.yml` for development
- `deploy-dev.sh` and `deploy-prod.sh` scripts
- Your own Dockerfile

### 3. **Startup Optimization** ⚡
Commit `8af376a`: Uses Claude 3.5 Haiku for faster/cheaper startup verification
```python
# In claude_cli.py - uses Haiku model for verification
model="claude-3-5-haiku-20241022" # Faster and cheaper
```

### 4. **Documentation Updates** 📚
Several README improvements for:
- Docker deployment instructions
- Performance optimization tips
- Updated examples using Haiku model

## Your Unique Features (Not in Upstream)

You have many features the upstream doesn't have:

1. **OpenAI Function Calling** ✅
2. **Swagger UI** (`openapi.yaml`) ✅
3. **Advanced Tool System** (`tool_handler.py`, `tools.py`) ✅
4. **Production Deployment Scripts** ✅
5. **Development Docker Compose** ✅
6. **Extensive Testing Suite** ✅
7. **Session Management Enhancements** ✅
8. **Parameter Validation System** ✅

## Recommendations

### Worth Cherry-Picking:
1. **Startup Optimization** - Easy win for faster startup:
```bash
git cherry-pick 8af376a
```

2. **GitHub Actions** - If you want automated PR reviews:
```bash
git checkout upstream/main -- .github/workflows/
```

### Already Have Better Versions:
- **Docker Setup**: Your setup with dev/prod scripts is more sophisticated
- **Documentation**: You have your own comprehensive docs

### Optional Considerations:
- Review their Dockerfile for any optimizations
- Check if their docker-compose.yml has useful environment variables

## Quick Command to Get GitHub Actions

If you want the automated code review features:

```bash
# Create .github directory and copy workflows
mkdir -p .github/workflows
git checkout upstream/main -- .github/workflows/claude-code-review.yml
git checkout upstream/main -- .github/workflows/claude.yml

# Commit the changes
git add .github/
git commit -m "Add Claude Code GitHub Actions for automated PR reviews"
```

## Summary

You're only missing:
1. GitHub Actions for automated reviews (optional)
2. Startup optimization using Haiku model (recommended)
3. Some documentation updates (low priority)

Your fork is actually MORE feature-rich than the upstream in most areas!
Loading