Skip to content

Commit

Permalink
fix: transaction hangs due to message commit block during long LLM ca…
Browse files Browse the repository at this point in the history
…lls (#1206)
  • Loading branch information
takatost authored Sep 21, 2023
1 parent e65f9cb commit 2b018fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/core/conversation_message_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def init(self):
)

db.session.add(self.message)
db.session.flush()
db.session.commit()

def append_message_text(self, text: str):
if text is not None:
Expand Down Expand Up @@ -191,7 +191,7 @@ def init_chain(self, chain_result: ChainResult):
)

db.session.add(message_chain)
db.session.flush()
db.session.commit()

return message_chain

Expand All @@ -217,7 +217,7 @@ def on_agent_start(self, message_chain: MessageChain, agent_loop: AgentLoop) ->
)

db.session.add(message_agent_thought)
db.session.flush()
db.session.commit()

self._pub_handler.pub_agent_thought(message_agent_thought)

Expand Down Expand Up @@ -249,7 +249,7 @@ def on_agent_end(self, message_agent_thought: MessageAgentThought, agent_model_i
message_agent_thought.tokens = agent_loop.prompt_tokens + agent_loop.completion_tokens
message_agent_thought.total_price = loop_total_price
message_agent_thought.currency = agent_model_instance.get_currency()
db.session.flush()
db.session.commit()

def on_dataset_query_end(self, dataset_query_obj: DatasetQueryObj):
dataset_query = DatasetQuery(
Expand Down Expand Up @@ -285,7 +285,7 @@ def on_dataset_query_finish(self, resource: List):
created_by=self.user.id
)
db.session.add(dataset_retriever_resource)
db.session.flush()
db.session.commit()
self.retriever_resource = resource

def message_end(self):
Expand Down

0 comments on commit 2b018fa

Please sign in to comment.