Skip to content

Commit a3dd0bf

Browse files
AmbratolmAmbratolm
authored andcommitted
Fixed AI response char limit prob
1 parent 96cb31f commit a3dd0bf

File tree

3 files changed

+37
-21
lines changed

3 files changed

+37
-21
lines changed

bot/cogs/game_cogs/inventory_cog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async def store(self, interaction: Interaction, item_id: str = ""):
103103
)
104104
return
105105
embed = EmbedX.info(
106-
emoji=item.alt_emoji,
106+
emoji=item.emoji or item.alt_emoji,
107107
title=item.name,
108108
description=item.description,
109109
)

db/Item.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ class ItemStack(Model):
5858
id="dagger",
5959
name="Dagger",
6060
description="A lightweight, curved dagger for quick strikes.",
61-
emoji="<:dagger:1350653129498165259>",
61+
emoji="<:dagger:1350710430519267359>",
6262
alt_emoji="🗡",
6363
icon_url="https://cdn.discordapp.com/attachments/1348859490203734057/1350655923160354907/dagger.png?ex=67d787da&is=67d6365a&hm=582b04b4d8dce9de72c15630cd3f4e83ca35db88aa01dc688876c510fdddb7f7&",
6464
type=ItemType.EQUIPPABLE,
6565
attack_bonus=1,
6666
speed_bonus=2,
67-
price=10,
67+
price=10000,
6868
),
6969
Item(
7070
id="short_sword",
@@ -76,7 +76,7 @@ class ItemStack(Model):
7676
type=ItemType.EQUIPPABLE,
7777
attack_bonus=2,
7878
speed_bonus=1,
79-
price=25,
79+
price=25000,
8080
),
8181
Item(
8282
id="sword",
@@ -88,7 +88,7 @@ class ItemStack(Model):
8888
type=ItemType.EQUIPPABLE,
8989
attack_bonus=3,
9090
speed_bonus=0,
91-
price=35,
91+
price=35000,
9292
),
9393
Item(
9494
id="scimitar",
@@ -100,7 +100,7 @@ class ItemStack(Model):
100100
type=ItemType.EQUIPPABLE,
101101
attack_bonus=3,
102102
speed_bonus=-1,
103-
price=40,
103+
price=40000,
104104
),
105105
Item(
106106
id="spear",
@@ -112,7 +112,7 @@ class ItemStack(Model):
112112
type=ItemType.EQUIPPABLE,
113113
attack_bonus=2,
114114
defense_bonus=1,
115-
price=30,
115+
price=30000,
116116
),
117117
Item(
118118
id="axe",
@@ -124,7 +124,7 @@ class ItemStack(Model):
124124
type=ItemType.EQUIPPABLE,
125125
attack_bonus=3,
126126
defense_bonus=-1,
127-
price=35,
127+
price=35000,
128128
),
129129
Item(
130130
id="mace",
@@ -136,7 +136,7 @@ class ItemStack(Model):
136136
type=ItemType.EQUIPPABLE,
137137
attack_bonus=2,
138138
defense_bonus=1,
139-
price=30,
139+
price=30000,
140140
),
141141
Item(
142142
id="bow",
@@ -148,7 +148,7 @@ class ItemStack(Model):
148148
type=ItemType.EQUIPPABLE,
149149
attack_bonus=2,
150150
speed_bonus=1,
151-
price=35,
151+
price=35000,
152152
),
153153
# Armor
154154
Item(
@@ -161,7 +161,7 @@ class ItemStack(Model):
161161
type=ItemType.EQUIPPABLE,
162162
defense_bonus=2,
163163
speed_bonus=-1,
164-
price=25,
164+
price=25000,
165165
),
166166
Item(
167167
id="helmet",
@@ -172,7 +172,7 @@ class ItemStack(Model):
172172
icon_url="https://cdn.discordapp.com/attachments/1348859490203734057/1350655920371404911/helmet.png?ex=67d787d9&is=67d63659&hm=ccebe366e9ec93bfcc9679dc9f2bfc3e75b7e4a9a4ffa22393afcc5d5f055c8d&",
173173
type=ItemType.EQUIPPABLE,
174174
defense_bonus=1,
175-
price=15,
175+
price=15000,
176176
),
177177
Item(
178178
id="armor",
@@ -184,7 +184,7 @@ class ItemStack(Model):
184184
type=ItemType.EQUIPPABLE,
185185
defense_bonus=2,
186186
speed_bonus=0,
187-
price=30,
187+
price=30000,
188188
),
189189
Item(
190190
id="chainmail",
@@ -196,7 +196,7 @@ class ItemStack(Model):
196196
type=ItemType.EQUIPPABLE,
197197
defense_bonus=3,
198198
speed_bonus=-1,
199-
price=45,
199+
price=45000,
200200
),
201201
# Footwear
202202
Item(
@@ -208,7 +208,7 @@ class ItemStack(Model):
208208
icon_url="https://cdn.discordapp.com/attachments/1348859490203734057/1350655932253868114/sandals.png?ex=67d787dc&is=67d6365c&hm=2a86819852e1e282b35e62d142a40947e34f84db1e0960c274b9220aef7b312c&",
209209
type=ItemType.EQUIPPABLE,
210210
speed_bonus=1,
211-
price=10,
211+
price=10000,
212212
),
213213
Item(
214214
id="shoes",
@@ -219,7 +219,7 @@ class ItemStack(Model):
219219
icon_url="https://cdn.discordapp.com/attachments/1348859490203734057/1350655933205839964/shoes.png?ex=67d787dc&is=67d6365c&hm=22eb643751b16521a77c1a0c3b3bb8b8805ca0bff36e4af09c2b0e341c4d629a&",
220220
type=ItemType.EQUIPPABLE,
221221
speed_bonus=2,
222-
price=20,
222+
price=20000,
223223
),
224224
Item(
225225
id="boots",
@@ -231,19 +231,19 @@ class ItemStack(Model):
231231
type=ItemType.EQUIPPABLE,
232232
speed_bonus=1,
233233
defense_bonus=1,
234-
price=30,
234+
price=30000,
235235
),
236236
# Consumables
237237
Item(
238238
id="potion",
239239
name="Potion",
240240
description="A basic potion that restores health.",
241-
emoji="<:potion:1350653172087263363>",
241+
emoji="<:potion:1350710440950366218>",
242242
alt_emoji="🧪",
243243
icon_url="https://cdn.discordapp.com/attachments/1348859490203734057/1350655931947417672/potion.png?ex=67d787dc&is=67d6365c&hm=87bec8eb5769212f444e990d27a245f014dc865eb4fb23b97fa718f2212fe214&",
244244
type=ItemType.CONSUMABLE,
245245
health_bonus=3,
246-
price=10,
246+
price=200,
247247
),
248248
Item(
249249
id="honeypot",
@@ -254,6 +254,18 @@ class ItemStack(Model):
254254
icon_url="https://cdn.discordapp.com/attachments/1348859490203734057/1350655931137921036/honeypot.png?ex=67d787db&is=67d6365b&hm=853f6cc0a38c04f416c2eaab15e062009318c4a4a44221b10ee65c2e1c11652d&",
255255
type=ItemType.CONSUMABLE,
256256
energy_bonus=3,
257-
price=15,
257+
price=200,
258+
),
259+
Item(
260+
id="cookie",
261+
name="Cookie",
262+
description="A delicious cookie that restores a small amount of health and energy.",
263+
emoji="",
264+
alt_emoji="🍪",
265+
icon_url="",
266+
type=ItemType.CONSUMABLE,
267+
health_bonus=1,
268+
energy_bonus=1,
269+
price=20,
258270
),
259271
]

utils/ai.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ActAi(BaseModel):
2222
api_key: NonEmptyStr
2323
instructions: NonEmptyStr | list[NonEmptyStr] | None = None
2424
model_name: str = Field(alias="model", default="gemini-2.0-flash")
25+
response_char_limit: int = 4000
2526

2627
_client: Client | None = None
2728
_config: GenerateContentConfig | None = None
@@ -52,7 +53,10 @@ async def prompt(self, text: str, file: ActFile | None = None) -> str | None:
5253
Part.from_bytes(data=file.data, mime_type=file.mime_type or "")
5354
)
5455
response = await chat.send_message(message, self._config)
55-
return response.text if response else None
56+
response_text = response.text if response else None
57+
if response_text and len(response_text) > self.response_char_limit:
58+
response_text = response_text[: (self.response_char_limit - 3)] + "..."
59+
return response_text
5660

5761
# ----------------------------------------------------------------------------------------------------
5862

0 commit comments

Comments
 (0)