mirror of https://github.com/buster-so/buster.git
fix(ai_tools): Update LLM request parameters and improve response handling
- Add `stream: Some(false)` to file search and data catalog tools - Make `json_schema` optional in `ResponseFormat` serialization - Enhance logging in search file tool with debug and warning messages - Improve error context when parsing LLM JSON responses
This commit is contained in:
parent
864257bc24
commit
8054bedf1a
|
@ -191,6 +191,7 @@ impl Message {
|
|||
pub struct ResponseFormat {
|
||||
#[serde(rename = "type")]
|
||||
pub type_: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub json_schema: Option<Value>,
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ impl SearchDataCatalogTool {
|
|||
content: prompt,
|
||||
name: None,
|
||||
}],
|
||||
temperature: Some(0.0),
|
||||
stream: Some(false),
|
||||
response_format: Some(ResponseFormat {
|
||||
type_: "json_object".to_string(),
|
||||
json_schema: None,
|
||||
|
|
|
@ -97,7 +97,7 @@ impl SearchFilesTool {
|
|||
content: prompt,
|
||||
name: None,
|
||||
}],
|
||||
temperature: Some(0.0),
|
||||
stream: Some(false),
|
||||
response_format: Some(ResponseFormat {
|
||||
type_: "json_object".to_string(),
|
||||
json_schema: None,
|
||||
|
@ -116,7 +116,10 @@ impl SearchFilesTool {
|
|||
Message::Assistant {
|
||||
content: Some(content),
|
||||
..
|
||||
} => content,
|
||||
} => {
|
||||
debug!("Received LLM response content: {}", content);
|
||||
content
|
||||
}
|
||||
_ => {
|
||||
error!("LLM response missing content");
|
||||
return Err(anyhow::anyhow!("LLM response missing content"));
|
||||
|
@ -125,7 +128,7 @@ impl SearchFilesTool {
|
|||
|
||||
// Parse into structured response
|
||||
serde_json::from_str(content).map_err(|e| {
|
||||
warn!(error = %e, "Failed to parse LLM response as JSON");
|
||||
warn!(error = %e, content = content, "Failed to parse LLM response as JSON");
|
||||
anyhow::anyhow!("Failed to parse search results: {}", e)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue