mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-04 02:40:50 +08:00
Merge pull request #361 from LyricalNanoha/fix/omit-empty-tools-array
This commit is contained in:
@@ -54,11 +54,13 @@ impl Provider for AnthropicProvider {
|
||||
.unwrap_or(DEFAULT_MAX_OUTPUT_TOKENS);
|
||||
let mut body = json!({
|
||||
"model": request.model.model_id, "system": request.prompt.instructions, "messages": messages,
|
||||
"max_tokens": max_tokens, "stream": true,
|
||||
"tools": request.prompt.tools.iter().map(|tool| json!({
|
||||
"name": tool.name, "description": tool.description, "input_schema": tool.parameters
|
||||
})).collect::<Vec<_>>()
|
||||
"max_tokens": max_tokens, "stream": true
|
||||
});
|
||||
if !request.prompt.tools.is_empty() {
|
||||
body["tools"] = json!(request.prompt.tools.iter().map(|tool| json!({
|
||||
"name": tool.name, "description": tool.description, "input_schema": tool.parameters
|
||||
})).collect::<Vec<_>>());
|
||||
}
|
||||
apply_model(&mut body, &request.model)?;
|
||||
merge_extra_params(&mut body, &request.model.extra_params)?;
|
||||
if let Some(recorder) = &recorder {
|
||||
|
||||
@@ -65,12 +65,14 @@ impl Provider for OpenAiChatProvider {
|
||||
let mut body = json!({
|
||||
"model": request.model.model_id,
|
||||
"messages": messages,
|
||||
"tools": request.prompt.tools.iter().map(|tool| json!({"type":"function","function":{
|
||||
"name": tool.name, "description": tool.description, "parameters": tool.parameters
|
||||
}})).collect::<Vec<_>>(),
|
||||
"stream": true,
|
||||
"stream_options": {"include_usage": true}
|
||||
});
|
||||
if !request.prompt.tools.is_empty() {
|
||||
body["tools"] = json!(request.prompt.tools.iter().map(|tool| json!({"type":"function","function":{
|
||||
"name": tool.name, "description": tool.description, "parameters": tool.parameters
|
||||
}})).collect::<Vec<_>>());
|
||||
}
|
||||
apply_model(&mut body, &request.model, config.max_output_tokens)?;
|
||||
merge_extra_params(&mut body, &request.model.extra_params)?;
|
||||
apply_openai_prompt_cache_key(&mut body, &request.model.model_id)?;
|
||||
|
||||
@@ -69,12 +69,14 @@ impl Provider for OpenAiResponsesProvider {
|
||||
let mut body = json!({
|
||||
"model": request.model.model_id, "input": input, "stream": true,
|
||||
"instructions": request.prompt.instructions,
|
||||
"include": ["reasoning.encrypted_content"],
|
||||
"tools": request.prompt.tools.iter().map(|tool| json!({
|
||||
"include": ["reasoning.encrypted_content"]
|
||||
});
|
||||
if !request.prompt.tools.is_empty() {
|
||||
body["tools"] = json!(request.prompt.tools.iter().map(|tool| json!({
|
||||
"type":"function", "name":tool.name, "description":tool.description,
|
||||
"parameters":tool.parameters, "strict":false
|
||||
})).collect::<Vec<_>>()
|
||||
});
|
||||
})).collect::<Vec<_>>());
|
||||
}
|
||||
apply_model(&mut body, &request.model, config.max_output_tokens)?;
|
||||
merge_extra_params(&mut body, &request.model.extra_params)?;
|
||||
apply_openai_prompt_cache_key(&mut body, &request.model.model_id)?;
|
||||
|
||||
Reference in New Issue
Block a user