♻️(backend) use mistral sdk with legacy ai feature

We also want to use the mistral sdk with the legacy AI feature when this
one is configured with the settings. In order to separate bot feature,
they now live in their own module.
This commit is contained in:
Manuel Raynaud
2026-04-30 09:32:34 +02:00
parent 8c84dbf39a
commit 6cfc8990b9
10 changed files with 279 additions and 138 deletions
@@ -14,7 +14,7 @@ import pytest
from rest_framework.test import APIClient
from core import factories, models
from core.services.ai_services import configure_legacy_openai_client
from core.services.ai_services.legacy import get_legacy_ai_service
from core.tests.documents.test_api_documents_ai_proxy import ( # pylint: disable=unused-import
ai_settings,
)
@@ -27,8 +27,7 @@ pytestmark = pytest.mark.django_db
@pytest.fixture(autouse=True)
def clear_openai_client_config():
"""Clear the configure_legacy_openai_client cache."""
yield
configure_legacy_openai_client.cache_clear()
get_legacy_ai_service.cache_clear()
def test_external_api_documents_ai_transform_not_allowed(
@@ -249,7 +248,7 @@ def test_external_api_documents_ai_translate_can_be_allowed(
}
)
@pytest.mark.usefixtures("ai_settings")
@patch("core.services.ai_services.AIService.stream")
@patch("core.services.ai_services.blocknote.AIService.stream")
def test_external_api_documents_ai_proxy_can_be_allowed(
mock_stream, user_token, resource_server_backend, user_specific_sub
):