diff --git a/ai_chat/apps.py b/ai_chat/apps.py index 46f8a6f39e..32b00f07a2 100644 --- a/ai_chat/apps.py +++ b/ai_chat/apps.py @@ -1,4 +1,4 @@ -"""learning_resources app config""" +"""ai_chat app config""" from django.apps import AppConfig diff --git a/ai_chat/views.py b/ai_chat/views.py index 3b39e7bea2..e1b4e88289 100644 --- a/ai_chat/views.py +++ b/ai_chat/views.py @@ -8,7 +8,6 @@ from rest_framework.request import Request from ai_chat import serializers -from ai_chat.agents import SearchAgent from ai_chat.permissions import SearchAgentPermissions log = logging.getLogger(__name__) @@ -34,6 +33,8 @@ class SearchAgentView(views.APIView): ) def post(self, request: Request) -> StreamingHttpResponse: """Handle a POST request to the chatbot agent.""" + from ai_chat.agents import SearchAgent + serializer = serializers.ChatRequestSerializer( data=request.data, context={"request": request} ) diff --git a/ai_chat/views_test.py b/ai_chat/views_test.py index 77f9c89f5d..7b3c297257 100644 --- a/ai_chat/views_test.py +++ b/ai_chat/views_test.py @@ -18,7 +18,7 @@ def test_post_search_agent_endpoint( user_message = "Do you have any good physics courses?" temperature = 0.1 system_prompt = "Answer this question as best you can" - mock_agent = mocker.patch("ai_chat.views.SearchAgent", autospec=True) + mock_agent = mocker.patch("ai_chat.agents.SearchAgent", autospec=True) mock_agent.return_value.get_completion = mocker.Mock( return_value=iter(expected_answer) ) diff --git a/main/settings.py b/main/settings.py index 766baf4666..45239f612f 100644 --- a/main/settings.py +++ b/main/settings.py @@ -105,7 +105,6 @@ "drf_spectacular", # Put our apps after this point "main", - "ai_chat", "authentication", "channels", "profiles", @@ -119,6 +118,7 @@ "testimonials", "data_fixtures", "vector_search", + "ai_chat", ) if not get_bool("RUN_DATA_MIGRATIONS", default=False): diff --git a/main/urls.py b/main/urls.py index 8431b44905..ef45361d81 100644 --- a/main/urls.py +++ b/main/urls.py @@ -45,6 +45,7 @@ re_path(r"^o/", include("oauth2_provider.urls", namespace="oauth2_provider")), re_path(r"^admin/", admin.site.urls), re_path(r"", include("authentication.urls")), + re_path(r"", include("ai_chat.urls")), re_path(r"", include("channels.urls")), re_path(r"", include("profiles.urls")), re_path(r"", include("embedly.urls")), @@ -58,7 +59,6 @@ re_path(r"", include("testimonials.urls")), re_path(r"", include("news_events.urls")), re_path(r"", include(features_router.urls)), - re_path(r"", include("ai_chat.urls")), re_path(r"^app", RedirectView.as_view(url=settings.APP_BASE_URL)), # Hijack re_path(r"^hijack/", include("hijack.urls", namespace="hijack")),