Skip to content

feat: add version headers and feedback API#19

Merged
oscarvalenzuelab merged 3 commits into
mainfrom
feat/version-headers-and-feedback
Apr 8, 2026
Merged

feat: add version headers and feedback API#19
oscarvalenzuelab merged 3 commits into
mainfrom
feat/version-headers-and-feedback

Conversation

@oscarvalenzuelab
Copy link
Copy Markdown
Contributor

Summary

  • Add X-SDK-Version and X-SDK-Type headers to all requests for cloud telemetry
  • Add feedback() and feedback_async() methods for reporting false positives or confirming detections
  • Fix Retry-After header parsing to handle both integer seconds and HTTP-date format
  • Fix async client resource leak in close() when no event loop is running
  • Add FeedbackResult model and export __version__

Changes

File Description
_version.py New file to hold version string (avoids circular imports)
client.py Add version headers, feedback methods, fix retry-after and async cleanup
models.py Add FeedbackResult dataclass
__init__.py Export FeedbackResult and __version__

Usage

from aiproxyguard import AIProxyGuard

client = AIProxyGuard("https://aiproxyguard.com", api_key="apg_xxx", api_mode="cloud")

# Check and get ID
result = client.check_cloud("suspicious text")
if result.is_blocked:
    # Report false positive
    client.feedback(result.id, "false_positive", comment="This was a normal question")

Test plan

  • All 120 tests pass
  • Coverage at 91%
  • Linting passes (ruff)

- Add X-SDK-Version and X-SDK-Type headers to all requests
- Add feedback() and feedback_async() methods for reporting false positives
- Fix Retry-After header parsing to handle HTTP-date format
- Fix async client leak in close() when no event loop is running
- Add FeedbackResult model

This enables the cloud to track SDK versions and allows users to submit
feedback on detection results to improve accuracy.
@cla-bot cla-bot Bot added the cla-signed label Apr 8, 2026
The async client cleanup was checking the private `_closed` attribute
which doesn't exist on httpx.AsyncClient. This caused the guard to
always return True, skipping cleanup and leaking connections.

Use the public `is_closed` property instead.
@oscarvalenzuelab oscarvalenzuelab merged commit 4468ce2 into main Apr 8, 2026
8 checks passed
@oscarvalenzuelab oscarvalenzuelab deleted the feat/version-headers-and-feedback branch April 8, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant