4 Commits

Author SHA1 Message Date
200500ecd1 Merge branch 'feature/deepseek-v4-api-updates'
* feature/deepseek-v4-api-updates:
  update deepseek (async model) for deepseek v4 api updates
  update bender (sync model) for deepseek v4 api updates
2026-05-24 20:13:24 -07:00
d8d2c43ade Merge branch 'feature/longer-messages'
* feature/longer-messages:
  expand length of allowed responses before compacting
2026-05-24 20:13:01 -07:00
461343cf80 expand length of allowed responses before compacting 2026-05-24 18:08:49 -07:00
920b616468 bender 🔥 not 👀 2026-05-17 18:25:04 -07:00
2 changed files with 16 additions and 6 deletions

View File

@@ -448,7 +448,7 @@ def make_app(ws):
) )
return return
client.reactions_add(channel=channel, timestamp=message_ts, name="eyes") client.reactions_add(channel=channel, timestamp=message_ts, name="fire")
try: try:
ws_logger.info("DeepSeek API call starting model=%s", deepseek_model) ws_logger.info("DeepSeek API call starting model=%s", deepseek_model)
@@ -491,10 +491,10 @@ def make_app(ws):
finally: finally:
try: try:
client.reactions_remove( client.reactions_remove(
channel=channel, timestamp=message_ts, name="eyes" channel=channel, timestamp=message_ts, name="fire"
) )
except Exception: except Exception:
ws_logger.warning("Failed to remove eyes reaction", exc_info=True) ws_logger.warning("Failed to remove fire reaction", exc_info=True)
return slack_app return slack_app

View File

@@ -25,7 +25,12 @@ logger = logging.getLogger(__name__)
# Constants # Constants
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
DEEPSEEK_TIMEOUT = 120 # seconds DEEPSEEK_TIMEOUT = 120 # seconds
MAX_INLINE_LENGTH = 2800 # characters MAX_INLINE_LENGTH = 10_000 # characters
def _has_code_snippet(text: str) -> bool:
"""Return True if the text contains a fenced code block."""
return "```" in text
MAX_TOOL_TURNS = 5 # max tool-call back-and-forths with DeepSeek MAX_TOOL_TURNS = 5 # max tool-call back-and-forths with DeepSeek
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -488,16 +493,21 @@ def make_app(ws):
reply_text = md_to_slack(reply_text) reply_text = md_to_slack(reply_text)
if len(reply_text) <= MAX_INLINE_LENGTH: if len(reply_text) <= MAX_INLINE_LENGTH and not _has_code_snippet(reply_text):
await say(text=reply_text, thread_ts=thread_ts) await say(text=reply_text, thread_ts=thread_ts)
else: else:
initial_comment = (
"The response contains a code snippet, which doesn't render well inline."
if _has_code_snippet(reply_text)
else "The response was too long for an inline message."
)
await client.files_upload_v2( await client.files_upload_v2(
channel=channel, channel=channel,
thread_ts=thread_ts, thread_ts=thread_ts,
content=reply_text, content=reply_text,
filename="response.txt", filename="response.txt",
title="DeepSeek Response", title="DeepSeek Response",
initial_comment="The response was too long for an inline message.", initial_comment=initial_comment,
) )
except Exception as exc: except Exception as exc: