feat: show AI progress and configure prompt directory
This commit is contained in:
@@ -4,7 +4,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import AsyncMock, MagicMock, call, patch
|
||||
|
||||
from app.agentic import (
|
||||
AgentSessionHandle,
|
||||
@@ -302,7 +302,7 @@ class AiCommandTests(unittest.IsolatedAsyncioTestCase):
|
||||
handle,
|
||||
ctx.reply.return_value,
|
||||
)
|
||||
ctx.message.react.assert_not_awaited()
|
||||
self.assertEqual(ctx.message.react.await_args_list, [call("🤔"), call(None)])
|
||||
|
||||
async def test_invalid_syntax_only_dislikes(self) -> None:
|
||||
ctx = self._ctx(".ds .th")
|
||||
@@ -310,7 +310,7 @@ class AiCommandTests(unittest.IsolatedAsyncioTestCase):
|
||||
with self.assertLogs("app.commands.builtins", level="ERROR"):
|
||||
await ai(ctx)
|
||||
|
||||
ctx.message.react.assert_awaited_once_with("👎")
|
||||
self.assertEqual(ctx.message.react.await_args_list, [call("🤔"), call("👎")])
|
||||
ctx.reply.assert_not_awaited()
|
||||
|
||||
async def test_agent_error_only_dislikes(self) -> None:
|
||||
@@ -322,9 +322,27 @@ class AiCommandTests(unittest.IsolatedAsyncioTestCase):
|
||||
with self.assertLogs("app.commands.builtins", level="ERROR"):
|
||||
await ai(ctx)
|
||||
|
||||
ctx.message.react.assert_awaited_once_with("👎")
|
||||
self.assertEqual(ctx.message.react.await_args_list, [call("🤔"), call("👎")])
|
||||
ctx.reply.assert_not_awaited()
|
||||
|
||||
async def test_thinking_reaction_failure_does_not_stop_ai(self) -> None:
|
||||
ctx = self._ctx()
|
||||
ctx.message.react.side_effect = [RuntimeError("reactions disabled"), None]
|
||||
|
||||
with (
|
||||
patch(
|
||||
"app.commands.builtins.run_agent_turn",
|
||||
AsyncMock(
|
||||
return_value=SimpleNamespace(answer="answer", handle=MagicMock())
|
||||
),
|
||||
),
|
||||
self.assertLogs("app.commands.builtins", level="ERROR"),
|
||||
):
|
||||
await ai(ctx)
|
||||
|
||||
ctx.reply.assert_awaited_once_with("answer")
|
||||
self.assertEqual(ctx.message.react.await_args_list, [call("🤔"), call(None)])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.config import _parse_ai_config, _parse_elevenlabs_config
|
||||
@@ -65,6 +66,7 @@ class ConfigAiTests(unittest.TestCase):
|
||||
"DEEPSEEK_MODEL": "env-ds-model",
|
||||
"AI_WEB_PAGE_TIMEOUT_SECONDS": "30",
|
||||
"AI_WEB_PAGE_MAX_CHARS": "54321",
|
||||
"AI_PROMPT_DIR": "alternate-prompts",
|
||||
}
|
||||
with patch.dict("os.environ", env, clear=True):
|
||||
config = _parse_ai_config({})
|
||||
@@ -75,6 +77,7 @@ class ConfigAiTests(unittest.TestCase):
|
||||
self.assertEqual(config.deepseek.model, "env-ds-model")
|
||||
self.assertEqual(config.web_page_timeout_seconds, 30)
|
||||
self.assertEqual(config.web_page_max_chars, 54321)
|
||||
self.assertEqual(config.prompt_dir, Path("alternate-prompts"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -26,6 +26,9 @@ use_qr = true
|
||||
[elevenlabs]
|
||||
api_key = "test-key"
|
||||
model_id = "scribe_v2"
|
||||
|
||||
[ai]
|
||||
prompt_dir = "custom-prompts"
|
||||
""".strip(),
|
||||
encoding="utf-8",
|
||||
)
|
||||
@@ -38,7 +41,7 @@ model_id = "scribe_v2"
|
||||
self.assertTrue(config.accounts[0].use_qr)
|
||||
self.assertEqual(config.elevenlabs.api_key, "test-key")
|
||||
self.assertEqual(config.session_dir, root / "sessions")
|
||||
self.assertEqual(config.ai.prompt_dir, root / "prompts")
|
||||
self.assertEqual(config.ai.prompt_dir, root / "custom-prompts")
|
||||
self.assertEqual(config.ai.base_dir, root)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user