aiproxyguard-python-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. aiproxyguard_python_sdk-0.1.0/.clabot +9 -0
  2. aiproxyguard_python_sdk-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +45 -0
  3. aiproxyguard_python_sdk-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +41 -0
  4. aiproxyguard_python_sdk-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +49 -0
  5. aiproxyguard_python_sdk-0.1.0/.github/dependabot.yml +13 -0
  6. aiproxyguard_python_sdk-0.1.0/.github/workflows/ci.yml +43 -0
  7. aiproxyguard_python_sdk-0.1.0/.github/workflows/cla-auto-sign.yml +58 -0
  8. aiproxyguard_python_sdk-0.1.0/.github/workflows/publish.yml +130 -0
  9. aiproxyguard_python_sdk-0.1.0/.gitignore +77 -0
  10. aiproxyguard_python_sdk-0.1.0/CHANGELOG.md +30 -0
  11. aiproxyguard_python_sdk-0.1.0/CODE_OF_CONDUCT.md +81 -0
  12. aiproxyguard_python_sdk-0.1.0/CONTRIBUTING.md +217 -0
  13. aiproxyguard_python_sdk-0.1.0/LICENSE +201 -0
  14. aiproxyguard_python_sdk-0.1.0/PKG-INFO +384 -0
  15. aiproxyguard_python_sdk-0.1.0/README.md +348 -0
  16. aiproxyguard_python_sdk-0.1.0/SECURITY.md +76 -0
  17. aiproxyguard_python_sdk-0.1.0/pyproject.toml +76 -0
  18. aiproxyguard_python_sdk-0.1.0/src/aiproxyguard/__init__.py +58 -0
  19. aiproxyguard_python_sdk-0.1.0/src/aiproxyguard/client.py +619 -0
  20. aiproxyguard_python_sdk-0.1.0/src/aiproxyguard/decorators.py +245 -0
  21. aiproxyguard_python_sdk-0.1.0/src/aiproxyguard/exceptions.py +76 -0
  22. aiproxyguard_python_sdk-0.1.0/src/aiproxyguard/models.py +222 -0
  23. aiproxyguard_python_sdk-0.1.0/src/aiproxyguard/py.typed +0 -0
  24. aiproxyguard_python_sdk-0.1.0/tests/__init__.py +1 -0
  25. aiproxyguard_python_sdk-0.1.0/tests/conftest.py +88 -0
  26. aiproxyguard_python_sdk-0.1.0/tests/test_client.py +1019 -0
  27. aiproxyguard_python_sdk-0.1.0/tests/test_models.py +307 -0
@@ -0,0 +1,9 @@
1
+ {
2
+ "message": "Thank you for your contribution! Before we can review and merge your pull request, we need you to sign our Contributor License Agreement (CLA).\n\n**To sign the CLA:**\n\n1. Review the agreement below\n2. Reply to this PR with the following statement:\n\n> I have read the Contributor License Agreement and I hereby accept the terms.\n\n**Contributor License Agreement (Summary)**\n\nBy signing this CLA, you certify that:\n\n- You created the contribution or have the right to submit it under the Apache 2.0 license\n- You grant AInvirion and recipients of this software a perpetual, worldwide, non-exclusive, royalty-free license to use, reproduce, modify, and distribute your contribution\n- You understand that your contribution is public and may be redistributed under the Apache 2.0 license\n- You have the legal right to make this grant (if employed, your employer has waived rights or you are contributing outside the scope of employment)\n- You agree to notify us if you become aware of any facts that would make these representations inaccurate\n\nThis agreement is based on the Apache Software Foundation CLA. Your contribution will remain publicly available under the Apache 2.0 license.\n\nOnce you post your acceptance, we'll review your contribution. Thank you!\n\n---\n\nQuestions? Contact legal@ainvirion.com",
3
+ "label": "cla-signed",
4
+ "recheckComment": "recheck",
5
+ "contributors": [
6
+ "oscarvalenzuelab",
7
+ "cla-bot[bot]"
8
+ ]
9
+ }
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: Bug Report
3
+ about: Create a report to help us improve
4
+ title: '[BUG] '
5
+ labels: 'bug'
6
+ assignees: ''
7
+ ---
8
+
9
+ ## Bug Description
10
+
11
+ A clear and concise description of what the bug is.
12
+
13
+ ## Steps to Reproduce
14
+
15
+ 1. Go to '...'
16
+ 2. Click on '...'
17
+ 3. Scroll down to '...'
18
+ 4. See error
19
+
20
+ ## Expected Behavior
21
+
22
+ A clear and concise description of what you expected to happen.
23
+
24
+ ## Actual Behavior
25
+
26
+ A clear and concise description of what actually happened.
27
+
28
+ ## Screenshots
29
+
30
+ If applicable, add screenshots to help explain your problem.
31
+
32
+ ## Environment
33
+
34
+ - **OS**: [e.g., macOS 13.0, Windows 11, Ubuntu 22.04]
35
+ - **Browser**: [e.g., Chrome 119, Firefox 120, Safari 17] (if applicable)
36
+ - **Version**: [e.g., 1.2.3]
37
+ - **Node Version**: [e.g., 18.17.0] (if applicable)
38
+
39
+ ## Additional Context
40
+
41
+ Add any other context about the problem here.
42
+
43
+ ## Possible Solution
44
+
45
+ If you have suggestions on how to fix the bug, please describe them here.
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: Feature Request
3
+ about: Suggest an idea for this project
4
+ title: '[FEATURE] '
5
+ labels: 'enhancement'
6
+ assignees: ''
7
+ ---
8
+
9
+ ## Feature Description
10
+
11
+ A clear and concise description of the feature you'd like to see.
12
+
13
+ ## Problem Statement
14
+
15
+ Describe the problem this feature would solve. Ex. I'm always frustrated when [...]
16
+
17
+ ## Proposed Solution
18
+
19
+ A clear and concise description of what you want to happen.
20
+
21
+ ## Alternatives Considered
22
+
23
+ Describe any alternative solutions or features you've considered.
24
+
25
+ ## Use Case
26
+
27
+ Describe the use case(s) for this feature. Who would benefit from it and how?
28
+
29
+ ## Additional Context
30
+
31
+ Add any other context, screenshots, or examples about the feature request here.
32
+
33
+ ## Implementation Ideas
34
+
35
+ If you have ideas about how this could be implemented, please share them here.
36
+
37
+ ## Willingness to Contribute
38
+
39
+ - [ ] I am willing to help implement this feature
40
+ - [ ] I can help with documentation
41
+ - [ ] I can help with testing
@@ -0,0 +1,49 @@
1
+ # Description
2
+
3
+ Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
4
+
5
+ Fixes # (issue)
6
+
7
+ ## Type of Change
8
+
9
+ Please delete options that are not relevant.
10
+
11
+ - [ ] Bug fix (non-breaking change which fixes an issue)
12
+ - [ ] New feature (non-breaking change which adds functionality)
13
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14
+ - [ ] Documentation update
15
+ - [ ] Performance improvement
16
+ - [ ] Code refactoring
17
+ - [ ] Dependency update
18
+
19
+ ## How Has This Been Tested?
20
+
21
+ Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
22
+
23
+ - [ ] Test A
24
+ - [ ] Test B
25
+
26
+ **Test Configuration**:
27
+ - OS:
28
+ - Node version:
29
+ - Other relevant details:
30
+
31
+ ## Checklist
32
+
33
+ - [ ] My code follows the style guidelines of this project
34
+ - [ ] I have performed a self-review of my own code
35
+ - [ ] I have commented my code, particularly in hard-to-understand areas
36
+ - [ ] I have made corresponding changes to the documentation
37
+ - [ ] My changes generate no new warnings
38
+ - [ ] I have added tests that prove my fix is effective or that my feature works
39
+ - [ ] New and existing unit tests pass locally with my changes
40
+ - [ ] Any dependent changes have been merged and published
41
+ - [ ] I have updated the CHANGELOG.md
42
+
43
+ ## Screenshots (if applicable)
44
+
45
+ Add screenshots to help explain your changes.
46
+
47
+ ## Additional Notes
48
+
49
+ Add any additional notes or context about the pull request here.
@@ -0,0 +1,13 @@
1
+ version: 2
2
+ updates:
3
+ # Enable version updates for GitHub Actions
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ day: "monday"
9
+ labels:
10
+ - "dependencies"
11
+ - "github-actions"
12
+ commit-message:
13
+ prefix: "ci"
@@ -0,0 +1,43 @@
1
+ name: Template Validation
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ validate:
11
+ name: Validate Template Files
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v6
17
+
18
+ - name: Check required files exist
19
+ run: |
20
+ test -f LICENSE
21
+ test -f README.md
22
+ test -f CONTRIBUTING.md
23
+ test -f SECURITY.md
24
+ test -f CODE_OF_CONDUCT.md
25
+ test -f .clabot
26
+ echo "All required template files present"
27
+
28
+ - name: Validate markdown files
29
+ uses: DavidAnson/markdownlint-cli2-action@v23
30
+ with:
31
+ globs: '**/*.md'
32
+ config: |
33
+ {
34
+ "default": true,
35
+ "MD013": false,
36
+ "MD033": false,
37
+ "MD041": false
38
+ }
39
+ continue-on-error: true
40
+
41
+ - name: Check for placeholder text
42
+ run: |
43
+ echo "Note: Remember to replace [Project Name] and other placeholders when using this template"
@@ -0,0 +1,58 @@
1
+ name: CLA Auto Sign
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+
7
+ jobs:
8
+ auto-sign:
9
+ if: github.event.issue.pull_request && contains(github.event.comment.body, 'I have read the Contributor License Agreement and I hereby accept the terms')
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ pull-requests: write
14
+
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v6
18
+ with:
19
+ token: ${{ secrets.GITHUB_TOKEN }}
20
+
21
+ - name: Add contributor to CLA whitelist
22
+ id: add-contributor
23
+ env:
24
+ CONTRIBUTOR: ${{ github.event.comment.user.login }}
25
+ run: |
26
+ if jq -e --arg user "$CONTRIBUTOR" '.contributors | index($user)' .clabot > /dev/null 2>&1; then
27
+ echo "already_signed=true" >> $GITHUB_OUTPUT
28
+ else
29
+ jq --arg user "$CONTRIBUTOR" '.contributors += [$user]' .clabot > .clabot.tmp
30
+ mv .clabot.tmp .clabot
31
+ echo "already_signed=false" >> $GITHUB_OUTPUT
32
+ fi
33
+
34
+ - name: Commit and push changes
35
+ if: steps.add-contributor.outputs.already_signed == 'false'
36
+ env:
37
+ CONTRIBUTOR: ${{ github.event.comment.user.login }}
38
+ run: |
39
+ git config user.name "github-actions[bot]"
40
+ git config user.email "github-actions[bot]@users.noreply.github.com"
41
+ git add .clabot
42
+ git commit -m "chore: add $CONTRIBUTOR to CLA contributors [skip ci]"
43
+ git push
44
+
45
+ - name: Trigger CLA recheck
46
+ if: steps.add-contributor.outputs.already_signed == 'false'
47
+ uses: actions/github-script@v8
48
+ env:
49
+ CONTRIBUTOR: ${{ github.event.comment.user.login }}
50
+ with:
51
+ script: |
52
+ const contributor = process.env.CONTRIBUTOR;
53
+ await github.rest.issues.createComment({
54
+ owner: context.repo.owner,
55
+ repo: context.repo.repo,
56
+ issue_number: context.issue.number,
57
+ body: 'Thanks @' + contributor + '! Your CLA signature has been recorded.\n\n@cla-bot check'
58
+ });
@@ -0,0 +1,130 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ # Allow manual trigger for testing
7
+ workflow_dispatch:
8
+ inputs:
9
+ target:
10
+ description: 'Target repository'
11
+ required: true
12
+ default: 'testpypi'
13
+ type: choice
14
+ options:
15
+ - testpypi
16
+ - pypi
17
+
18
+ jobs:
19
+ test:
20
+ name: Run Tests
21
+ runs-on: ubuntu-latest
22
+ strategy:
23
+ matrix:
24
+ python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
25
+
26
+ steps:
27
+ - name: Checkout code
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Set up Python ${{ matrix.python-version }}
31
+ uses: actions/setup-python@v5
32
+ with:
33
+ python-version: ${{ matrix.python-version }}
34
+
35
+ - name: Install dependencies
36
+ run: |
37
+ python -m pip install --upgrade pip
38
+ pip install -e ".[dev]"
39
+
40
+ - name: Run linting
41
+ run: ruff check src/ tests/
42
+
43
+ - name: Run type checking
44
+ run: mypy src/
45
+
46
+ - name: Run tests
47
+ run: pytest
48
+
49
+ build:
50
+ name: Build Distribution
51
+ needs: test
52
+ runs-on: ubuntu-latest
53
+
54
+ steps:
55
+ - name: Checkout code
56
+ uses: actions/checkout@v4
57
+
58
+ - name: Set up Python
59
+ uses: actions/setup-python@v5
60
+ with:
61
+ python-version: '3.12'
62
+
63
+ - name: Install build tools
64
+ run: python -m pip install --upgrade pip build
65
+
66
+ - name: Build package
67
+ run: python -m build
68
+
69
+ - name: Check distribution
70
+ run: |
71
+ pip install twine
72
+ twine check dist/*
73
+
74
+ - name: Upload artifacts
75
+ uses: actions/upload-artifact@v4
76
+ with:
77
+ name: dist
78
+ path: dist/
79
+ if-no-files-found: error
80
+
81
+ publish-testpypi:
82
+ name: Publish to TestPyPI
83
+ needs: build
84
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi'
85
+ runs-on: ubuntu-latest
86
+ environment:
87
+ name: testpypi
88
+ url: https://test.pypi.org/project/aiproxyguard-python-sdk/
89
+ permissions:
90
+ id-token: write
91
+ attestations: write
92
+ contents: read
93
+
94
+ steps:
95
+ - name: Download artifacts
96
+ uses: actions/download-artifact@v4
97
+ with:
98
+ name: dist
99
+ path: dist/
100
+
101
+ - name: Publish to TestPyPI
102
+ uses: pypa/gh-action-pypi-publish@release/v1
103
+ with:
104
+ repository-url: https://test.pypi.org/legacy/
105
+
106
+ publish-pypi:
107
+ name: Publish to PyPI
108
+ needs: build
109
+ if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'pypi')
110
+ runs-on: ubuntu-latest
111
+ environment:
112
+ name: pypi
113
+ url: https://pypi.org/project/aiproxyguard-python-sdk/
114
+ permissions:
115
+ id-token: write
116
+ attestations: write
117
+ contents: read
118
+
119
+ steps:
120
+ - name: Download artifacts
121
+ uses: actions/download-artifact@v4
122
+ with:
123
+ name: dist
124
+ path: dist/
125
+
126
+ - name: Publish to PyPI
127
+ uses: pypa/gh-action-pypi-publish@release/v1
128
+ with:
129
+ attestations: false
130
+ verbose: true
@@ -0,0 +1,77 @@
1
+ # Dependencies
2
+ node_modules/
3
+ bower_components/
4
+ vendor/
5
+
6
+ # Build outputs
7
+ dist/
8
+ build/
9
+ out/
10
+ *.log
11
+ *.min.js
12
+ *.min.css
13
+
14
+ # Environment files
15
+ .env
16
+ .env.local
17
+ .env.*.local
18
+ *.env
19
+
20
+ # IDE and editor files
21
+ .vscode/
22
+ .idea/
23
+ *.swp
24
+ *.swo
25
+ *~
26
+ .DS_Store
27
+ *.sublime-project
28
+ *.sublime-workspace
29
+
30
+ # OS files
31
+ Thumbs.db
32
+ .DS_Store
33
+ .AppleDouble
34
+ .LSOverride
35
+
36
+ # Testing
37
+ coverage/
38
+ .nyc_output/
39
+ *.test.js.snap
40
+
41
+ # Logs
42
+ logs/
43
+ *.log
44
+ npm-debug.log*
45
+ yarn-debug.log*
46
+ yarn-error.log*
47
+ pnpm-debug.log*
48
+ lerna-debug.log*
49
+
50
+ # Runtime data
51
+ pids/
52
+ *.pid
53
+ *.seed
54
+ *.pid.lock
55
+
56
+ # Temporary files
57
+ tmp/
58
+ temp/
59
+ *.tmp
60
+
61
+ # Cache
62
+ .cache/
63
+ .parcel-cache/
64
+ .next/
65
+ .nuxt/
66
+ .eslintcache
67
+
68
+ # Optional npm cache directory
69
+ .npm
70
+
71
+ # Optional REPL history
72
+ .node_repl_history
73
+
74
+ # Package manager lock files (uncomment if needed)
75
+ # package-lock.json
76
+ # yarn.lock
77
+ # pnpm-lock.yaml
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-04-03
9
+
10
+ ### Added
11
+
12
+ - Initial release of the AIProxyGuard Python SDK
13
+ - `AIProxyGuard` client with sync and async support
14
+ - Support for both self-hosted and cloud API modes (`ApiMode.SELF_HOSTED`, `ApiMode.CLOUD`)
15
+ - Prompt injection detection via `check()` and `check_async()` methods
16
+ - `@guard` decorator for automatic input validation on functions
17
+ - `@guard_output` decorator for automatic output validation
18
+ - Comprehensive exception hierarchy:
19
+ - `AIProxyGuardError` (base exception)
20
+ - `ValidationError` for invalid inputs
21
+ - `ConnectionError` for network issues
22
+ - `TimeoutError` for request timeouts
23
+ - `RateLimitError` for rate limit exceeded
24
+ - `ServerError` for server-side errors
25
+ - `ContentBlockedError` for blocked content
26
+ - Health check endpoints (`health()`, `ready()`, `info()`)
27
+ - Full type annotations and `py.typed` marker
28
+ - Support for Python 3.9, 3.10, 3.11, 3.12, and 3.13
29
+
30
+ [0.1.0]: https://github.com/AInvirion/aiproxyguard-python-sdk/releases/tag/v0.1.0
@@ -0,0 +1,81 @@
1
+ # Code of Conduct
2
+
3
+ ## Our Commitment
4
+
5
+ We are committed to providing a welcoming and inclusive environment for all contributors, regardless of experience level, gender identity, sexual orientation, disability, personal appearance, race, ethnicity, age, religion, or nationality.
6
+
7
+ ## Standards
8
+
9
+ ### Expected Behavior
10
+
11
+ - Use welcoming and inclusive language
12
+ - Respect differing viewpoints and experiences
13
+ - Accept constructive criticism gracefully
14
+ - Focus on what is best for the community
15
+ - Show empathy towards other community members
16
+
17
+ ### Unacceptable Behavior
18
+
19
+ - Harassment, intimidation, or discrimination of any kind
20
+ - Trolling, insulting comments, or personal attacks
21
+ - Public or private harassment
22
+ - Publishing others' private information without permission
23
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right to remove, edit, or reject comments, commits, code, issues, and other contributions that do not align with this Code of Conduct, or to ban temporarily or permanently any contributor for behaviors they deem inappropriate, threatening, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies within all project spaces, including the repository, issue tracker, and any other forums created by the project team. It also applies when an individual is representing the project in public spaces.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at legal@ainvirion.com. All complaints will be reviewed and investigated promptly and fairly.
38
+
39
+ All project team members are obligated to respect the privacy and security of the reporter of any incident.
40
+
41
+ ## Enforcement Guidelines
42
+
43
+ Project maintainers will follow these guidelines in determining consequences for any action they deem in violation of this Code of Conduct:
44
+
45
+ ### 1. Correction
46
+
47
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional.
48
+
49
+ **Consequence**: A private written warning, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate.
50
+
51
+ ### 2. Warning
52
+
53
+ **Community Impact**: A violation through a single incident or series of actions.
54
+
55
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved for a specified period. This includes avoiding interactions in project spaces as well as external channels. Violating these terms may lead to a temporary or permanent ban.
56
+
57
+ ### 3. Temporary Ban
58
+
59
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
60
+
61
+ **Consequence**: A temporary ban from any interaction or public communication with the project for a specified period. Violating these terms may lead to a permanent ban.
62
+
63
+ ### 4. Permanent Ban
64
+
65
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment, or aggression toward individuals.
66
+
67
+ **Consequence**: A permanent ban from any public interaction within the project.
68
+
69
+ ## Attribution
70
+
71
+ This Code of Conduct is adapted from the Contributor Covenant, version 2.1.
72
+
73
+ ## Contact
74
+
75
+ For questions or concerns about this Code of Conduct, contact:
76
+ - Email: legal@ainvirion.com
77
+ - General inquiries: contact@ainvirion.com
78
+
79
+ ---
80
+
81
+ Copyright (c) 2025-2026 AInvirion LLC. All Rights Reserved.