Skip to content

Commit

Permalink
Merge pull request #102 from LlmKira/dev
Browse files Browse the repository at this point in the history
doc
  • Loading branch information
sudoskys authored Jan 5, 2025
2 parents 969aaab + f33e507 commit 07dad0d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def main():
),
Character(
prompt="1girl, fox ears, fox tail, white hair, white tail, white ears",
uc="white hair",
uc="black hair",
center=PositionMap.D2
)
],
Expand Down
Binary file modified playground/augment-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions playground/augment-image.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def generate(
agent = AugmentImageInfer.build(
req_type=request_type,
image=image,
mood=Moods.Shy,
# mood=Moods.Shy,
prompt="",
defry=0,
)
Expand All @@ -45,7 +45,7 @@ async def generate(
print(f"Error: {e.message}")
return None
else:
print(f"Meta: {result.meta}")
print(f"Meta: {result.meta.endpoint}")
_res: ImageGenerateResp
file = result.files[0]
with open(f"{pathlib.Path(__file__).stem}.png", "wb") as f:
Expand Down
8 changes: 4 additions & 4 deletions playground/generate_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pydantic import SecretStr

from novelai_python import APIError, LoginCredential
from novelai_python import GenerateImageInfer, ImageGenerateResp, JwtCredential
from novelai_python import GenerateImageInfer, ImageGenerateResp, ApiCredential
from novelai_python.sdk.ai.generate_image import Action, Model, Sampler, Character, UCPreset, Params
from novelai_python.sdk.ai.generate_image.schema import PositionMap
from novelai_python.utils.useful import enum_to_list
Expand All @@ -24,7 +24,7 @@ async def generate(
jwt = os.getenv("NOVELAI_JWT", None)
if jwt is None:
raise ValueError("NOVELAI_JWT is not set in `.env` file, please create one and set it")
credential = JwtCredential(jwt_token=SecretStr(jwt))
credential = ApiCredential(api_token=SecretStr(jwt))
"""Or you can use the login credential to get the renewable jwt token"""
_login_credential = LoginCredential(
username=os.getenv("NOVELAI_USER"),
Expand Down Expand Up @@ -57,7 +57,7 @@ async def generate(
),
Character(
prompt="1girl, fox ears, fox tail, white hair, white tail, white ears",
uc="white hair",
uc="black hair",
center=PositionMap.D2
)
],
Expand Down Expand Up @@ -91,7 +91,7 @@ async def direct_use():
that's pydantic!
:return:
"""
credential = JwtCredential(jwt_token=SecretStr("pst-5555"))
credential = ApiCredential(api_token=SecretStr("pst-5555"))
result = await GenerateImageInfer(
input="1girl",
model=Model.NAI_DIFFUSION_4_CURATED_PREVIEW,
Expand Down
4 changes: 2 additions & 2 deletions playground/generate_image_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pydantic import SecretStr

from novelai_python import APIError, LoginCredential
from novelai_python import GenerateImageInfer, ImageGenerateResp, JwtCredential
from novelai_python import GenerateImageInfer, ImageGenerateResp, ApiCredential
from novelai_python.sdk.ai.generate_image import Action, Sampler
from novelai_python.utils.useful import enum_to_list

Expand All @@ -25,7 +25,7 @@ async def generate(
jwt = os.getenv("NOVELAI_JWT", None)
if jwt is None:
raise ValueError("NOVELAI_JWT is not set in `.env` file, please create one and set it")
credential = JwtCredential(jwt_token=SecretStr(jwt))
credential = ApiCredential(api_token=SecretStr(jwt))
"""Or you can use the login credential to get the jwt token"""
_login_credential = LoginCredential(
username=os.getenv("NOVELAI_USER"),
Expand Down
2 changes: 1 addition & 1 deletion src/novelai_python/credential/ApiToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ async def get_session(self, timeout: int = 180, update_headers: dict = None):
@field_validator('api_token')
def check_api_token(cls, v: SecretStr):
if not v.get_secret_value().startswith("pst"):
logger.warning("api token should start with pst-")
logger.warning("api token should start with `pst-`")
return v

0 comments on commit 07dad0d

Please sign in to comment.