mirror of
https://github.com/katanemo/plano.git
synced 2026-05-08 23:32:43 +02:00
Improve end to end tracing (#628)
* adding canonical tracing support via bright-staff * improved formatting for tools in the traces * removing anthropic from the currency exchange demo * using Envoy to transport traces, not calling OTEL directly * moving otel collcetor cluster outside tracing if/else * minor fixes to not write to the OTEL collector if tracing is disabled * fixed PR comments and added more trace attributes * more fixes based on PR comments * more clean up based on PR comments --------- Co-authored-by: Salman Paracha <salmanparacha@MacBook-Pro-342.local>
This commit is contained in:
parent
8adb9795d8
commit
a79f55f313
34 changed files with 2556 additions and 403 deletions
|
|
@ -200,6 +200,17 @@ impl ProviderRequest for ConverseRequest {
|
|||
})
|
||||
}
|
||||
|
||||
fn get_tool_names(&self) -> Option<Vec<String>> {
|
||||
self.tool_config.as_ref()?.tools.as_ref().map(|tools| {
|
||||
tools
|
||||
.iter()
|
||||
.filter_map(|tool| match tool {
|
||||
Tool::ToolSpec { tool_spec } => Some(tool_spec.name.clone()),
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
fn to_bytes(&self) -> Result<Vec<u8>, ProviderRequestError> {
|
||||
serde_json::to_vec(self).map_err(|e| ProviderRequestError {
|
||||
message: format!("Failed to serialize Bedrock request: {}", e),
|
||||
|
|
@ -218,6 +229,10 @@ impl ProviderRequest for ConverseRequest {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn get_temperature(&self) -> Option<f32> {
|
||||
self.inference_config.as_ref()?.temperature
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
|||
|
|
@ -513,6 +513,12 @@ impl ProviderRequest for MessagesRequest {
|
|||
None
|
||||
}
|
||||
|
||||
fn get_tool_names(&self) -> Option<Vec<String>> {
|
||||
self.tools.as_ref().map(|tools| {
|
||||
tools.iter().map(|tool| tool.name.clone()).collect()
|
||||
})
|
||||
}
|
||||
|
||||
fn to_bytes(&self) -> Result<Vec<u8>, ProviderRequestError> {
|
||||
serde_json::to_vec(self).map_err(|e| ProviderRequestError {
|
||||
message: format!("Failed to serialize MessagesRequest: {}", e),
|
||||
|
|
@ -531,6 +537,10 @@ impl ProviderRequest for MessagesRequest {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn get_temperature(&self) -> Option<f32> {
|
||||
self.temperature
|
||||
}
|
||||
}
|
||||
|
||||
impl MessagesResponse {
|
||||
|
|
|
|||
|
|
@ -687,6 +687,32 @@ impl ProviderRequest for ChatCompletionsRequest {
|
|||
})
|
||||
}
|
||||
|
||||
fn get_tool_names(&self) -> Option<Vec<String>> {
|
||||
// First check the 'tools' field (current API)
|
||||
if let Some(tools) = &self.tools {
|
||||
let names: Vec<String> = tools
|
||||
.iter()
|
||||
.map(|tool| tool.function.name.clone())
|
||||
.collect();
|
||||
if !names.is_empty() {
|
||||
return Some(names);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to 'functions' field (deprecated but still supported)
|
||||
if let Some(functions) = &self.functions {
|
||||
let names: Vec<String> = functions
|
||||
.iter()
|
||||
.map(|func| func.function.name.clone())
|
||||
.collect();
|
||||
if !names.is_empty() {
|
||||
return Some(names);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
fn to_bytes(&self) -> Result<Vec<u8>, ProviderRequestError> {
|
||||
serde_json::to_vec(&self).map_err(|e| ProviderRequestError {
|
||||
message: format!("Failed to serialize OpenAI request: {}", e),
|
||||
|
|
@ -705,6 +731,10 @@ impl ProviderRequest for ChatCompletionsRequest {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn get_temperature(&self) -> Option<f32> {
|
||||
self.temperature
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation of ProviderResponse for ChatCompletionsResponse
|
||||
|
|
|
|||
|
|
@ -1063,6 +1063,19 @@ impl ProviderRequest for ResponsesAPIRequest {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_tool_names(&self) -> Option<Vec<String>> {
|
||||
self.tools.as_ref().map(|tools| {
|
||||
tools
|
||||
.iter()
|
||||
.filter_map(|tool| match tool {
|
||||
Tool::Function { name, .. } => Some(name.clone()),
|
||||
// Other tool types don't have user-defined names
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
fn to_bytes(&self) -> Result<Vec<u8>, ProviderRequestError> {
|
||||
serde_json::to_vec(&self).map_err(|e| ProviderRequestError {
|
||||
message: format!("Failed to serialize Responses API request: {}", e),
|
||||
|
|
@ -1081,6 +1094,10 @@ impl ProviderRequest for ResponsesAPIRequest {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn get_temperature(&self) -> Option<f32> {
|
||||
self.temperature
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue