Skip to content

Commit 773b928

Browse files
authored
Merge pull request #1671 from swirlai/DS-4207_disable_rag_features_no_ai_provider
[DS-4207] Disable search RAG features when no AI provider configured
2 parents a6f5c61 + b7baef3 commit 773b928

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

swirl/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
path('search/search', views.SearchViewSet.as_view({'get': 'list'}), name='search'),
4545
path('sapi/detail-search-rag/', views.DetailSearchRagView.as_view(), name='detail-search-rag'),
46+
path('sapi/is_chat_ai_provider_exists', views.IsChatAIProviderExists.as_view({'get': 'list'}), name='is-chat-ai-provider-exists'),
4647

4748
path('', views.index, name='index'),
4849
path('index.html', views.index, name='index'),

swirl/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,3 +995,13 @@ def list(self, request):
995995
return JsonResponse({}, status=status.HTTP_200_OK)
996996
else:
997997
return Response('Logo Object Not Found', status=status.HTTP_404_NOT_FOUND)
998+
999+
1000+
class IsChatAIProviderExists(viewsets.ModelViewSet):
1001+
1002+
def list(self, request):
1003+
# TODO: The Community Edition does not include an AI provider model.
1004+
# For now, we are setting the status to True as a temporary workaround.
1005+
# This should be updated once the AI provider model is implemented.
1006+
# This validation is used to enable or disable the second row of Search RAG.
1007+
return Response({'status': 'True'}, status=status.HTTP_200_OK)

swirl/views_helpers/search_rag.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,13 @@ def get_rag_result(self) -> tuple[str, dict[str, str]]:
6161
instances[self.search_id] = rag_processor
6262
if rag_processor.validate():
6363
result = rag_processor.process(should_return=True)
64-
try:
65-
if self.search_id in instances:
66-
del instances[self.search_id]
67-
return result.json_results[0]["body"][0]
68-
except:
69-
if self.search_id in instances:
70-
del instances[self.search_id]
71-
return False
64+
if result == 0:
65+
return "Please check the OpenAI or Azure/OpenAI credentials in your environment."
66+
67+
if self.search_id in instances:
68+
del instances[self.search_id]
69+
70+
return result.json_results[0]["body"][0]
7271

7372
def process_rag(self) -> dict[str, str]:
7473
result = ""

0 commit comments

Comments
 (0)