rig/client/
transcription.rs1#[allow(deprecated)]
2use crate::transcription::TranscriptionModelDyn;
3use crate::transcription::{
4 TranscriptionError, TranscriptionModel, TranscriptionRequest, TranscriptionResponse,
5};
6use std::sync::Arc;
7
8pub trait TranscriptionClient {
11 type TranscriptionModel: TranscriptionModel;
13
14 fn transcription_model(&self, model: impl Into<String>) -> Self::TranscriptionModel;
27}
28
29#[allow(deprecated)]
30#[deprecated(
31 since = "0.25.0",
32 note = "`DynClientBuilder` and related features have been deprecated and will be removed in a future release. In this case, use `TranscriptionClient` instead."
33)]
34pub trait TranscriptionClientDyn {
35 fn transcription_model<'a>(&self, model: &str) -> Box<dyn TranscriptionModelDyn + 'a>;
37}
38
39#[allow(deprecated)]
40impl<M, T> TranscriptionClientDyn for T
41where
42 T: TranscriptionClient<TranscriptionModel = M>,
43 M: TranscriptionModel + 'static,
44{
45 fn transcription_model<'a>(&self, model: &str) -> Box<dyn TranscriptionModelDyn + 'a> {
46 Box::new(self.transcription_model(model))
47 }
48}
49
50#[allow(deprecated)]
51#[deprecated(
52 since = "0.25.0",
53 note = "`DynClientBuilder` and related features have been deprecated and will be removed in a future release."
54)]
55#[derive(Clone)]
57pub struct TranscriptionModelHandle<'a> {
58 pub inner: Arc<dyn TranscriptionModelDyn + 'a>,
59}
60
61#[allow(deprecated)]
62impl TranscriptionModel for TranscriptionModelHandle<'_> {
63 type Response = ();
64 type Client = ();
65
66 fn make(_: &Self::Client, _: impl Into<String>) -> Self {
69 panic!(
70 "Invalid method: Cannot make a TranscriptionModelHandle from a client + model identifier"
71 )
72 }
73
74 async fn transcription(
75 &self,
76 request: TranscriptionRequest,
77 ) -> Result<TranscriptionResponse<Self::Response>, TranscriptionError> {
78 self.inner.transcription(request).await
79 }
80}