Initial commit: FastGPT Python SDK Phase 1
Implement core infrastructure: - BaseClientMixin with retry logic and validation - FastGPTClient base class with httpx - ChatClient with 11 chat operation methods - AppClient for analytics and logs - Custom exceptions (APIError, AuthenticationError, etc.) - Package configuration (pyproject.toml, setup.py) - Documentation (README.md, CLAUDE.md) - Basic usage examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
43
fastgpt_client/exceptions.py
Normal file
43
fastgpt_client/exceptions.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""FastGPT Client Exceptions."""
|
||||
|
||||
|
||||
class FastGPTError(Exception):
|
||||
"""Base exception for all FastGPT errors."""
|
||||
|
||||
def __init__(self, message: str, status_code: int = None, response_data: dict = None):
|
||||
self.message = message
|
||||
self.status_code = status_code
|
||||
self.response_data = response_data or {}
|
||||
super().__init__(self.message)
|
||||
|
||||
|
||||
class APIError(FastGPTError):
|
||||
"""General API error (4xx, 5xx responses)."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class AuthenticationError(FastGPTError):
|
||||
"""Authentication failed (401)."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class RateLimitError(FastGPTError):
|
||||
"""Rate limit exceeded (429)."""
|
||||
|
||||
def __init__(self, message: str, retry_after: str = None, status_code: int = None, response_data: dict = None):
|
||||
super().__init__(message, status_code, response_data)
|
||||
self.retry_after = retry_after
|
||||
|
||||
|
||||
class ValidationError(FastGPTError):
|
||||
"""Invalid request parameters (422)."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class StreamParseError(FastGPTError):
|
||||
"""Error parsing streaming response."""
|
||||
|
||||
pass
|
||||
Reference in New Issue
Block a user