[router][grpc] Fix tool call id in parse_json_schema_response (#12152)
This commit is contained in:
@@ -193,6 +193,8 @@ impl ResponseProcessor {
|
|||||||
(tool_calls, processed_text) = utils::parse_json_schema_response(
|
(tool_calls, processed_text) = utils::parse_json_schema_response(
|
||||||
&processed_text,
|
&processed_text,
|
||||||
&original_request.tool_choice,
|
&original_request.tool_choice,
|
||||||
|
&original_request.model,
|
||||||
|
history_tool_calls_count,
|
||||||
);
|
);
|
||||||
} else if tool_parser_available {
|
} else if tool_parser_available {
|
||||||
(tool_calls, processed_text) = self
|
(tool_calls, processed_text) = self
|
||||||
|
|||||||
@@ -542,6 +542,8 @@ pub fn create_stop_decoder(
|
|||||||
pub fn parse_json_schema_response(
|
pub fn parse_json_schema_response(
|
||||||
processed_text: &str,
|
processed_text: &str,
|
||||||
tool_choice: &Option<ToolChoice>,
|
tool_choice: &Option<ToolChoice>,
|
||||||
|
model: &str,
|
||||||
|
history_tool_calls_count: usize,
|
||||||
) -> (Option<Vec<ToolCall>>, String) {
|
) -> (Option<Vec<ToolCall>>, String) {
|
||||||
match tool_choice {
|
match tool_choice {
|
||||||
Some(ToolChoice::Function { function, .. }) => {
|
Some(ToolChoice::Function { function, .. }) => {
|
||||||
@@ -549,7 +551,12 @@ pub fn parse_json_schema_response(
|
|||||||
match serde_json::from_str::<Value>(processed_text) {
|
match serde_json::from_str::<Value>(processed_text) {
|
||||||
Ok(params) => {
|
Ok(params) => {
|
||||||
let tool_call = ToolCall {
|
let tool_call = ToolCall {
|
||||||
id: format!("call_{}", Uuid::new_v4()),
|
id: generate_tool_call_id(
|
||||||
|
model,
|
||||||
|
&function.name,
|
||||||
|
0,
|
||||||
|
history_tool_calls_count,
|
||||||
|
),
|
||||||
tool_type: "function".to_string(),
|
tool_type: "function".to_string(),
|
||||||
function: FunctionCallResponse {
|
function: FunctionCallResponse {
|
||||||
name: function.name.clone(),
|
name: function.name.clone(),
|
||||||
@@ -580,7 +587,12 @@ pub fn parse_json_schema_response(
|
|||||||
let parameters = obj.get("parameters")?;
|
let parameters = obj.get("parameters")?;
|
||||||
|
|
||||||
Some(ToolCall {
|
Some(ToolCall {
|
||||||
id: format!("call_{}_{}", i, Uuid::new_v4()),
|
id: generate_tool_call_id(
|
||||||
|
model,
|
||||||
|
&name,
|
||||||
|
i,
|
||||||
|
history_tool_calls_count,
|
||||||
|
),
|
||||||
tool_type: "function".to_string(),
|
tool_type: "function".to_string(),
|
||||||
function: FunctionCallResponse {
|
function: FunctionCallResponse {
|
||||||
name,
|
name,
|
||||||
|
|||||||
Reference in New Issue
Block a user