minchyeom commited on
Commit
100e82d
·
1 Parent(s): c776856

Prevent storing empty assistant messages in the database

Browse files
Files changed (1) hide show
  1. src/chat.py +2 -1
src/chat.py CHANGED
@@ -170,7 +170,8 @@ class ChatSession:
170
  else:
171
  content = message.content or ""
172
 
173
- DBMessage.create(conversation=conversation, role="assistant", content=content)
 
174
 
175
  async def ask(self, messages: List[Msg], *, think: bool = True) -> ChatResponse:
176
  """Send a chat request, automatically prepending the system prompt."""
 
170
  else:
171
  content = message.content or ""
172
 
173
+ if content.strip():
174
+ DBMessage.create(conversation=conversation, role="assistant", content=content)
175
 
176
  async def ask(self, messages: List[Msg], *, think: bool = True) -> ChatResponse:
177
  """Send a chat request, automatically prepending the system prompt."""