amigo_sdk 0.1.1__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.
Potentially problematic release.
This version of amigo_sdk might be problematic. Click here for more details.
- amigo_sdk-0.1.1/.github/workflows/release.yml +175 -0
- amigo_sdk-0.1.1/.github/workflows/test.yml +50 -0
- amigo_sdk-0.1.1/.gitignore +15 -0
- amigo_sdk-0.1.1/CONTRIBUTING.md +77 -0
- amigo_sdk-0.1.1/LICENSE +21 -0
- amigo_sdk-0.1.1/PKG-INFO +192 -0
- amigo_sdk-0.1.1/README.md +170 -0
- amigo_sdk-0.1.1/pyproject.toml +141 -0
- amigo_sdk-0.1.1/scripts/__init__.py +0 -0
- amigo_sdk-0.1.1/scripts/aliases.json +5 -0
- amigo_sdk-0.1.1/scripts/check.py +102 -0
- amigo_sdk-0.1.1/scripts/gen_models.py +70 -0
- amigo_sdk-0.1.1/src/amigo_sdk/__init__.py +1 -0
- amigo_sdk-0.1.1/src/amigo_sdk/auth.py +30 -0
- amigo_sdk-0.1.1/src/amigo_sdk/config.py +48 -0
- amigo_sdk-0.1.1/src/amigo_sdk/errors.py +163 -0
- amigo_sdk-0.1.1/src/amigo_sdk/generated/model.py +15683 -0
- amigo_sdk-0.1.1/src/amigo_sdk/http_client.py +228 -0
- amigo_sdk-0.1.1/src/amigo_sdk/resources/conversation.py +208 -0
- amigo_sdk-0.1.1/src/amigo_sdk/resources/organization.py +22 -0
- amigo_sdk-0.1.1/src/amigo_sdk/resources/service.py +30 -0
- amigo_sdk-0.1.1/src/amigo_sdk/resources/user.py +57 -0
- amigo_sdk-0.1.1/src/amigo_sdk/sdk_client.py +105 -0
- amigo_sdk-0.1.1/tests/__init__.py +1 -0
- amigo_sdk-0.1.1/tests/conftest.py +20 -0
- amigo_sdk-0.1.1/tests/integration/test_conversation_integration.py +211 -0
- amigo_sdk-0.1.1/tests/integration/test_organization_integration.py +127 -0
- amigo_sdk-0.1.1/tests/integration/test_user_integration.py +97 -0
- amigo_sdk-0.1.1/tests/resources/__init__.py +1 -0
- amigo_sdk-0.1.1/tests/resources/helpers.py +213 -0
- amigo_sdk-0.1.1/tests/resources/test_conversation.py +463 -0
- amigo_sdk-0.1.1/tests/resources/test_organization.py +60 -0
- amigo_sdk-0.1.1/tests/resources/test_service.py +58 -0
- amigo_sdk-0.1.1/tests/resources/test_user.py +123 -0
- amigo_sdk-0.1.1/tests/test_auth.py +107 -0
- amigo_sdk-0.1.1/tests/test_config.py +132 -0
- amigo_sdk-0.1.1/tests/test_errors.py +117 -0
- amigo_sdk-0.1.1/tests/test_http_client.py +551 -0
- amigo_sdk-0.1.1/tests/test_sdk_client.py +77 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version_type:
|
|
7
|
+
description: "Version increment type"
|
|
8
|
+
required: true
|
|
9
|
+
default: "patch"
|
|
10
|
+
type: choice
|
|
11
|
+
options:
|
|
12
|
+
- patch
|
|
13
|
+
- minor
|
|
14
|
+
- major
|
|
15
|
+
dry_run:
|
|
16
|
+
description: "Dry run (skip upload)"
|
|
17
|
+
required: false
|
|
18
|
+
default: false
|
|
19
|
+
type: boolean
|
|
20
|
+
|
|
21
|
+
permissions:
|
|
22
|
+
contents: write
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
# Reuse the existing test workflow
|
|
26
|
+
test:
|
|
27
|
+
uses: ./.github/workflows/test.yml
|
|
28
|
+
with:
|
|
29
|
+
skip_codecov: true
|
|
30
|
+
secrets: inherit
|
|
31
|
+
|
|
32
|
+
release:
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
needs: test
|
|
35
|
+
|
|
36
|
+
steps:
|
|
37
|
+
- name: Checkout code
|
|
38
|
+
uses: actions/checkout@v4
|
|
39
|
+
with:
|
|
40
|
+
# Fetch full history for version tagging
|
|
41
|
+
fetch-depth: 0
|
|
42
|
+
# Use a token that can push tags and create releases
|
|
43
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
44
|
+
|
|
45
|
+
- name: Setup Python
|
|
46
|
+
uses: actions/setup-python@v5
|
|
47
|
+
with:
|
|
48
|
+
python-version: "3.13"
|
|
49
|
+
cache: "pip"
|
|
50
|
+
|
|
51
|
+
- name: Install dependencies
|
|
52
|
+
run: |
|
|
53
|
+
python -m pip install --upgrade pip
|
|
54
|
+
pip install -e ".[dev]"
|
|
55
|
+
pip install hatch
|
|
56
|
+
|
|
57
|
+
- name: Configure git
|
|
58
|
+
run: |
|
|
59
|
+
git config --global user.name "github-actions[bot]"
|
|
60
|
+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
61
|
+
|
|
62
|
+
- name: Get current version
|
|
63
|
+
id: current_version
|
|
64
|
+
run: |
|
|
65
|
+
CURRENT_VERSION=$(hatch version)
|
|
66
|
+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
67
|
+
echo "Current version: $CURRENT_VERSION"
|
|
68
|
+
|
|
69
|
+
- name: Generate models
|
|
70
|
+
run: |
|
|
71
|
+
echo "🔄 Generating models from API spec..."
|
|
72
|
+
python -m scripts.gen_models
|
|
73
|
+
echo "✅ Models generated successfully"
|
|
74
|
+
|
|
75
|
+
- name: Increment version
|
|
76
|
+
id: new_version
|
|
77
|
+
run: |
|
|
78
|
+
echo "🔄 Incrementing ${{ inputs.version_type }} version..."
|
|
79
|
+
hatch version ${{ inputs.version_type }}
|
|
80
|
+
NEW_VERSION=$(hatch version)
|
|
81
|
+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
82
|
+
echo "✅ Version updated: ${{ steps.current_version.outputs.version }} → $NEW_VERSION"
|
|
83
|
+
|
|
84
|
+
- name: Build package
|
|
85
|
+
run: |
|
|
86
|
+
echo "🔄 Building package..."
|
|
87
|
+
# Clean any existing build artifacts
|
|
88
|
+
rm -rf dist/
|
|
89
|
+
hatch build
|
|
90
|
+
echo "✅ Package built successfully"
|
|
91
|
+
ls -la dist/
|
|
92
|
+
|
|
93
|
+
- name: Upload to PyPI
|
|
94
|
+
if: ${{ !inputs.dry_run }}
|
|
95
|
+
env:
|
|
96
|
+
HATCH_INDEX_USER: __token__
|
|
97
|
+
HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }}
|
|
98
|
+
run: |
|
|
99
|
+
echo "🔄 Uploading to PyPI..."
|
|
100
|
+
hatch publish --repo https://upload.pypi.org/legacy/
|
|
101
|
+
echo "✅ Package uploaded to PyPI"
|
|
102
|
+
|
|
103
|
+
- name: Commit version bump
|
|
104
|
+
if: ${{ !inputs.dry_run }}
|
|
105
|
+
run: |
|
|
106
|
+
git add src/amigo_sdk/__init__.py
|
|
107
|
+
git commit -m "Bump version to ${{ steps.new_version.outputs.version }}"
|
|
108
|
+
git push origin HEAD
|
|
109
|
+
|
|
110
|
+
- name: Create and push tag
|
|
111
|
+
if: ${{ !inputs.dry_run }}
|
|
112
|
+
run: |
|
|
113
|
+
git tag -a "v${{ steps.new_version.outputs.version }}" -m "Release v${{ steps.new_version.outputs.version }}"
|
|
114
|
+
git push origin "v${{ steps.new_version.outputs.version }}"
|
|
115
|
+
|
|
116
|
+
- name: Create GitHub Release
|
|
117
|
+
if: ${{ !inputs.dry_run }}
|
|
118
|
+
uses: actions/create-release@v1
|
|
119
|
+
env:
|
|
120
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
121
|
+
with:
|
|
122
|
+
tag_name: "v${{ steps.new_version.outputs.version }}"
|
|
123
|
+
release_name: "Release v${{ steps.new_version.outputs.version }}"
|
|
124
|
+
body: |
|
|
125
|
+
## Changes in v${{ steps.new_version.outputs.version }}
|
|
126
|
+
|
|
127
|
+
This release was automatically created by the GitHub Actions release workflow.
|
|
128
|
+
|
|
129
|
+
### Package Information
|
|
130
|
+
- **Version**: ${{ steps.new_version.outputs.version }}
|
|
131
|
+
- **Target**: PyPI
|
|
132
|
+
- **Type**: ${{ inputs.version_type }} release
|
|
133
|
+
|
|
134
|
+
### Links
|
|
135
|
+
${{ format('- [View on PyPI](https://pypi.org/project/amigo_sdk/{0}/)', steps.new_version.outputs.version) }}
|
|
136
|
+
|
|
137
|
+
### Installation
|
|
138
|
+
```bash
|
|
139
|
+
pip install amigo_sdk
|
|
140
|
+
```
|
|
141
|
+
draft: false
|
|
142
|
+
|
|
143
|
+
- name: Upload build artifacts
|
|
144
|
+
if: always()
|
|
145
|
+
uses: actions/upload-artifact@v4
|
|
146
|
+
with:
|
|
147
|
+
name: dist-${{ steps.new_version.outputs.version }}
|
|
148
|
+
path: dist/
|
|
149
|
+
retention-days: 30
|
|
150
|
+
|
|
151
|
+
- name: Release Summary
|
|
152
|
+
run: |
|
|
153
|
+
echo "## 🎉 Release Summary" >> $GITHUB_STEP_SUMMARY
|
|
154
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
155
|
+
echo "- **Version**: ${{ steps.new_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
|
156
|
+
echo "- **Previous**: ${{ steps.current_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
|
157
|
+
echo "- **Type**: ${{ inputs.version_type }} release" >> $GITHUB_STEP_SUMMARY
|
|
158
|
+
echo "- **Target**: PyPI" >> $GITHUB_STEP_SUMMARY
|
|
159
|
+
echo "- **Dry Run**: ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY
|
|
160
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
161
|
+
|
|
162
|
+
if [ "${{ inputs.dry_run }}" = "false" ]; then
|
|
163
|
+
echo "### 📦 Package Links" >> $GITHUB_STEP_SUMMARY
|
|
164
|
+
echo "- [PyPI Package](https://pypi.org/project/amigo_sdk/${{ steps.new_version.outputs.version }}/)" >> $GITHUB_STEP_SUMMARY
|
|
165
|
+
echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.new_version.outputs.version }})" >> $GITHUB_STEP_SUMMARY
|
|
166
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
167
|
+
echo "### 🚀 Next Steps" >> $GITHUB_STEP_SUMMARY
|
|
168
|
+
echo "The package has been successfully released and is available for installation!" >> $GITHUB_STEP_SUMMARY
|
|
169
|
+
else
|
|
170
|
+
echo "### 🚫 Dry Run Results" >> $GITHUB_STEP_SUMMARY
|
|
171
|
+
echo "- All steps completed successfully" >> $GITHUB_STEP_SUMMARY
|
|
172
|
+
echo "- Version would be bumped to: ${{ steps.new_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
|
173
|
+
echo "- Package built and ready for upload" >> $GITHUB_STEP_SUMMARY
|
|
174
|
+
echo "- No commits, tags, or uploads were made" >> $GITHUB_STEP_SUMMARY
|
|
175
|
+
fi
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_call:
|
|
9
|
+
inputs:
|
|
10
|
+
skip_codecov:
|
|
11
|
+
description: "Skip Codecov upload"
|
|
12
|
+
required: false
|
|
13
|
+
default: true
|
|
14
|
+
type: boolean
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout code
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Python
|
|
25
|
+
uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.13"
|
|
28
|
+
cache: "pip"
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --upgrade pip
|
|
33
|
+
pip install -e ".[dev]"
|
|
34
|
+
|
|
35
|
+
- name: Run linter
|
|
36
|
+
run: ruff check .
|
|
37
|
+
|
|
38
|
+
- name: Run formatter check
|
|
39
|
+
run: ruff format --check .
|
|
40
|
+
|
|
41
|
+
- name: Run tests with coverage
|
|
42
|
+
run: pytest --cov=src --cov-report=xml --cov-report=term
|
|
43
|
+
|
|
44
|
+
- name: Upload coverage reports to Codecov
|
|
45
|
+
if: inputs.skip_codecov != true
|
|
46
|
+
uses: codecov/codecov-action@v5
|
|
47
|
+
with:
|
|
48
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
49
|
+
files: ./coverage.xml
|
|
50
|
+
fail_ci_if_error: true
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Contributing Guide
|
|
2
|
+
|
|
3
|
+
## Quick Setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Create and activate virtual environment
|
|
7
|
+
python -m venv .venv
|
|
8
|
+
source .venv/bin/activate
|
|
9
|
+
|
|
10
|
+
# Install the project in development mode
|
|
11
|
+
pip install -e ".[dev]"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Development Commands
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
check # Run all checks (format, lint, tests)
|
|
18
|
+
check --fix # Auto-fix issues and run all checks
|
|
19
|
+
check --fast # Format + lint only (skip tests)
|
|
20
|
+
|
|
21
|
+
gen-models # Generate models from API spec
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Workflow
|
|
25
|
+
|
|
26
|
+
1. **Before committing:** Run `check --fix` to auto-fix issues
|
|
27
|
+
2. **During development:** Use `check --fast` for quick validation
|
|
28
|
+
3. **Update models:** Run `gen-models` when API changes
|
|
29
|
+
|
|
30
|
+
## Release Process
|
|
31
|
+
|
|
32
|
+
### GitHub Actions Release
|
|
33
|
+
|
|
34
|
+
1. Go to the **Actions** tab in GitHub
|
|
35
|
+
2. Select the **Release** workflow
|
|
36
|
+
3. Click **Run workflow** and choose:
|
|
37
|
+
- **Version type**: `patch` (default), `minor`, or `major`
|
|
38
|
+
- **Dry run**: Test the release process without publishing
|
|
39
|
+
- **Production**: Upload to PyPI instead of TestPyPI
|
|
40
|
+
|
|
41
|
+
The workflow will automatically:
|
|
42
|
+
|
|
43
|
+
- ✅ Run all tests, linting, and formatting checks (reuses existing test workflow)
|
|
44
|
+
- 🔄 Generate fresh models from the API spec
|
|
45
|
+
- 📈 Increment the version using Hatch
|
|
46
|
+
- 📦 Build the package
|
|
47
|
+
- 🚀 Upload to TestPyPI (or PyPI if production mode)
|
|
48
|
+
- 🏷️ Create a Git tag and GitHub release
|
|
49
|
+
- 📋 Provide detailed summary with links
|
|
50
|
+
|
|
51
|
+
### Required Repository Secrets
|
|
52
|
+
|
|
53
|
+
Configure these secrets in your GitHub repository settings:
|
|
54
|
+
|
|
55
|
+
- `TEST_PYPI_API_TOKEN`: Token for https://test.pypi.org/
|
|
56
|
+
- `PYPI_API_TOKEN`: Token for https://pypi.org/ (production releases)
|
|
57
|
+
|
|
58
|
+
### Getting API Tokens
|
|
59
|
+
|
|
60
|
+
1. **TestPyPI**: Go to https://test.pypi.org/manage/account/token/
|
|
61
|
+
2. **PyPI**: Go to https://pypi.org/manage/account/token/
|
|
62
|
+
3. Create a token with upload permissions
|
|
63
|
+
4. Add the token to your repository secrets
|
|
64
|
+
|
|
65
|
+
## IDE Setup (VS Code)
|
|
66
|
+
|
|
67
|
+
Install extensions:
|
|
68
|
+
|
|
69
|
+
- [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff)
|
|
70
|
+
- [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python)
|
|
71
|
+
|
|
72
|
+
## Troubleshooting
|
|
73
|
+
|
|
74
|
+
- **Command not found:** Activate virtual environment with `source .venv/bin/activate`
|
|
75
|
+
- **Linting failures:** Run `check --fix` to auto-fix issues
|
|
76
|
+
- **Model import errors:** Run `gen-models` to regenerate models
|
|
77
|
+
- **Release failures:** Check API tokens are configured in repository secrets and try a dry run first
|
amigo_sdk-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Amigo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
amigo_sdk-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amigo_sdk
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Amigo AI Python SDK
|
|
5
|
+
Author: Amigo AI
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Requires-Dist: email-validator<3.0,>=2.0
|
|
10
|
+
Requires-Dist: httpx<1.0,>=0.25
|
|
11
|
+
Requires-Dist: pydantic-settings<3.0,>=2.0
|
|
12
|
+
Requires-Dist: pydantic<3.0,>=2.7
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: datamodel-code-generator[http]<1.0,>=0.21; extra == 'dev'
|
|
15
|
+
Requires-Dist: pytest-asyncio<1.0,>=0.21; extra == 'dev'
|
|
16
|
+
Requires-Dist: pytest-cov<6.0,>=4.0; extra == 'dev'
|
|
17
|
+
Requires-Dist: pytest-httpx<1.0,>=0.30; extra == 'dev'
|
|
18
|
+
Requires-Dist: pytest<9.0,>=7.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: python-dotenv<2.0,>=1.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: ruff<1.0,>=0.1; extra == 'dev'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# Amigo Python SDK
|
|
24
|
+
|
|
25
|
+
[](https://github.com/amigo-ai/amigo-python-sdk/actions/workflows/test.yml)
|
|
26
|
+
[](https://codecov.io/gh/amigo-ai/amigo-python-sdk)
|
|
27
|
+
[](https://opensource.org/licenses/MIT)
|
|
28
|
+
|
|
29
|
+
The official Python SDK for the Amigo API, providing a simple and intuitive interface to interact with Amigo's AI services.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Install the SDK using pip:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install amigo_sdk
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or add it to your requirements.txt:
|
|
40
|
+
|
|
41
|
+
```txt
|
|
42
|
+
amigo_sdk
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### API compatibility
|
|
46
|
+
|
|
47
|
+
This SDK auto-generates its types from the latest [Amigo OpenAPI schema](https://api.amigo.ai/v1/openapi.json). As a result, only the latest published SDK version is guaranteed to match the current API. If you pin to an older version, it may not include the newest endpoints or fields.
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import asyncio
|
|
53
|
+
from amigo_sdk import AmigoClient
|
|
54
|
+
from amigo_sdk.generated.model import GetConversationsParametersQuery
|
|
55
|
+
|
|
56
|
+
# Initialize the client
|
|
57
|
+
client = AmigoClient(
|
|
58
|
+
api_key="your-api-key",
|
|
59
|
+
api_key_id="your-api-key-id",
|
|
60
|
+
user_id="user-id",
|
|
61
|
+
org_id="your-organization-id",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# List recent conversations
|
|
65
|
+
async def example():
|
|
66
|
+
try:
|
|
67
|
+
async with client:
|
|
68
|
+
conversations = await client.conversation.get_conversations(
|
|
69
|
+
GetConversationsParametersQuery(limit=10, sort_by=["-created_at"])
|
|
70
|
+
)
|
|
71
|
+
print("Conversations:", conversations)
|
|
72
|
+
except Exception as error:
|
|
73
|
+
print(error)
|
|
74
|
+
|
|
75
|
+
# Run the example
|
|
76
|
+
asyncio.run(example())
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Examples
|
|
80
|
+
|
|
81
|
+
For more SDK usage examples see checkout the [examples/](examples/README.md) folder.
|
|
82
|
+
|
|
83
|
+
## Configuration
|
|
84
|
+
|
|
85
|
+
The SDK requires the following configuration parameters:
|
|
86
|
+
|
|
87
|
+
| Parameter | Type | Required | Description |
|
|
88
|
+
| ------------ | ---- | -------- | -------------------------------------------------------------- |
|
|
89
|
+
| `api_key` | str | ✅ | API key from Amigo dashboard |
|
|
90
|
+
| `api_key_id` | str | ✅ | API key ID from Amigo dashboard |
|
|
91
|
+
| `user_id` | str | ✅ | User ID on whose behalf the request is made |
|
|
92
|
+
| `org_id` | str | ✅ | Your organization ID |
|
|
93
|
+
| `base_url` | str | ❌ | Base URL of the Amigo API (defaults to `https://api.amigo.ai`) |
|
|
94
|
+
|
|
95
|
+
### Environment Variables
|
|
96
|
+
|
|
97
|
+
You can also configure the SDK using environment variables:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
export AMIGO_API_KEY="your-api-key"
|
|
101
|
+
export AMIGO_API_KEY_ID="your-api-key-id"
|
|
102
|
+
export AMIGO_USER_ID="user-id"
|
|
103
|
+
export AMIGO_ORG_ID="your-organization-id"
|
|
104
|
+
export AMIGO_BASE_URL="https://api.amigo.ai" # optional
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Then initialize the client without parameters:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from amigo_sdk import AmigoClient
|
|
111
|
+
|
|
112
|
+
# Automatically loads from environment variables
|
|
113
|
+
client = AmigoClient()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Using .env Files
|
|
117
|
+
|
|
118
|
+
Create a `.env` file in your project root:
|
|
119
|
+
|
|
120
|
+
```env
|
|
121
|
+
AMIGO_API_KEY=your-api-key
|
|
122
|
+
AMIGO_API_KEY_ID=your-api-key-id
|
|
123
|
+
AMIGO_USER_ID=user-id
|
|
124
|
+
AMIGO_ORG_ID=your-organization-id
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The SDK will automatically load these variables.
|
|
128
|
+
|
|
129
|
+
### Getting Your API Credentials
|
|
130
|
+
|
|
131
|
+
1. **API Key & API Key ID**: Generate these from your Amigo admin dashboard or programmatically using the API
|
|
132
|
+
2. **Organization ID**: Found in your Amigo dashboard URL or organization settings
|
|
133
|
+
3. **User ID**: The ID of the user you want to impersonate for API calls
|
|
134
|
+
|
|
135
|
+
For detailed instructions on generating API keys, see the [Authentication Guide](https://docs.amigo.ai/developer-guide).
|
|
136
|
+
|
|
137
|
+
## Available Resources
|
|
138
|
+
|
|
139
|
+
The SDK provides access to the following resources:
|
|
140
|
+
|
|
141
|
+
- **Organizations**: Get Organization info
|
|
142
|
+
- **Services**: Get available services
|
|
143
|
+
- **Conversation**: Manage conversations
|
|
144
|
+
- **User**: Manage users
|
|
145
|
+
|
|
146
|
+
## Error Handling
|
|
147
|
+
|
|
148
|
+
The SDK provides typed error handling:
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from amigo_sdk import AmigoClient
|
|
152
|
+
from amigo_sdk.errors import (
|
|
153
|
+
AuthenticationError,
|
|
154
|
+
NotFoundError,
|
|
155
|
+
BadRequestError,
|
|
156
|
+
ValidationError
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
async def example_with_error_handling():
|
|
160
|
+
client = AmigoClient()
|
|
161
|
+
|
|
162
|
+
try:
|
|
163
|
+
async with client:
|
|
164
|
+
result = await client.organizations.get_organization("org-id")
|
|
165
|
+
except AuthenticationError as error:
|
|
166
|
+
print("Authentication failed:", error)
|
|
167
|
+
except NotFoundError as error:
|
|
168
|
+
print("Resource not found:", error)
|
|
169
|
+
except BadRequestError as error:
|
|
170
|
+
print("Bad request:", error)
|
|
171
|
+
except ValidationError as error:
|
|
172
|
+
print("Validation error:", error)
|
|
173
|
+
except Exception as error:
|
|
174
|
+
print("Unexpected error:", error)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Development
|
|
178
|
+
|
|
179
|
+
For detailed development setup, testing, and contribution guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
180
|
+
|
|
181
|
+
## Documentation
|
|
182
|
+
|
|
183
|
+
- **Developer Guide**: [https://docs.amigo.ai/developer-guide](https://docs.amigo.ai/developer-guide)
|
|
184
|
+
- **API Reference**: [https://docs.amigo.ai/api-reference](https://docs.amigo.ai/api-reference)
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
189
|
+
|
|
190
|
+
## Support
|
|
191
|
+
|
|
192
|
+
For questions, issues, or feature requests, please visit our [GitHub repository](https://github.com/amigo-ai/amigo-python-sdk) or contact support through the Amigo dashboard.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Amigo Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://github.com/amigo-ai/amigo-python-sdk/actions/workflows/test.yml)
|
|
4
|
+
[](https://codecov.io/gh/amigo-ai/amigo-python-sdk)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
The official Python SDK for the Amigo API, providing a simple and intuitive interface to interact with Amigo's AI services.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Install the SDK using pip:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install amigo_sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or add it to your requirements.txt:
|
|
18
|
+
|
|
19
|
+
```txt
|
|
20
|
+
amigo_sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### API compatibility
|
|
24
|
+
|
|
25
|
+
This SDK auto-generates its types from the latest [Amigo OpenAPI schema](https://api.amigo.ai/v1/openapi.json). As a result, only the latest published SDK version is guaranteed to match the current API. If you pin to an older version, it may not include the newest endpoints or fields.
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import asyncio
|
|
31
|
+
from amigo_sdk import AmigoClient
|
|
32
|
+
from amigo_sdk.generated.model import GetConversationsParametersQuery
|
|
33
|
+
|
|
34
|
+
# Initialize the client
|
|
35
|
+
client = AmigoClient(
|
|
36
|
+
api_key="your-api-key",
|
|
37
|
+
api_key_id="your-api-key-id",
|
|
38
|
+
user_id="user-id",
|
|
39
|
+
org_id="your-organization-id",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# List recent conversations
|
|
43
|
+
async def example():
|
|
44
|
+
try:
|
|
45
|
+
async with client:
|
|
46
|
+
conversations = await client.conversation.get_conversations(
|
|
47
|
+
GetConversationsParametersQuery(limit=10, sort_by=["-created_at"])
|
|
48
|
+
)
|
|
49
|
+
print("Conversations:", conversations)
|
|
50
|
+
except Exception as error:
|
|
51
|
+
print(error)
|
|
52
|
+
|
|
53
|
+
# Run the example
|
|
54
|
+
asyncio.run(example())
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Examples
|
|
58
|
+
|
|
59
|
+
For more SDK usage examples see checkout the [examples/](examples/README.md) folder.
|
|
60
|
+
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
The SDK requires the following configuration parameters:
|
|
64
|
+
|
|
65
|
+
| Parameter | Type | Required | Description |
|
|
66
|
+
| ------------ | ---- | -------- | -------------------------------------------------------------- |
|
|
67
|
+
| `api_key` | str | ✅ | API key from Amigo dashboard |
|
|
68
|
+
| `api_key_id` | str | ✅ | API key ID from Amigo dashboard |
|
|
69
|
+
| `user_id` | str | ✅ | User ID on whose behalf the request is made |
|
|
70
|
+
| `org_id` | str | ✅ | Your organization ID |
|
|
71
|
+
| `base_url` | str | ❌ | Base URL of the Amigo API (defaults to `https://api.amigo.ai`) |
|
|
72
|
+
|
|
73
|
+
### Environment Variables
|
|
74
|
+
|
|
75
|
+
You can also configure the SDK using environment variables:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
export AMIGO_API_KEY="your-api-key"
|
|
79
|
+
export AMIGO_API_KEY_ID="your-api-key-id"
|
|
80
|
+
export AMIGO_USER_ID="user-id"
|
|
81
|
+
export AMIGO_ORG_ID="your-organization-id"
|
|
82
|
+
export AMIGO_BASE_URL="https://api.amigo.ai" # optional
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then initialize the client without parameters:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from amigo_sdk import AmigoClient
|
|
89
|
+
|
|
90
|
+
# Automatically loads from environment variables
|
|
91
|
+
client = AmigoClient()
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Using .env Files
|
|
95
|
+
|
|
96
|
+
Create a `.env` file in your project root:
|
|
97
|
+
|
|
98
|
+
```env
|
|
99
|
+
AMIGO_API_KEY=your-api-key
|
|
100
|
+
AMIGO_API_KEY_ID=your-api-key-id
|
|
101
|
+
AMIGO_USER_ID=user-id
|
|
102
|
+
AMIGO_ORG_ID=your-organization-id
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The SDK will automatically load these variables.
|
|
106
|
+
|
|
107
|
+
### Getting Your API Credentials
|
|
108
|
+
|
|
109
|
+
1. **API Key & API Key ID**: Generate these from your Amigo admin dashboard or programmatically using the API
|
|
110
|
+
2. **Organization ID**: Found in your Amigo dashboard URL or organization settings
|
|
111
|
+
3. **User ID**: The ID of the user you want to impersonate for API calls
|
|
112
|
+
|
|
113
|
+
For detailed instructions on generating API keys, see the [Authentication Guide](https://docs.amigo.ai/developer-guide).
|
|
114
|
+
|
|
115
|
+
## Available Resources
|
|
116
|
+
|
|
117
|
+
The SDK provides access to the following resources:
|
|
118
|
+
|
|
119
|
+
- **Organizations**: Get Organization info
|
|
120
|
+
- **Services**: Get available services
|
|
121
|
+
- **Conversation**: Manage conversations
|
|
122
|
+
- **User**: Manage users
|
|
123
|
+
|
|
124
|
+
## Error Handling
|
|
125
|
+
|
|
126
|
+
The SDK provides typed error handling:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from amigo_sdk import AmigoClient
|
|
130
|
+
from amigo_sdk.errors import (
|
|
131
|
+
AuthenticationError,
|
|
132
|
+
NotFoundError,
|
|
133
|
+
BadRequestError,
|
|
134
|
+
ValidationError
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
async def example_with_error_handling():
|
|
138
|
+
client = AmigoClient()
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
async with client:
|
|
142
|
+
result = await client.organizations.get_organization("org-id")
|
|
143
|
+
except AuthenticationError as error:
|
|
144
|
+
print("Authentication failed:", error)
|
|
145
|
+
except NotFoundError as error:
|
|
146
|
+
print("Resource not found:", error)
|
|
147
|
+
except BadRequestError as error:
|
|
148
|
+
print("Bad request:", error)
|
|
149
|
+
except ValidationError as error:
|
|
150
|
+
print("Validation error:", error)
|
|
151
|
+
except Exception as error:
|
|
152
|
+
print("Unexpected error:", error)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
For detailed development setup, testing, and contribution guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
158
|
+
|
|
159
|
+
## Documentation
|
|
160
|
+
|
|
161
|
+
- **Developer Guide**: [https://docs.amigo.ai/developer-guide](https://docs.amigo.ai/developer-guide)
|
|
162
|
+
- **API Reference**: [https://docs.amigo.ai/api-reference](https://docs.amigo.ai/api-reference)
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
167
|
+
|
|
168
|
+
## Support
|
|
169
|
+
|
|
170
|
+
For questions, issues, or feature requests, please visit our [GitHub repository](https://github.com/amigo-ai/amigo-python-sdk) or contact support through the Amigo dashboard.
|