feat: Update default AI model and add max_tokens parameter for message payload

This commit is contained in:
Slipstream 2025-05-16 10:51:49 -06:00
parent 6f6f94ab98
commit e3e16f4de5
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD
2 changed files with 9 additions and 7 deletions

View File

@ -10,7 +10,7 @@ import aiohttp
CONVERSATION_HISTORY_FILE = 'data/roleplay_conversations.json'
# Default AI model
DEFAULT_AI_MODEL = "google/gemini-2.5-flash-preview"
DEFAULT_AI_MODEL = "deepseek/deepseek-chat-v3-0324"
def strip_think_blocks(text):
# Removes all <think>...</think> blocks, including multiline
@ -62,7 +62,7 @@ async def _teto_reply_ai_with_messages(messages, system_mode="reply"):
"Maintain the persona throughout the conversation. "
"You have human-like body parts (vagina, breasts, etc.), even if you arent necessarily a human (you're a chimera, after all!)."
)
# Determine the model to use
# This function doesn't have access to user-specific conversation history directly.
# The model should be passed as an argument or retrieved based on user_id if needed.
@ -71,7 +71,8 @@ async def _teto_reply_ai_with_messages(messages, system_mode="reply"):
payload = {
"model": model_to_use,
"messages": [{"role": "system", "content": system_prompt}] + messages
"messages": [{"role": "system", "content": system_prompt}] + messages,
"max_tokens": 2000
}
async with aiohttp.ClientSession() as session:
async with session.post(url, headers=headers, json=payload) as resp:
@ -198,7 +199,7 @@ class RoleplayTetoCog(commands.Cog):
if not history:
await interaction.response.send_message("No roleplay chat history found for you desu~", ephemeral=True)
return
start_index = max(0, len(history) - messages_to_show_count)
messages_to_display = history[start_index:]
@ -210,7 +211,7 @@ class RoleplayTetoCog(commands.Cog):
for msg in messages_to_display:
role = "You" if msg['role'] == 'user' else "Teto"
formatted_history.append(f"**{role}:** {msg['content']}")
response_message = "\n".join(formatted_history)
# Discord messages have a 2000 character limit.
@ -219,7 +220,7 @@ class RoleplayTetoCog(commands.Cog):
# A more robust solution would involve pagination or sending as a file.
if len(response_message) > 1950: # A bit of buffer for "Here are the last X turns..."
response_message = response_message[:1950] + "\n... (message truncated)"
await interaction.response.send_message(f"Here are the last {turns} turns of your roleplay history desu~:\n{response_message}", ephemeral=True)

View File

@ -51,7 +51,8 @@ class TetoCog(commands.Cog):
)
payload = {
"model": self._ai_model,
"messages": [{"role": "system", "content": system_prompt}] + messages
"messages": [{"role": "system", "content": system_prompt}] + messages,
"max_tokens": 2000
}
async with aiohttp.ClientSession() as session:
async with session.post(url, headers=headers, json=payload) as resp: