From a31466d34e280284216b638e1fcd89e0db9bfff4 Mon Sep 17 00:00:00 2001 From: takatost Date: Wed, 27 Sep 2023 21:40:26 +0800 Subject: [PATCH] fix: db session not commit before long llm call running (#1251) --- api/core/model_providers/models/llm/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/core/model_providers/models/llm/base.py b/api/core/model_providers/models/llm/base.py index 2fcf7ee96e957e..0aacfe260263f9 100644 --- a/api/core/model_providers/models/llm/base.py +++ b/api/core/model_providers/models/llm/base.py @@ -1,6 +1,7 @@ import json import os import re +import time from abc import abstractmethod from typing import List, Optional, Any, Union, Tuple import decimal @@ -20,6 +21,8 @@ from core.third_party.langchain.llms.fake import FakeLLM import logging +from extensions.ext_database import db + logger = logging.getLogger(__name__) @@ -129,6 +132,8 @@ def run(self, messages: List[PromptMessage], if self.deduct_quota: self.model_provider.check_quota_over_limit() + db.session.commit() + if not callbacks: callbacks = self.callbacks else: