From 83803a72ee16cfe72b190e7e4093a0aae5e811fe Mon Sep 17 00:00:00 2001 From: KevinHuSh Date: Thu, 30 May 2024 18:03:36 +0800 Subject: [PATCH] fix ollama bug (#999) ### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/db/services/dialog_service.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py index a4f960158..92121a0dc 100644 --- a/api/db/services/dialog_service.py +++ b/api/db/services/dialog_service.py @@ -58,17 +58,17 @@ def message_fit_in(msg, max_length=4000): if c < max_length: return c, msg - ll = num_tokens_from_string(msg_[0].content) - l = num_tokens_from_string(msg_[-1].content) + ll = num_tokens_from_string(msg_[0]["content"]) + l = num_tokens_from_string(msg_[-1]["content"]) if ll / (ll + l) > 0.8: - m = msg_[0].content + m = msg_[0]["content"] m = encoder.decode(encoder.encode(m)[:max_length - l]) - msg[0].content = m + msg[0]["content"] = m return max_length, msg - m = msg_[1].content + m = msg_[1]["content"] m = encoder.decode(encoder.encode(m)[:max_length - l]) - msg[1].content = m + msg[1]["content"] = m return max_length, msg