Skip to content

Commit b78b354

Browse files
committed
fix when no ai provider is configured
1 parent 8fc24cd commit b78b354

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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 "API key is required to initialize AIClient"
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)