mirror of
https://github.com/katanemo/plano.git
synced 2026-05-18 13:45:15 +02:00
improve logging of api failure (#79)
This commit is contained in:
parent
bd8206742a
commit
d970b214f4
2 changed files with 15 additions and 4 deletions
|
|
@ -47,6 +47,8 @@ pub struct CallContext {
|
|||
prompt_target_name: Option<String>,
|
||||
request_body: ChatCompletionsRequest,
|
||||
similarity_scores: Option<Vec<(String, f64)>>,
|
||||
up_stream_cluster: Option<String>,
|
||||
up_stream_cluster_path: Option<String>,
|
||||
}
|
||||
|
||||
pub struct StreamContext {
|
||||
|
|
@ -533,6 +535,8 @@ impl StreamContext {
|
|||
}
|
||||
};
|
||||
|
||||
callout_context.up_stream_cluster = Some(endpoint.cluster);
|
||||
callout_context.up_stream_cluster_path = Some(path);
|
||||
callout_context.response_handler_type = ResponseHandlerType::FunctionCall;
|
||||
if self.callouts.insert(token_id, callout_context).is_some() {
|
||||
panic!("duplicate token_id")
|
||||
|
|
@ -542,11 +546,12 @@ impl StreamContext {
|
|||
|
||||
fn function_call_response_handler(&mut self, body: Vec<u8>, callout_context: CallContext) {
|
||||
let headers = self.get_http_call_response_headers();
|
||||
debug!("response headers: {:?}", headers);
|
||||
if let Some(http_status) = headers.iter().find(|(key, _)| key == ":status") {
|
||||
if http_status.1 != StatusCode::OK.as_str() {
|
||||
let error_msg = format!(
|
||||
"Error in function call response: status code: {}",
|
||||
"Error in function call response: cluster: {}, path: {}, status code: {}",
|
||||
callout_context.up_stream_cluster.unwrap(),
|
||||
callout_context.up_stream_cluster_path.unwrap(),
|
||||
http_status.1
|
||||
);
|
||||
return self.send_server_error(error_msg, Some(StatusCode::BAD_REQUEST));
|
||||
|
|
@ -739,6 +744,8 @@ impl StreamContext {
|
|||
prompt_target_name: None,
|
||||
request_body: callout_context.request_body,
|
||||
similarity_scores: None,
|
||||
up_stream_cluster: None,
|
||||
up_stream_cluster_path: None,
|
||||
};
|
||||
if self.callouts.insert(token_id, call_context).is_some() {
|
||||
panic!(
|
||||
|
|
@ -846,6 +853,8 @@ impl HttpContext for StreamContext {
|
|||
prompt_target_name: None,
|
||||
request_body: deserialized_body,
|
||||
similarity_scores: None,
|
||||
up_stream_cluster: None,
|
||||
up_stream_cluster_path: None,
|
||||
};
|
||||
self.get_embeddings(callout_context);
|
||||
return Action::Pause;
|
||||
|
|
@ -867,6 +876,8 @@ impl HttpContext for StreamContext {
|
|||
prompt_target_name: None,
|
||||
request_body: deserialized_body,
|
||||
similarity_scores: None,
|
||||
up_stream_cluster: None,
|
||||
up_stream_cluster_path: None,
|
||||
};
|
||||
self.get_embeddings(callout_context);
|
||||
return Action::Pause;
|
||||
|
|
@ -916,6 +927,8 @@ impl HttpContext for StreamContext {
|
|||
prompt_target_name: None,
|
||||
request_body: deserialized_body,
|
||||
similarity_scores: None,
|
||||
up_stream_cluster: None,
|
||||
up_stream_cluster_path: None,
|
||||
};
|
||||
if self.callouts.insert(token_id, call_context).is_some() {
|
||||
panic!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue