-
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.
Merge pull request #9 from Haidra-Org/mid-alpha-renames-and-docs
docs: better `getting started`, refactor: class renames for clarity
- Loading branch information
Showing
30 changed files
with
627 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Template | ||
# Copy this file to .env and fill in the values | ||
AI_HORDE_URL="https://aihorde.net/api/" | ||
AI_HORDE_DEV_URL="http://localhost:7001/api/" | ||
|
||
AI_HORDE_DEV_APIKEY="devkey" | ||
|
||
RATINGS_URL="https://ratings.aihorde.net/api/" | ||
RATINGS_DEV_URL="http://localhost:7002/api/" | ||
|
||
RATINGS_DEV_APIKEY=${AI_HORDE_DEV_APIKEY} |
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
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,83 @@ | ||
# Example Clients | ||
|
||
See `examples/` for a complete list. These examples are all made in mind with your current working directory as `horde_sdk` (e.g., `cd horde_sdk`). | ||
|
||
## Simple Client (sync) Example | ||
From `examples/ai_horde_client/aihorde_simple_client_example.py`: | ||
|
||
``` python | ||
from horde_sdk.ai_horde_api.ai_horde_clients import AIHordeAPISimpleClient | ||
from horde_sdk.ai_horde_api.apimodels import ImageGenerateAsyncRequest, ImageGeneration | ||
|
||
|
||
def simple_generate_example() -> None: | ||
simple_client = AIHordeAPISimpleClient() | ||
|
||
generations: list[ImageGeneration] = simple_client.image_generate_request( | ||
ImageGenerateAsyncRequest( | ||
apikey="0000000000", | ||
prompt="A cat in a hat", | ||
models=["Deliberate"], | ||
), | ||
) | ||
|
||
image = simple_client.generation_to_image(generations[0]) | ||
|
||
image.save("cat_in_hat.png") | ||
|
||
if __name__ == "__main__": | ||
simple_generate_example() | ||
``` | ||
|
||
## Simple Client (using asyncio) Example | ||
From `examples/ai_horde_client/async_aihorde_simple_client_example.py`: | ||
|
||
``` python | ||
|
||
import asyncio | ||
|
||
from horde_sdk.ai_horde_api.ai_horde_clients import AIHordeAPISimpleClient | ||
from horde_sdk.ai_horde_api.apimodels import ImageGenerateAsyncRequest, ImageGeneration | ||
|
||
|
||
async def async_simple_generate_example() -> None: | ||
simple_client = AIHordeAPISimpleClient() | ||
|
||
generations: list[ImageGeneration] = await simple_client.async_image_generate_request( | ||
ImageGenerateAsyncRequest( | ||
apikey="0000000000", | ||
prompt="A cat in a hat", | ||
models=["Deliberate"], | ||
), | ||
) | ||
|
||
image = simple_client.generation_to_image(generations[0]) | ||
image.save("cat_in_hat.png") | ||
|
||
# Do 2 requests at once. | ||
multi_generations: tuple[list[ImageGeneration], list[ImageGeneration]] = await asyncio.gather( | ||
simple_client.async_image_generate_request( | ||
ImageGenerateAsyncRequest( | ||
apikey="0000000000", | ||
prompt="A cat in a hat", | ||
models=["Deliberate"], | ||
), | ||
), | ||
simple_client.async_image_generate_request( | ||
ImageGenerateAsyncRequest( | ||
apikey="0000000000", | ||
prompt="A cat in a hat", | ||
models=["Deliberate"], | ||
), | ||
), | ||
) | ||
|
||
multi_image_1 = simple_client.generation_to_image(multi_generations[0][0]) | ||
multi_image_1.save("cat_in_hat_multi_1.png") | ||
|
||
multi_image_2 = simple_client.generation_to_image(multi_generations[1][0]) | ||
|
||
multi_image_2.save("cat_in_hat_multi_2.png") | ||
if __name__ == "__main__": | ||
asyncio.run(async_simple_generate_example()) | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
title: horde_sdk | ||
title: Horde SDK Code Reference |
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
# ai_horde_clients | ||
::: horde_sdk.ai_horde_api.ai_horde_clients |
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
# generic_clients | ||
::: horde_sdk.generic_api.generic_clients |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.