Skip to content

Commit 36a88c4

Browse files
committed
fix: When there is an empty string in the context, the conversation reports an error
1 parent 9c56c7e commit 36a88c4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/application/models/application.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django.contrib.postgres.fields import ArrayField
1212
from django.db import models
1313
from langchain.schema import HumanMessage, AIMessage
14-
14+
from django.utils.translation import gettext as _
1515
from common.encoder.encoder import SystemEncoder
1616
from common.mixins.app_model_mixin import AppModelMixin
1717
from dataset.models.data_set import DataSet
@@ -167,7 +167,11 @@ def get_human_message(self):
167167
return HumanMessage(content=self.problem_text)
168168

169169
def get_ai_message(self):
170-
return AIMessage(content=self.answer_text)
170+
answer_text = self.answer_text
171+
if answer_text is None or len(str(answer_text).strip()) == 0:
172+
answer_text = _(
173+
'Sorry, no relevant content was found. Please re-describe your problem or provide more information. ')
174+
return AIMessage(content=answer_text)
171175

172176
def get_node_details_runtime_node_id(self, runtime_node_id):
173177
return self.details.get(runtime_node_id, None)

0 commit comments

Comments
 (0)