Skip to content

Commit

Permalink
Merge pull request #200 from Haidra-Org/main
Browse files Browse the repository at this point in the history
feat: kudos, users and more stats endpoints; better examples
  • Loading branch information
tazlin authored May 30, 2024
2 parents 425a370 + 64af40a commit 35de911
Show file tree
Hide file tree
Showing 69 changed files with 6,102 additions and 2,461 deletions.
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,19 @@ out.json
.vscode/launch.json
.vscode/settings.json

examples/requested_images/*.*
requested_images/*.*
examples/ai_horde_client/image/requested_images/*.*

requested_text/*.*
examples/ai_horde_client/text/requested_text/*.*

_version.py
# to prevent mkdocs from including this file in the documentation
_version.md

tests/testing_result_images/*
!tests/testing_result_images/.results_go_here

workers.txt

ai_horde_codegen.py
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ repos:
types-pytz,
types-setuptools,
types-urllib3,
types-aiofiles,
StrEnum
]
14 changes: 7 additions & 7 deletions codegen/ai_horde/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ api-spec-converter --from=swagger_2 --to=openapi_3 swagger.json > swagger_openap

Generate the code:
```bash
datamodel-codegen --input codegen/swagger_openapi3.json --output codegen/ai_horde_codegen.py --output-model-type pydantic_v2.BaseModel --use-union-operator --field-constraints
datamodel-codegen --input swagger_openapi3.json --output ai_horde_codegen.py --output-model-type pydantic_v2.BaseModel --use-union-operator --field-constraints
```

Standardize quotes with black:
```bash
black codegen/ai_horde_codegen.py
black ai_horde_codegen.py
```

Clean up issues with datamodel-code-generator v0.21.1
```bash
python codegen/codegen_regex_fixes.py codegen/ai_horde_codegen.py
python codegen_regex_fixes.py ai_horde_codegen.py
```

Format again, this time truncating the lines with `--preview`, and auto-fix lint problems
```bash
black codegen/ai_horde_codegen.py --unstable --enable-unstable-feature string_processing
ruff codegen/ai_horde_codegen.py --fix
black codegen/ai_horde_codegen.py --unstable --enable-unstable-feature string_processing # for good measure
ruff codegen/ai_horde_codegen.py --fix # for good measure
black ai_horde_codegen.py --unstable --enable-unstable-feature string_processing
ruff ai_horde_codegen.py --fix
black ai_horde_codegen.py --unstable --enable-unstable-feature string_processing # for good measure
ruff ai_horde_codegen.py --fix # for good measure
```

* Fix Enum classes
Expand Down
15 changes: 12 additions & 3 deletions docs/api_to_sdk_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This is a mapping of the AI-Horde API models (defined at [https://stablehorde.ne
| /v2/interrogate/status/{id} | DELETE | [AlchemyDeleteRequest][horde_sdk.ai_horde_api.apimodels.alchemy._status.AlchemyDeleteRequest] |
| /v2/interrogate/status/{id} | GET | [AlchemyStatusRequest][horde_sdk.ai_horde_api.apimodels.alchemy._status.AlchemyStatusRequest] |
| /v2/interrogate/submit | POST | [AlchemyJobSubmitRequest][horde_sdk.ai_horde_api.apimodels.alchemy._submit.AlchemyJobSubmitRequest] |
| /v2/kudos/transfer | POST | [KudosTransferRequest][horde_sdk.ai_horde_api.apimodels._kudos.KudosTransferRequest] |
| /v2/stats/img/models | GET | [ImageStatsModelsRequest][horde_sdk.ai_horde_api.apimodels._stats.ImageStatsModelsRequest] |
| /v2/stats/img/totals | GET | [ImageStatsModelsTotalRequest][horde_sdk.ai_horde_api.apimodels._stats.ImageStatsModelsTotalRequest] |
| /v2/stats/text/models | GET | [TextStatsModelsRequest][horde_sdk.ai_horde_api.apimodels._stats.TextStatsModelsRequest] |
Expand All @@ -30,14 +31,19 @@ This is a mapping of the AI-Horde API models (defined at [https://stablehorde.ne
| /v2/status/models/{model_name} | GET | [HordeStatusModelsSingleRequest][horde_sdk.ai_horde_api.apimodels._status.HordeStatusModelsSingleRequest] |
| /v2/status/news | GET | [NewsRequest][horde_sdk.ai_horde_api.apimodels._status.NewsRequest] |
| /v2/status/performance | GET | [HordePerformanceRequest][horde_sdk.ai_horde_api.apimodels._status.HordePerformanceRequest] |
| /v2/users | GET | [ListUsersDetailsRequest][horde_sdk.ai_horde_api.apimodels._users.ListUsersDetailsRequest] |
| /v2/users/{user_id} | PUT | [ModifyUserRequest][horde_sdk.ai_horde_api.apimodels._users.ModifyUserRequest] |
| /v2/users/{user_id} | GET | [SingleUserDetailsRequest][horde_sdk.ai_horde_api.apimodels._users.SingleUserDetailsRequest] |
| /v2/workers | GET | [AllWorkersDetailsRequest][horde_sdk.ai_horde_api.apimodels.workers._workers.AllWorkersDetailsRequest] |
| /v2/workers/{worker_id} | DELETE | [DeleteWorkerRequest][horde_sdk.ai_horde_api.apimodels.workers._workers.DeleteWorkerRequest] |
| /v2/workers/{worker_id} | PUT | [ModifyWorkerRequest][horde_sdk.ai_horde_api.apimodels.workers._workers.ModifyWorkerRequest] |
| /v2/workers/{worker_id} | GET | [SingleWorkerDetailsRequest][horde_sdk.ai_horde_api.apimodels.workers._workers.SingleWorkerDetailsRequest] |


## Responses
| API Endpoint | HTTP Status Code | SDK Response Type |
| ------------ | ----------- | ----------------- |
| /v2/find_user | 200 | [FindUserResponse][horde_sdk.ai_horde_api.apimodels._find_user.FindUserResponse] |
| /v2/find_user | 200 | [UserDetailsResponse][horde_sdk.ai_horde_api.apimodels._users.UserDetailsResponse] |
| /v2/generate/async | 200 | [ImageGenerateAsyncDryRunResponse][horde_sdk.ai_horde_api.apimodels.generate._async.ImageGenerateAsyncDryRunResponse] |
| /v2/generate/async | 202 | [ImageGenerateAsyncResponse][horde_sdk.ai_horde_api.apimodels.generate._async.ImageGenerateAsyncResponse] |
| /v2/generate/check/{id} | 200 | [ImageGenerateCheckResponse][horde_sdk.ai_horde_api.apimodels.generate._check.ImageGenerateCheckResponse] |
Expand All @@ -53,14 +59,17 @@ This is a mapping of the AI-Horde API models (defined at [https://stablehorde.ne
| /v2/interrogate/pop | 200 | [AlchemyPopResponse][horde_sdk.ai_horde_api.apimodels.alchemy._pop.AlchemyPopResponse] |
| /v2/interrogate/status/{id} | 200 | [AlchemyStatusResponse][horde_sdk.ai_horde_api.apimodels.alchemy._status.AlchemyStatusResponse] |
| /v2/interrogate/submit | 200 | [AlchemyJobSubmitResponse][horde_sdk.ai_horde_api.apimodels.alchemy._submit.AlchemyJobSubmitResponse] |
| /v2/stats/img/models | 200 | [ImageModelStatsResponse][horde_sdk.ai_horde_api.apimodels._stats.ImageModelStatsResponse] |
| /v2/kudos/transfer | 200 | [KudosTransferResponse][horde_sdk.ai_horde_api.apimodels._kudos.KudosTransferResponse] |
| /v2/stats/img/models | 200 | [ImageStatsModelsResponse][horde_sdk.ai_horde_api.apimodels._stats.ImageStatsModelsResponse] |
| /v2/stats/img/totals | 200 | [ImageStatsModelsTotalResponse][horde_sdk.ai_horde_api.apimodels._stats.ImageStatsModelsTotalResponse] |
| /v2/stats/text/models | 200 | [TextModelStatsResponse][horde_sdk.ai_horde_api.apimodels._stats.TextModelStatsResponse] |
| /v2/stats/text/models | 200 | [TextStatsModelResponse][horde_sdk.ai_horde_api.apimodels._stats.TextStatsModelResponse] |
| /v2/stats/text/totals | 200 | [TextStatsModelsTotalResponse][horde_sdk.ai_horde_api.apimodels._stats.TextStatsModelsTotalResponse] |
| /v2/status/heartbeat | 200 | [AIHordeHeartbeatResponse][horde_sdk.ai_horde_api.apimodels._status.AIHordeHeartbeatResponse] |
| /v2/status/models | 200 | [HordeStatusModelsAllResponse][horde_sdk.ai_horde_api.apimodels._status.HordeStatusModelsAllResponse] |
| /v2/status/models/{model_name} | 200 | [HordeStatusModelsSingleResponse][horde_sdk.ai_horde_api.apimodels._status.HordeStatusModelsSingleResponse] |
| /v2/status/news | 200 | [NewsResponse][horde_sdk.ai_horde_api.apimodels._status.NewsResponse] |
| /v2/status/performance | 200 | [HordePerformanceResponse][horde_sdk.ai_horde_api.apimodels._status.HordePerformanceResponse] |
| /v2/users | 200 | [ListUsersDetailsResponse][horde_sdk.ai_horde_api.apimodels._users.ListUsersDetailsResponse] |
| /v2/users/{user_id} | 200 | [UserDetailsResponse][horde_sdk.ai_horde_api.apimodels._users.UserDetailsResponse] |
| /v2/workers | 200 | [AllWorkersDetailsResponse][horde_sdk.ai_horde_api.apimodels.workers._workers.AllWorkersDetailsResponse] |
| /v2/workers/{worker_id} | 200 | [SingleWorkerDetailsResponse][horde_sdk.ai_horde_api.apimodels.workers._workers.SingleWorkerDetailsResponse] |
18 changes: 15 additions & 3 deletions docs/api_to_sdk_payload_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"DELETE": "horde_sdk.ai_horde_api.apimodels.generate.text._status.DeleteTextGenerateRequest",
"GET": "horde_sdk.ai_horde_api.apimodels.generate.text._status.TextGenerateStatusRequest"
},
"/v2/workers/{worker_id}": {
"DELETE": "horde_sdk.ai_horde_api.apimodels.workers._workers.DeleteWorkerRequest",
"PUT": "horde_sdk.ai_horde_api.apimodels.workers._workers.ModifyWorkerRequest",
"GET": "horde_sdk.ai_horde_api.apimodels.workers._workers.SingleWorkerDetailsRequest"
},
"/v2/find_user": {
"GET": "horde_sdk.ai_horde_api.apimodels._find_user.FindUserRequest"
},
Expand Down Expand Up @@ -56,12 +61,19 @@
"/v2/stats/img/totals": {
"GET": "horde_sdk.ai_horde_api.apimodels._stats.ImageStatsModelsTotalRequest"
},
"/v2/kudos/transfer": {
"POST": "horde_sdk.ai_horde_api.apimodels._kudos.KudosTransferRequest"
},
"/v2/users": {
"GET": "horde_sdk.ai_horde_api.apimodels._users.ListUsersDetailsRequest"
},
"/v2/users/{user_id}": {
"PUT": "horde_sdk.ai_horde_api.apimodels._users.ModifyUserRequest",
"GET": "horde_sdk.ai_horde_api.apimodels._users.SingleUserDetailsRequest"
},
"/v2/status/news": {
"GET": "horde_sdk.ai_horde_api.apimodels._status.NewsRequest"
},
"/v2/workers/{worker_id}": {
"GET": "horde_sdk.ai_horde_api.apimodels.workers._workers.SingleWorkerDetailsRequest"
},
"/v2/generate/text/async": {
"POST": "horde_sdk.ai_horde_api.apimodels.generate.text._async.TextGenerateAsyncRequest"
},
Expand Down
21 changes: 15 additions & 6 deletions docs/api_to_sdk_response_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
"/v2/generate/text/status/{id}": {
"200": "horde_sdk.ai_horde_api.apimodels.generate.text._status.TextGenerateStatusResponse"
},
"/v2/workers/{worker_id}": {
"200": "horde_sdk.ai_horde_api.apimodels.workers._workers.SingleWorkerDetailsResponse"
},
"/v2/find_user": {
"200": "horde_sdk.ai_horde_api.apimodels._find_user.FindUserResponse"
"200": "horde_sdk.ai_horde_api.apimodels._users.UserDetailsResponse"
},
"/v2/status/performance": {
"200": "horde_sdk.ai_horde_api.apimodels._status.HordePerformanceResponse"
Expand All @@ -49,17 +52,23 @@
"200": "horde_sdk.ai_horde_api.apimodels.base.JobSubmitResponse"
},
"/v2/stats/img/models": {
"200": "horde_sdk.ai_horde_api.apimodels._stats.ImageModelStatsResponse"
"200": "horde_sdk.ai_horde_api.apimodels._stats.ImageStatsModelsResponse"
},
"/v2/stats/img/totals": {
"200": "horde_sdk.ai_horde_api.apimodels._stats.ImageStatsModelsTotalResponse"
},
"/v2/kudos/transfer": {
"200": "horde_sdk.ai_horde_api.apimodels._kudos.KudosTransferResponse"
},
"/v2/users": {
"200": "horde_sdk.ai_horde_api.apimodels._users.ListUsersDetailsResponse"
},
"/v2/users/{user_id}": {
"200": "horde_sdk.ai_horde_api.apimodels._users.UserDetailsResponse"
},
"/v2/status/news": {
"200": "horde_sdk.ai_horde_api.apimodels._status.NewsResponse"
},
"/v2/workers/{worker_id}": {
"200": "horde_sdk.ai_horde_api.apimodels.workers._workers.SingleWorkerDetailsResponse"
},
"/v2/generate/text/async": {
"200": "horde_sdk.ai_horde_api.apimodels.generate.text._async.TextGenerateAsyncDryRunResponse",
"202": "horde_sdk.ai_horde_api.apimodels.generate.text._async.TextGenerateAsyncResponse"
Expand All @@ -71,7 +80,7 @@
"200": "horde_sdk.ai_horde_api.apimodels.base.JobSubmitResponse"
},
"/v2/stats/text/models": {
"200": "horde_sdk.ai_horde_api.apimodels._stats.TextModelStatsResponse"
"200": "horde_sdk.ai_horde_api.apimodels._stats.TextStatsModelResponse"
},
"/v2/stats/text/totals": {
"200": "horde_sdk.ai_horde_api.apimodels._stats.TextStatsModelsTotalResponse"
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Frequently Asked Questions

> The objects returned by horde_sdk are immutable. If you need to change
> something, you'll need to create a new object with the changes you
> want. See the [section in getting started](../getting_started/#faux-immutability-or-why-cant-i-change-this-attribute) for more info.
> want. See the [section in getting started](getting_started.md#faux-immutability) for more info.
# I don't like types. Why is this library so focused on them?

Expand Down
5 changes: 3 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pip install horde_sdk

- [AIHordeAPIManualClient][horde_sdk.ai_horde_api.ai_horde_clients.AIHordeAPIManualClient] (more control, manual cleanup required)

2. Find the `*Request` object type appropriate to what you want to do. (see also: [naming](../getting_started/#naming))
2. Find the `*Request` object type appropriate to what you want to do. (see also: [naming](getting_started.md#naming))
- These objects types are always found in the `apimodels` namespace of the `*_api` sub package.
- e.g., [ImageGenerateAsyncRequest][horde_sdk.ai_horde_api.apimodels.generate._async.ImageGenerateAsyncRequest]
- **Note** that there is always one or more response types mapped to a request. You can get the default success response `type` like so:
Expand Down Expand Up @@ -147,7 +147,8 @@ A few endpoints, such as `/v2/generate/async` ([ImageGenerateAsyncRequest][horde
trailing underscore, as in `id_`. Ingested json still will work with
the field <span class="title-ref">`id`</span> (its a alias).

### Faux Immutability (or 'Why can't I change this attribute?!')
### Faux Immutability
> 'Why can't I change this attribute?!

- All of the \*Request and \*Response class, and many other classes,
implement faux immutability, and their attributes are **read only**.
Expand Down
2 changes: 0 additions & 2 deletions docs/horde_sdk/_version.md

This file was deleted.

2 changes: 2 additions & 0 deletions docs/horde_sdk/ai_horde_api/apimodels/_kudos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# _kudos
::: horde_sdk.ai_horde_api.apimodels._kudos
2 changes: 2 additions & 0 deletions docs/horde_sdk/ai_horde_api/apimodels/_users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# _users
::: horde_sdk.ai_horde_api.apimodels._users
Loading

0 comments on commit 35de911

Please sign in to comment.