Properly close mistral response

This commit is contained in:
2025-01-09 20:01:32 +01:00
parent ed9e38c848
commit 3ab726f961

View File

@@ -46,12 +46,12 @@ class MistralLlmEngine(LlmEngine):
try: try:
for chunk in stream_response: for chunk in stream_response:
if should_stop(): if should_stop():
stream_response.close() stream_response.response.close()
break break
if content := chunk.data.choices[0].delta.content: if content := chunk.data.choices[0].delta.content:
yield content yield content
finally: finally:
stream_response.close() stream_response.response.close()
def token_count(self, system_prompt: str, main_context: str) -> int: def token_count(self, system_prompt: str, main_context: str) -> int:
messages = [ messages = [