pub struct RuntimeClient { /* private fields */ }Expand description
HTTP access to the serving runtime.
Tokenization always goes through the runtime unless a local tokenizer is configured, so the bridge never needs a copy of the model’s vocabulary. Rendering goes through it too unless a local renderer is configured.
Implementations§
Source§impl RuntimeClient
impl RuntimeClient
Sourcepub fn new(
client: Client,
base: impl Into<String>,
model: impl Into<String>,
api_key: Option<String>,
) -> Self
pub fn new( client: Client, base: impl Into<String>, model: impl Into<String>, api_key: Option<String>, ) -> Self
Point a client at the runtime’s native base URL.
Sourcepub async fn apply_template(
&self,
messages: &[ChatMessage],
chat_template_kwargs: &Value,
) -> Result<String>
pub async fn apply_template( &self, messages: &[ChatMessage], chat_template_kwargs: &Value, ) -> Result<String>
Render messages with the runtime’s own chat template.
Sourcepub async fn tokenize(&self, content: &str) -> Result<Vec<u32>>
pub async fn tokenize(&self, content: &str) -> Result<Vec<u32>>
Tokenize without special tokens, matching fastjev’s encode_prompt.
Sourcepub async fn detokenize(&self, tokens: &[u32]) -> Result<String>
pub async fn detokenize(&self, tokens: &[u32]) -> Result<String>
Decode tokens for the answer-slot round-trip check.
Auto Trait Implementations§
impl !RefUnwindSafe for RuntimeClient
impl !UnwindSafe for RuntimeClient
impl Freeze for RuntimeClient
impl Send for RuntimeClient
impl Sync for RuntimeClient
impl Unpin for RuntimeClient
impl UnsafeUnpin for RuntimeClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more