orchestral_runtime/api/
service.rs1use async_trait::async_trait;
2use tokio::sync::broadcast;
3
4use orchestral_core::store::Event;
5
6use super::{
7 ApiError, HistoryEventView, InteractionSubmitRequest, InteractionSubmitResponse, ThreadView,
8};
9
10#[async_trait]
11pub trait ApiService: Send + Sync {
12 async fn create_thread(&self, preferred_id: Option<String>) -> Result<ThreadView, ApiError>;
13 async fn get_thread(&self, thread_id: &str) -> Result<ThreadView, ApiError>;
14 async fn submit_interaction(
15 &self,
16 thread_id: &str,
17 request: InteractionSubmitRequest,
18 ) -> Result<InteractionSubmitResponse, ApiError>;
19 async fn query_history(
20 &self,
21 thread_id: &str,
22 limit: usize,
23 ) -> Result<Vec<HistoryEventView>, ApiError>;
24 async fn subscribe_events(
25 &self,
26 thread_id: &str,
27 ) -> Result<broadcast::Receiver<Event>, ApiError>;
28}