fix: single transaction for dyn tools injection (#10614)
This commit is contained in:
parent
100eb6e6f0
commit
3d8deeea4b
1 changed files with 3 additions and 1 deletions
|
|
@ -419,6 +419,7 @@ ON CONFLICT(id) DO UPDATE SET
|
|||
return Ok(());
|
||||
}
|
||||
let thread_id = thread_id.to_string();
|
||||
let mut tx = self.pool.begin().await?;
|
||||
for (idx, tool) in tools.iter().enumerate() {
|
||||
let position = i64::try_from(idx).unwrap_or(i64::MAX);
|
||||
let input_schema = serde_json::to_string(&tool.input_schema)?;
|
||||
|
|
@ -439,9 +440,10 @@ ON CONFLICT(thread_id, position) DO NOTHING
|
|||
.bind(tool.name.as_str())
|
||||
.bind(tool.description.as_str())
|
||||
.bind(input_schema)
|
||||
.execute(self.pool.as_ref())
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
}
|
||||
tx.commit().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue