Skip to main content

sim_lib_openai_server/codec_openai/
shapes.rs

1use sim_codec_chat::validate_chat_transcript;
2pub use sim_codec_chat::{OpenAiCodecOptions, OpenAiRequestOptions};
3use sim_kernel::{Expr, Result};
4
5/// Validated chat transcript expression accepted by `codec:openai`.
6#[derive(Clone, Debug, PartialEq)]
7pub struct ChatTranscript {
8    expr: Expr,
9}
10
11impl ChatTranscript {
12    /// Validates `expr` as a chat transcript and wraps it.
13    pub fn new(expr: Expr) -> Result<Self> {
14        validate_chat_transcript(&expr)?;
15        Ok(Self { expr })
16    }
17
18    /// Returns the wrapped transcript expression.
19    pub fn expr(&self) -> &Expr {
20        &self.expr
21    }
22
23    /// Consumes the wrapper and returns the transcript expression.
24    pub fn into_expr(self) -> Expr {
25        self.expr
26    }
27}