fix pre-commit

This commit is contained in:
Adil Hafeez 2025-12-25 20:53:48 -08:00
parent 36970e5de5
commit a2dc311e7d
No known key found for this signature in database
GPG key ID: 9B18EF7691369645
10 changed files with 14 additions and 27 deletions

View file

@ -1081,7 +1081,7 @@ impl ArchFunctionHandler {
let model_message = if response_dict
.response
.as_ref()
.map_or(false, |s| !s.is_empty())
.is_some_and(|s| !s.is_empty())
{
// When arch-fc returns a "response" field, it means no intent was matched
// Return empty content and empty tool_calls so prompt_gateway routes to default target
@ -1735,7 +1735,7 @@ impl HallucinationState {
if self.state.as_deref() == Some("function_name") {
if !FUNC_NAME_END_TOKEN
.iter()
.any(|&t| self.tokens.last().map_or(false, |tok| tok == t))
.any(|&t| self.tokens.last().is_some_and(|tok| tok == t))
{
self.mask.push(MaskToken::FunctionName);
} else {

View file

@ -123,8 +123,8 @@ pub async fn llm_chat(
// Do this BEFORE routing since routing consumes the request
// Only process state if state_storage is configured
let mut should_manage_state = false;
if is_responses_api_client && state_storage.is_some() {
if let ProviderRequestType::ResponsesAPIRequest(ref mut responses_req) = client_request {
if is_responses_api_client {
if let (ProviderRequestType::ResponsesAPIRequest(ref mut responses_req), Some(ref state_store)) = (&mut client_request, &state_storage) {
// Extract original input once
original_input_items = extract_input_items(&responses_req.input);
@ -150,7 +150,7 @@ pub async fn llm_chat(
// Retrieve and combine conversation history if previous_response_id exists
if let Some(ref prev_resp_id) = responses_req.previous_response_id {
match retrieve_and_combine_input(
state_storage.as_ref().unwrap().clone(),
state_store.clone(),
prev_resp_id,
original_input_items, // Pass ownership instead of cloning
)
@ -293,7 +293,7 @@ pub async fn llm_chat(
// === v1/responses state management: Wrap with ResponsesStateProcessor ===
// Only wrap if we need to manage state (client is ResponsesAPI AND upstream is NOT ResponsesAPI AND state_storage is configured)
let streaming_response =
if should_manage_state && !original_input_items.is_empty() && state_storage.is_some() {
if let (true, false, Some(state_store)) = (should_manage_state, original_input_items.is_empty(), state_storage) {
// Extract Content-Encoding header to handle decompression for state parsing
let content_encoding = response_headers
.get("content-encoding")
@ -303,7 +303,7 @@ pub async fn llm_chat(
// Wrap with state management processor to store state after response completes
let state_processor = ResponsesStateProcessor::new(
base_processor,
state_storage.unwrap(),
state_store,
original_input_items,
resolved_model.clone(),
model_name.clone(),

View file

@ -133,7 +133,7 @@ impl ResponseHandler {
let response_headers = llm_response.headers();
let is_sse_streaming = response_headers
.get(hyper::header::CONTENT_TYPE)
.map_or(false, |v| {
.is_some_and(|v| {
v.to_str().unwrap_or("").contains("text/event-stream")
});

View file

@ -2,11 +2,9 @@
///
/// This module defines standard attribute keys following OTEL semantic conventions.
/// See: https://opentelemetry.io/docs/specs/semconv/
// =============================================================================
// Span Attributes - HTTP
// =============================================================================
/// Semantic conventions for HTTP-related span attributes
pub mod http {
/// HTTP request method

View file

@ -1,7 +1,6 @@
/// OpenTelemetry semantic convention constants for tracing
///
/// These constants ensure consistency across the codebase and prevent typos
/// Resource attribute keys following OTEL semantic conventions
pub mod resource {
/// Logical name of the service

View file

@ -286,7 +286,6 @@ pub struct ImageUrl {
}
/// A single message in a chat conversation
/// A tool call made by the assistant
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct ToolCall {
@ -569,7 +568,6 @@ pub enum OpenAIError {
// ============================================================================
/// Trait Implementations
/// ===========================================================================
/// Parameterized conversion for ChatCompletionsRequest
impl TryFrom<&[u8]> for ChatCompletionsRequest {
type Error = OpenAIStreamError;

View file

@ -34,10 +34,7 @@ where
}
pub fn decode_frame(&mut self) -> Option<DecodedFrame> {
match self.decoder.decode_frame(&mut self.buffer) {
Ok(frame) => Some(frame),
Err(_e) => None, // Fatal decode error
}
self.decoder.decode_frame(&mut self.buffer).ok()
}
pub fn buffer_mut(&mut self) -> &mut B {

View file

@ -11,7 +11,6 @@ use crate::apis::streaming_shapes::{
anthropic_streaming_buffer::AnthropicMessagesStreamBuffer,
chat_completions_streaming_buffer::OpenAIChatCompletionsStreamBuffer,
passthrough_streaming_buffer::PassthroughStreamBuffer,
responses_api_streaming_buffer::ResponsesAPIStreamBuffer,
};
use crate::clients::endpoints::SupportedAPIsFromClient;
@ -82,7 +81,7 @@ impl TryFrom<(&SupportedAPIsFromClient, &SupportedUpstreamAPIs)> for SseStreamBu
SseStreamBuffer::AnthropicMessages(AnthropicMessagesStreamBuffer::new()),
),
SupportedAPIsFromClient::OpenAIResponsesAPI(_) => Ok(SseStreamBuffer::OpenAIResponses(
Box::new(ResponsesAPIStreamBuffer::new()),
Box::default(),
)),
}
}

View file

@ -141,9 +141,7 @@ impl HttpContext for StreamContext {
let last_user_prompt = match deserialized_body
.messages
.iter()
.filter(|msg| msg.role == USER_ROLE)
.last()
.iter().rfind(|msg| msg.role == USER_ROLE)
{
Some(content) => content,
None => {
@ -156,9 +154,7 @@ impl HttpContext for StreamContext {
// convert prompt targets to ChatCompletionTool
let tool_calls: Vec<ChatCompletionTool> = self
.prompt_targets
.iter()
.map(|(_, pt)| pt.into())
.prompt_targets.values().map(|pt| pt.into())
.collect();
let mut metadata = deserialized_body.metadata.clone();

View file

@ -630,10 +630,10 @@ impl StreamContext {
}
};
if system_prompt.is_some() {
if let Some(system_prompt_text) = system_prompt {
let system_prompt_message = Message {
role: SYSTEM_ROLE.to_string(),
content: Some(ContentType::Text(system_prompt.unwrap())),
content: Some(ContentType::Text(system_prompt_text)),
model: None,
tool_calls: None,
tool_call_id: None,