-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: asyncio support, subpkg shuffle, remove builtin shadowing
Additionally: - adds a couple of examples to `examples/` - renamed CancelImageGenerateRequest to DeleteImageGenerateRequest
- Loading branch information
Showing
25 changed files
with
721 additions
and
3,904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from horde_sdk.ai_horde_api import AIHordeAPIClient | ||
from horde_sdk.ai_horde_api.apimodels import ImageGenerateAsyncRequest | ||
from horde_sdk.generic_api import RequestErrorResponse | ||
|
||
|
||
def do_generate_check(ai_horde_api_client: AIHordeAPIClient) -> None: | ||
pass | ||
|
||
|
||
def main() -> None: | ||
"""Just a proof of concept - but several other pieces of functionality exist.""" | ||
|
||
ai_horde_api_client = AIHordeAPIClient() | ||
|
||
image_generate_async_request = ImageGenerateAsyncRequest( | ||
apikey="0000000000", | ||
prompt="A cat in a hat", | ||
models=["Deliberate"], | ||
) | ||
|
||
response = ai_horde_api_client.submit_request( | ||
image_generate_async_request, | ||
image_generate_async_request.get_success_response_type(), | ||
) | ||
|
||
if isinstance(response, RequestErrorResponse): | ||
print(f"Error: {response.message}") | ||
return | ||
|
||
print(f"Job ID: {response.id_}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from __future__ import annotations | ||
|
||
import asyncio | ||
|
||
from horde_sdk.ai_horde_api import AIHordeAPIClient | ||
from horde_sdk.ai_horde_api.apimodels import ImageGenerateAsyncRequest | ||
from horde_sdk.generic_api import RequestErrorResponse | ||
|
||
|
||
async def main() -> None: | ||
print("Starting...") | ||
ai_horde_api_client = AIHordeAPIClient() | ||
|
||
image_generate_async_request = ImageGenerateAsyncRequest( | ||
apikey="0000000000", | ||
prompt="A cat in a hat", | ||
models=["Deliberate"], | ||
) | ||
|
||
response = await ai_horde_api_client.async_submit_request( | ||
image_generate_async_request, | ||
image_generate_async_request.get_success_response_type(), | ||
) | ||
|
||
if isinstance(response, RequestErrorResponse): | ||
print(f"Error: {response.message}") | ||
return | ||
|
||
# Keep making ImageGenerateCheckRequests until the job is done. | ||
while True: | ||
check_response = await ai_horde_api_client.async_get_generate_check( | ||
apikey="0000000000", | ||
generation_id=response.id_, | ||
) | ||
|
||
if isinstance(check_response, RequestErrorResponse): | ||
print(f"Error: {check_response.message}") | ||
return | ||
|
||
if check_response.done: | ||
break | ||
|
||
await asyncio.sleep(5) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from horde_sdk.ai_horde_api.ai_horde_client import ( | ||
AIHordeAPIClient, | ||
) | ||
from horde_sdk.ai_horde_api.consts import ( | ||
ALCHEMY_FORMS, | ||
GENERATION_STATE, | ||
KNOWN_SAMPLERS, | ||
KNOWN_SOURCE_PROCESSING, | ||
WORKER_TYPE, | ||
) | ||
from horde_sdk.ai_horde_api.endpoints import ( | ||
AI_HORDE_BASE_URL, | ||
AI_HORDE_API_URL_Literals, | ||
) | ||
|
||
__all__ = [ | ||
"AIHordeAPIClient", | ||
"AI_HORDE_BASE_URL", | ||
"AI_HORDE_API_URL_Literals", | ||
"ALCHEMY_FORMS", | ||
"GENERATION_STATE", | ||
"KNOWN_SAMPLERS", | ||
"KNOWN_SOURCE_PROCESSING", | ||
"WORKER_TYPE", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.