Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8bb6681c7 | |||
| c0d5bff873 | |||
| ff7b33b952 | |||
| 702e62973a | |||
| c3dd3fa7b0 | |||
| b4954b082e | |||
| 54713ed346 | |||
| 673fc0deaf | |||
| f80cc18294 | |||
| e03b26da0f | |||
| 9eef597c8d | |||
| 57acaef1b2 | |||
| aa2382f3b4 | |||
| a8d83c8768 | |||
| e7be5553cc | |||
| 895b17390d | |||
| 9145ac1bb4 | |||
| 44d0315059 | |||
| b3045bf724 | |||
| 90c97d3f54 |
@ -15,12 +15,12 @@ jobs:
|
|||||||
GITHUB: ${{ secrets.GITHUB }}
|
GITHUB: ${{ secrets.GITHUB }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.14'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
@ -85,7 +85,7 @@ jobs:
|
|||||||
|
|
||||||
# Ergebnisse als Artefakte speichern
|
# Ergebnisse als Artefakte speichern
|
||||||
- name: Upload results as artifacts
|
- name: Upload results as artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: quality-reports
|
name: quality-reports
|
||||||
path: /tmp/results
|
path: /tmp/results
|
||||||
|
|||||||
@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Verify Docker installation
|
- name: Verify Docker installation
|
||||||
run: docker --version
|
run: docker --version
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
FROM python:3.13.3-slim
|
FROM python:3.14.2-slim
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
32
src/main.py
32
src/main.py
@ -58,7 +58,7 @@ async def on_ready():
|
|||||||
orientation="portrait or landscape (Standard: portrait)",
|
orientation="portrait or landscape (Standard: portrait)",
|
||||||
seed="Optional seed (integer). If empty, a random one will be generated",
|
seed="Optional seed (integer). If empty, a random one will be generated",
|
||||||
)
|
)
|
||||||
# pylint: disable=too-many-locals,too-many-return-statements
|
# pylint: disable=too-many-locals,too-many-return-statements,too-many-statements
|
||||||
async def generate(
|
async def generate(
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
prompt: str,
|
prompt: str,
|
||||||
@ -159,16 +159,20 @@ async def generate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_time = time.monotonic()
|
start_time = time.monotonic()
|
||||||
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.post(
|
async with session.post(
|
||||||
"https://image.novelai.net/ai/generate-image",
|
"https://image.novelai.net/ai/generate-image",
|
||||||
json=payload,
|
json=payload,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
timeout=aiohttp.ClientTimeout(total=120),
|
timeout=aiohttp.ClientTimeout(total=120),
|
||||||
) as response:
|
) as response:
|
||||||
response_bytes = await response.read()
|
response_bytes = await response.read()
|
||||||
status_code = response.status
|
status_code = response.status
|
||||||
|
except aiohttp.TimeoutError:
|
||||||
|
await interaction.followup.send("Error: the request timed out.")
|
||||||
|
except aiohttp.ClientError as e:
|
||||||
|
await interaction.followup.send(f"Error: {e}")
|
||||||
|
|
||||||
duration = time.monotonic() - start_time
|
duration = time.monotonic() - start_time
|
||||||
logger.info("Image creation took %.2f seconds", duration)
|
logger.info("Image creation took %.2f seconds", duration)
|
||||||
@ -214,9 +218,11 @@ async def generate(
|
|||||||
except Exception: # pylint: disable=W0718
|
except Exception: # pylint: disable=W0718
|
||||||
error_data = "error message unreadable"
|
error_data = "error message unreadable"
|
||||||
|
|
||||||
error_message = f"Error {status_code} at API-request.\n" f"Answer: {error_data}\n"
|
error_message = (
|
||||||
|
f"Error {status_code} at API-request.\n" f"Answer: {error_data}\n"
|
||||||
|
)
|
||||||
|
|
||||||
await interaction.followup.send(error_message)
|
await interaction.followup.send(error_message)
|
||||||
|
|
||||||
|
|
||||||
bot.run(BOT_TOKEN)
|
bot.run(BOT_TOKEN)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user