This commit is contained in:
Nicolas Patry 2025-03-10 18:42:27 +01:00
parent a73cd56075
commit 214a5b5da1
No known key found for this signature in database
GPG Key ID: 4242CEF24CB6DBF9

View File

@ -21,8 +21,8 @@ use serde::{Deserialize, Serialize};
use tokenizers::Encoding;
use tracing::warn;
use utoipa::ToSchema;
use validation::Validation;
use uuid::Uuid;
use validation::Validation;
#[allow(clippy::large_enum_variant)]
#[derive(Clone)]
@ -997,11 +997,11 @@ impl ChatRequest {
))
}
fn next_int_id(&self) -> Result<String, Box<dyn std::error::Error>>{
fn next_int_id(&self) -> Result<String, Box<dyn std::error::Error>> {
let mut id: usize = 0;
for message in &self.messages{
if let MessageBody::Tool{tool_calls} = &message.body {
for tool_call in tool_calls{
for message in &self.messages {
if let MessageBody::Tool { tool_calls } = &message.body {
for tool_call in tool_calls {
let new_id: usize = tool_call.id.parse()?;
id = std::cmp::max(id, new_id + 1);
}
@ -1013,8 +1013,8 @@ impl ChatRequest {
/// Try to have linearly increasing id
/// or resort to using Uuid if the initial
/// scheme is not understood
fn next_tool_call_id(&self) -> String{
self.next_int_id().unwrap_or_else(|_|{
fn next_tool_call_id(&self) -> String {
self.next_int_id().unwrap_or_else(|_| {
let uid = Uuid::new_v4().to_string();
uid.to_string()
})