Skip to content

Commit 47faed2

Browse files
perf: Raise Model does not exist instead of a null pointer exception
1 parent f75a527 commit 47faed2

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

apps/application/chat_pipeline/step/generate_human_message_step/impl/base_generate_human_message_step.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ def to_human_message(prompt: str,
5757
content=no_references_setting.get('value').replace('{question}', problem))
5858
else:
5959
return HumanMessage(content=prompt.replace('{data}', "").replace('{question}', problem))
60-
temp_data = ""
60+
temp_len = 0
6161
data_list = []
6262
for p in paragraph_list:
6363
content = f"{p.title}:{p.content}"
64-
temp_data += content
65-
if len(temp_data) > max_paragraph_char_number:
66-
row_data = content[0:max_paragraph_char_number - len(temp_data)]
64+
temp_len += len(content)
65+
if temp_len > max_paragraph_char_number:
66+
row_data = content[0:max_paragraph_char_number - temp_len]
6767
data_list.append(f"<data>{row_data}</data>")
6868
break
6969
else:

apps/models_provider/serializers/model_serializer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ def one_meta(self, with_valid=False):
150150
super().is_valid(raise_exception=True)
151151
model = QuerySet(Model).filter(id=self.data.get("id"),
152152
workspace_id=self.data.get('workspace_id', 'None')).first()
153-
if model is None:
154-
raise AppApiException(500, _('Model does not exist'))
153+
if model is None:
154+
raise AppApiException(500, _('Model does not exist'))
155155
return {'id': str(model.id), 'provider': model.provider, 'name': model.name, 'model_type': model.model_type,
156156
'model_name': model.model_name,
157157
'status': model.status,

0 commit comments

Comments
 (0)