| @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any, Optional, cast | |||
| from sqlalchemy import Float, and_, func, or_, text | |||
| from sqlalchemy import cast as sqlalchemy_cast | |||
| from sqlalchemy.orm import Session | |||
| from sqlalchemy.orm import sessionmaker | |||
| from core.app.app_config.entities import DatasetRetrieveConfigEntity | |||
| from core.app.entities.app_invoke_entities import ModelConfigWithCredentialsEntity | |||
| @@ -175,7 +175,7 @@ class KnowledgeRetrievalNode(BaseNode): | |||
| redis_client.zremrangebyscore(key, 0, current_time - 60000) | |||
| request_count = redis_client.zcard(key) | |||
| if request_count > knowledge_rate_limit.limit: | |||
| with Session(db.engine) as session: | |||
| with sessionmaker(db.engine).begin() as session: | |||
| # add ratelimit record | |||
| rate_limit_log = RateLimitLog( | |||
| tenant_id=self.tenant_id, | |||
| @@ -183,7 +183,6 @@ class KnowledgeRetrievalNode(BaseNode): | |||
| operation="knowledge", | |||
| ) | |||
| session.add(rate_limit_log) | |||
| session.commit() | |||
| return NodeRunResult( | |||
| status=WorkflowNodeExecutionStatus.FAILED, | |||
| inputs=variables, | |||