pub struct TracedChat<'c, C: Config> { /* private fields */ }Expand description
A wrapper around async-openai’s Chat that automatically creates
Langfuse generation spans for every chat completion API call.
Implementations§
Source§impl<'c, C: Config> TracedChat<'c, C>
impl<'c, C: Config> TracedChat<'c, C>
Sourcepub async fn create(
&self,
request: CreateChatCompletionRequest,
) -> Result<CreateChatCompletionResponse, OpenAIError>
pub async fn create( &self, request: CreateChatCompletionRequest, ) -> Result<CreateChatCompletionResponse, OpenAIError>
Create a chat completion with automatic Langfuse tracing.
A generation span is created before the request and ended after the response is received. Model, usage, input, and output are recorded automatically.
§Errors
Returns the underlying OpenAIError if the API call fails.
Sourcepub async fn create_stream(
&self,
request: CreateChatCompletionRequest,
) -> Result<TracedStream, OpenAIError>
pub async fn create_stream( &self, request: CreateChatCompletionRequest, ) -> Result<TracedStream, OpenAIError>
Create a streaming chat completion with automatic Langfuse tracing.
A generation span is created before the request. The returned
TracedStream accumulates content from delta chunks and records
completion_start_time on the first chunk. The span is finalized
when the stream ends or is dropped.
§Errors
Returns the underlying OpenAIError if the API call fails.
Trait Implementations§
Auto Trait Implementations§
impl<'c, C> Freeze for TracedChat<'c, C>
impl<'c, C> !RefUnwindSafe for TracedChat<'c, C>
impl<'c, C> Send for TracedChat<'c, C>
impl<'c, C> Sync for TracedChat<'c, C>
impl<'c, C> Unpin for TracedChat<'c, C>
impl<'c, C> UnsafeUnpin for TracedChat<'c, C>
impl<'c, C> !UnwindSafe for TracedChat<'c, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more