1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// GENERATED by scripts/generate-sdk-resources.mjs from sdks/manifest.json.
// Do not edit by hand — change the route, run `pnpm sdk:sync`, and regenerate.
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;
/// The `chat` resource — 3 operation(s).
///
/// OpenAI-compatible chat completions (plain and streamed) and the studio build conversation stream.
///
/// Reached through [`crate::MisarDev::chat`].
#[derive(Debug, Clone, Copy)]
pub struct ChatResource<'a> {
pub(crate) t: &'a Transport,
}
impl ChatResource<'_> {
/// `POST /v1/chat/completions`
///
/// misardev:method chat.completions
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
}
/// `POST /chat`
///
/// Yields each Server-Sent Event as it arrives, until the server closes the stream.
///
/// misardev:stream chat.studioStream
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
}
/// `POST /v1/chat/completions`
///
/// Sets `"stream": true` for you and yields each chunk until `[DONE]`.
///
/// misardev:stream chat.completionsStream
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
}
}