Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
827 changes: 827 additions & 0 deletions sgl-router/src/routers/conversations/handlers.rs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions sgl-router/src/routers/conversations/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Shared conversation management module.
//!
//! This module provides conversation CRUD operations that can be shared
//! across different router implementations.

mod handlers;

pub use handlers::*;
51 changes: 27 additions & 24 deletions sgl-router/src/routers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ use crate::protocols::{
responses::{ResponsesGetParams, ResponsesRequest},
};

pub mod conversations;
pub mod factory;
pub mod grpc;
pub mod header_utils;
pub mod http;
pub mod openai; // New refactored OpenAI router module
pub mod openai;
pub mod router_manager;

pub use factory::RouterFactory;
Expand Down Expand Up @@ -141,27 +142,37 @@ pub trait RouterTrait: Send + Sync + Debug {
model_id: Option<&str>,
) -> Response;

// Conversations API
/// Get router type name
fn router_type(&self) -> &'static str;

/// Check if this is a PD router
fn is_pd_mode(&self) -> bool {
self.router_type() == "pd"
}

/// Create a new conversation
async fn create_conversation(&self, _headers: Option<&HeaderMap>, _body: &Value) -> Response {
(
StatusCode::NOT_IMPLEMENTED,
"Conversations create endpoint not implemented",
"Conversations not supported by this router",
)
.into_response()
}

/// Get a conversation by ID
async fn get_conversation(
&self,
_headers: Option<&HeaderMap>,
_conversation_id: &str,
) -> Response {
(
StatusCode::NOT_IMPLEMENTED,
"Conversations get endpoint not implemented",
"Conversations not supported by this router",
)
.into_response()
}

/// Update a conversation
async fn update_conversation(
&self,
_headers: Option<&HeaderMap>,
Expand All @@ -170,35 +181,36 @@ pub trait RouterTrait: Send + Sync + Debug {
) -> Response {
(
StatusCode::NOT_IMPLEMENTED,
"Conversations update endpoint not implemented",
"Conversations not supported by this router",
)
.into_response()
}

/// Delete a conversation
async fn delete_conversation(
&self,
_headers: Option<&HeaderMap>,
_conversation_id: &str,
) -> Response {
(
StatusCode::NOT_IMPLEMENTED,
"Conversations delete endpoint not implemented",
"Conversations not supported by this router",
)
.into_response()
}

/// List items for a conversation
/// List items in a conversation
async fn list_conversation_items(
&self,
_headers: Option<&HeaderMap>,
_conversation_id: &str,
_limit: Option<usize>,
_order: Option<String>,
_after: Option<String>,
_order: Option<&str>,
_after: Option<&str>,
) -> Response {
(
StatusCode::NOT_IMPLEMENTED,
"Conversation items list endpoint not implemented",
"Conversations not supported by this router",
)
.into_response()
}
Expand All @@ -212,13 +224,12 @@ pub trait RouterTrait: Send + Sync + Debug {
) -> Response {
(
StatusCode::NOT_IMPLEMENTED,
"Conversation items create endpoint not implemented",
"Conversations not supported by this router",
)
.into_response()
}

/// Get a single conversation item
/// The `include` parameter is accepted but not yet implemented
/// Get a specific item from a conversation
async fn get_conversation_item(
&self,
_headers: Option<&HeaderMap>,
Expand All @@ -228,12 +239,12 @@ pub trait RouterTrait: Send + Sync + Debug {
) -> Response {
(
StatusCode::NOT_IMPLEMENTED,
"Conversation item get endpoint not implemented",
"Conversations not supported by this router",
)
.into_response()
}

/// Delete a conversation item
/// Delete an item from a conversation
async fn delete_conversation_item(
&self,
_headers: Option<&HeaderMap>,
Expand All @@ -242,16 +253,8 @@ pub trait RouterTrait: Send + Sync + Debug {
) -> Response {
(
StatusCode::NOT_IMPLEMENTED,
"Conversation item delete endpoint not implemented",
"Conversations not supported by this router",
)
.into_response()
}

/// Get router type name
fn router_type(&self) -> &'static str;

/// Check if this is a PD router
fn is_pd_mode(&self) -> bool {
self.router_type() == "pd"
}
}
Loading
Loading