chore: nettoyage .gitignore - retrait venv, __pycache__, .env, data, logs, modèles du tracking
This commit is contained in:
parent
7333a22bcd
commit
604a5affe0
9231 changed files with 1244 additions and 1601201 deletions
37
core/content.py
Normal file
37
core/content.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"""Content preparation for LLM input."""
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger('Beta')
|
||||
|
||||
|
||||
def prepare_message_content(message) -> str:
|
||||
"""Prepare message content for LLM by normalizing mentions and attachments."""
|
||||
if not message:
|
||||
return ""
|
||||
|
||||
content = message.content
|
||||
|
||||
# Replace channel mentions <#123> -> #general
|
||||
for channel in message.channel_mentions:
|
||||
content = content.replace(f'<#{channel.id}>', f'#{channel.name}')
|
||||
|
||||
# Replace role mentions <@&123> -> @admin
|
||||
for role in message.role_mentions:
|
||||
content = content.replace(f'<@&{role.id}>', f'@{role.name}')
|
||||
|
||||
# Replace user mentions <@123> or <@!123> -> @User
|
||||
for mention in message.mentions:
|
||||
content = content.replace(f'<@{mention.id}>', f'@{mention.display_name}')
|
||||
content = content.replace(f'<@!{mention.id}>', f'@{mention.display_name}')
|
||||
|
||||
# Handle attachments
|
||||
if message.attachments:
|
||||
for attachment in message.attachments:
|
||||
if attachment.content_type and attachment.content_type.startswith('image/'):
|
||||
label = f"[Image: {attachment.filename}]"
|
||||
else:
|
||||
label = f"[Fichier: {attachment.filename}]"
|
||||
content = f"{content} {label}".strip() if content else label
|
||||
|
||||
return content.strip()
|
||||
Loading…
Add table
Add a link
Reference in a new issue