Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: db session not commit before long llm call running (#1251)

takatosta31466d34e28
diff --git a/api/core/model_providers/models/llm/base.py b/api/core/model_providers/models/llm/base.py
index 2fcf7ee96e9..0aacfe26026 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.prompt.prompt_template import JinjaPromptTemplate
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 @@ class BaseLLM(BaseProviderModel):
if self.deduct_quota:
self.model_provider.check_quota_over_limit()
+ db.session.commit()
+
if not callbacks:
callbacks = self.callbacks
else: