Compare commits
2 Commits
feature/de
...
feature/lo
| Author | SHA1 | Date | |
|---|---|---|---|
| 461343cf80 | |||
| 920b616468 |
@@ -122,7 +122,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)
|
||||||
@@ -176,10 +176,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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -387,16 +392,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:
|
||||||
|
|||||||
Reference in New Issue
Block a user