mirror of
https://github.com/csd4ni3l/meow-bot.git
synced 2026-01-01 04:23:49 +01:00
Update default model in .env.example, add AI context from conversation history
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
OPENROUTER_API_KEY=API_KEY
|
OPENROUTER_API_KEY=API_KEY
|
||||||
OPENROUTER_MODEL=qwen/qwen3-32b
|
OPENROUTER_MODEL=openai/gpt-5-mini
|
||||||
OPENROUTER_URL=https://ai.hackclub.com/proxy/v1
|
OPENROUTER_URL=https://ai.hackclub.com/proxy/v1
|
||||||
BOT_TOKEN=BOT_TOKEN
|
BOT_TOKEN=BOT_TOKEN
|
||||||
APP_TOKEN=APP_TOKEN
|
APP_TOKEN=APP_TOKEN
|
||||||
9
app.py
9
app.py
@@ -220,12 +220,13 @@ def message_handler(event, say, client, message):
|
|||||||
message_ts = message["ts"]
|
message_ts = message["ts"]
|
||||||
|
|
||||||
if event.get("channel_type") == "im" and "bot_id" not in event:
|
if event.get("channel_type") == "im" and "bot_id" not in event:
|
||||||
|
messages = [{"role": "system", "content": AI_SYSTEM_PROMPT}]
|
||||||
|
messages.extend([{"role": "assistant" if "bot_id" in msg else "user", "content": msg.get("text", "")} for msg in client.conversations_history(channel=channel_id, limit=AI_CONTEXT_MSG_LIMIT).get("messages", [])])
|
||||||
|
messages.append({"role": "user", "content": message_text})
|
||||||
|
|
||||||
response = openrouter_client.chat.send(
|
response = openrouter_client.chat.send(
|
||||||
model=os.getenv("OPENROUTER_MODEL"),
|
model=os.getenv("OPENROUTER_MODEL"),
|
||||||
messages=[
|
messages=messages,
|
||||||
{"role": "assistant", "content": AI_SYSTEM_PROMPT},
|
|
||||||
{"role": "user", "content": message_text}
|
|
||||||
],
|
|
||||||
stream=False,
|
stream=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ MEOW_PHRASES = [
|
|||||||
"cat"
|
"cat"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
AI_CONTEXT_MSG_LIMIT = 10
|
||||||
|
|
||||||
CAT_EMOJI = "cat"
|
CAT_EMOJI = "cat"
|
||||||
DUCK_EMOJI = "duck"
|
DUCK_EMOJI = "duck"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user