Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ max-elif-branches=5

[FORMAT]
# Maximum number of characters on a single line.
max-line-length=100
max-line-length=88

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
Expand Down
8 changes: 4 additions & 4 deletions src/security/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ async def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(s
# Check Authorization scheme
if not credentials or credentials.scheme.lower() != "bearer":
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid authentication scheme. Expected 'Bearer'",
headers={"WWW-Authenticate": "Bearer"},
)

credentials_exception = HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
status_code=status.HTTP_403_FORBIDDEN,
detail="Could not validate credentials",
headers={"WWW-Authenticate": "Bearer"},
)
Expand All @@ -55,7 +55,7 @@ async def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(s
except JWTError as jwt_error:
# Preserve original JWT error details for debugging
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
status_code=status.HTTP_403_FORBIDDEN,
detail=f"JWT validation failed: {str(jwt_error)}",
headers={"WWW-Authenticate": "Bearer"},
) from jwt_error
Expand Down
2 changes: 1 addition & 1 deletion src/unified_ai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ async def refresh_token(request: RefreshTokenRequest) -> TokenResponse:
payload = jwt_manager.verify_token(request.refresh_token)
if not payload or payload.type != "refresh":
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid refresh token"
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_api_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_endpoint_consistency(self):
# Test all endpoints
endpoints = [
('/api/analyze/journal', {'text': 'I feel happy today.', 'generate_summary': True}),
('/api/summarize/', {'text': 'This is a long text for testing.', 'max_length': 50}),
('/api/summarize/', {'text': 'This is a longer text for testing that intentionally exceeds fifty characters to satisfy validation.', 'max_length': 50}),
('/api/transcribe/', {'audio_data': self.mock_audio_data, 'language': 'en'}),
('/api/complete-analysis/', {'text': 'I feel happy today.', 'include_summary': True, 'include_emotion': True})
]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_model_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_model_loading_consistency(self):
# Test all endpoints to trigger model loading
endpoints = [
('/api/analyze/journal', {'text': 'I feel happy today.', 'generate_summary': True}),
('/api/summarize/', {'text': 'This is a long text for testing.', 'max_length': 50}),
('/api/summarize/', {'text': 'This is a longer text for testing that intentionally exceeds fifty characters to satisfy validation.', 'max_length': 50}),
('/api/transcribe/', {'audio_data': self.mock_audio_data, 'language': 'en'}),
('/api/complete-analysis/', {'text': 'I feel happy today.', 'include_summary': True, 'include_emotion': True})
]
Expand All @@ -122,7 +122,7 @@ def test_model_error_handling(self):
# Test that endpoints handle model loading failures gracefully
endpoints = [
('/api/analyze/journal', {'text': 'I feel happy today.', 'generate_summary': True}),
('/api/summarize/', {'text': 'This is a long text for testing.', 'max_length': 50}),
('/api/summarize/', {'text': 'This is a longer text for testing that intentionally exceeds fifty characters to satisfy validation.', 'max_length': 50}),
('/api/transcribe/', {'audio_data': self.mock_audio_data, 'language': 'en'}),
('/api/complete-analysis/', {'text': 'I feel happy today.', 'include_summary': True, 'include_emotion': True})
]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_summarize_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_summarize_short_text(self):
def test_summarize_invalid_parameters(self):
"""Test summarization with invalid parameters."""
response = self.client.post('/api/summarize/',
json={'text': 'This is a long text for testing.',
json={'text': 'This is a longer text for testing that intentionally exceeds fifty characters to satisfy validation.',
'max_length': 10, 'min_length': 20})
self.assertEqual(response.status_code, 400)
data = json.loads(response.data)
Expand All @@ -61,7 +61,7 @@ def test_summarize_invalid_parameters(self):
def test_summarize_invalid_temperature(self):
"""Test summarization with invalid temperature."""
response = self.client.post('/api/summarize/',
json={'text': 'This is a long text for testing.',
json={'text': 'This is a longer text for testing that intentionally exceeds fifty characters to satisfy validation.',
'temperature': 3.0})
self.assertEqual(response.status_code, 400)
data = json.loads(response.data)
Expand Down