use crate::error::MisarDevError;
use crate::sse::EventStream;
use crate::transport::Transport;
use crate::transport::body_or_empty;
use crate::transport::with_stream;
use reqwest::Method;
use serde_json::Value;
#[derive(Debug, Clone, Copy)]
pub struct ChatResource<'a> {
pub(crate) t: &'a Transport,
}
impl ChatResource<'_> {
pub async fn completions(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, "/v1/chat/completions", "", Some(body_or_empty(body))).await
}
pub async fn studio_stream(self, body: Option<Value>) -> Result<EventStream, MisarDevError> {
self.t.stream(Method::POST, "/chat", "", Some(body_or_empty(body)), None).await
}
pub async fn completions_stream(self, body: Option<Value>) -> Result<EventStream, MisarDevError> {
self.t.stream(Method::POST, "/v1/chat/completions", "", Some(with_stream(body)), Some("[DONE]")).await
}
}