Skip to main content

Daemon

Struct Daemon 

Source
pub struct Daemon { /* private fields */ }

Implementations§

Source§

impl Daemon

Source

pub fn new( store: SessionStore, host: EngineHost, codec: Box<dyn TextCodec + Send + Sync>, max_lanes: usize, ) -> Daemon

Source

pub fn with_park( store: SessionStore, host: EngineHost, codec: Box<dyn TextCodec + Send + Sync>, max_lanes: usize, park_dir: Option<PathBuf>, ) -> Daemon

Source

pub fn with_options( store: SessionStore, host: EngineHost, codec: Box<dyn TextCodec + Send + Sync>, opts: DaemonOptions, ) -> Result<Daemon, DaemonError>

Source

pub fn reload_with( &self, build: impl FnOnce() -> Result<(EngineHost, Box<dyn TextCodec + Send + Sync>), DaemonError>, ) -> Result<(), DaemonError>

Source

pub fn on_retired(&self, reload: Box<dyn Fn() + Send + Sync>)

Source

pub fn max_stream_tokens(&self) -> u64

Source

pub fn session_fits( &self, session: u64, thinking: Option<bool>, ) -> Result<(), DaemonError>

Source

pub fn fim_fits(&self, req: &FimRequest) -> Result<(), DaemonError>

Source

pub fn complete( &self, prefix: &str, suffix: &str, mode: u8, max_tokens: u32, ) -> Result<Completion, DaemonError>

Source

pub fn complete_streaming( &self, req: &FimRequest, on_text: impl FnMut(&str, usize) -> ControlFlow<()>, ) -> Result<Completion, DaemonError>

Source

pub fn attach_fim_satellite( &self, name: impl Into<String>, satellite: Arc<Daemon>, ) -> Result<(), DaemonError>

Source

pub fn fim_satellite_name(&self) -> Option<String>

Source

pub fn fim_satellite(&self) -> Option<Arc<Daemon>>

Source

pub fn fim_supported(&self) -> bool

Source

pub fn completion_bucket(&self) -> BucketConfig

Source

pub fn note_completion_throttled(&self)

Source

pub fn generate_tokens( &self, stream: Vec<u32>, params: GenParams, max_tokens: u32, deadline_ms: u64, ) -> Result<(Vec<u32>, bool), DaemonError>

Source

pub fn generate_tokens_streaming( &self, stream: Vec<u32>, params: GenParams, max_tokens: u32, deadline_ms: u64, extras: GenExtras, on_tokens: impl FnMut(&[u32]) -> ControlFlow<()>, ) -> Result<(Vec<u32>, u32, bool), DaemonError>

Source

pub fn forward_stage( &self, tokens: Vec<u32>, start_layer: u32, end_layer: u32, hidden_in: Option<Vec<u8>>, ) -> Result<StageOutput, DaemonError>

Source

pub fn generate_tokens_constrained( &self, stream: Vec<u32>, params: GenParams, max_tokens: u32, deadline_ms: u64, json_schema: &str, ) -> Result<(Vec<u32>, bool), DaemonError>

Source

pub fn put_media(&self, bytes: &[u8]) -> Result<String, DaemonError>

Source

pub fn media_pool(&self) -> &MediaPool

Source

pub fn append_image( &self, session: u64, role: u32, blob: &str, pre_text: &str, post_text: &str, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn gc_media(&self) -> Result<(usize, usize), DaemonError>

Source

pub fn speculation(&self) -> Option<SpeculationGrant>

Source

pub fn tool_lease_ms(&self) -> u64

Source

pub fn inspect(&self, session: u64) -> Result<Inspection, DaemonError>

Source

pub fn files(&self) -> &FileStore

Source

pub fn batches(&self) -> Arc<BatchStore> ⓘ

Source

pub fn responses(&self) -> &ResponseStore

Source

pub fn tokenize(&self, text: &str) -> Vec<u32>

Source

pub fn grammar_create(&self, json_schema: &str) -> Result<u32, DaemonError>

Source

pub fn grammar_free(&self, grammar_handle: u32)

Source

pub fn logit_bias_create( &self, tokens: &[i32], values: &[f32], ) -> Result<u32, DaemonError>

Source

pub fn logit_bias_free(&self, handle: u32)

Source

pub fn lora_load( &self, adapter_path: &str, ) -> Result<Option<String>, DaemonError>

Source

pub fn lora_unload(&self) -> Result<Option<String>, DaemonError>

Source

pub fn lora_id(&self) -> Result<Option<String>, DaemonError>

Source

pub fn try_model_sampling_defaults(&self) -> Option<ModelSamplingDefaults>

Source

pub fn model_sampling_defaults(&self) -> ModelSamplingDefaults

Source

pub fn capability_descriptor(&self) -> Option<Value>

Source

pub fn runtime_id(&self) -> Option<&'static str>

Source

pub fn needs_reload(&self) -> Option<String>

Source

pub fn capabilities(&self) -> Capabilities

Source

pub fn require( &self, section: &str, key: &str, code: &'static str, param: Option<&str>, what: &str, ) -> Result<(), DaemonError>

Source

pub fn chat_template(&self) -> Option<String>

Source

pub fn transcribe( &self, audio_path: &str, params: &TranscribeParams, ) -> Result<Transcription, DaemonError>

Source

pub fn transcribe_as( &self, audio_path: &str, params: &TranscribeParams, class: Option<u8>, ) -> Result<Transcription, DaemonError>

Source

pub fn transcribe_streaming( &self, audio_path: &str, params: &TranscribeParams, ) -> Result<(Receiver<TranscribeSegmentMsg>, Receiver<Result<Transcription, DaemonError>>), DaemonError>

Source

pub fn transcribe_streaming_as( &self, audio_path: &str, params: &TranscribeParams, class: Option<u8>, ) -> Result<(Receiver<TranscribeSegmentMsg>, Receiver<Result<Transcription, DaemonError>>), DaemonError>

Source

pub fn embed(&self, text: &str) -> Result<Vec<f32>, DaemonError>

Source

pub fn embed_as( &self, text: &str, class: Option<u8>, ) -> Result<Vec<f32>, DaemonError>

Source

pub fn detokenize(&self, tokens: &[u32]) -> String

Source

pub fn metrics_text(&self) -> String

Source

pub fn set_background_tick_divisor(&self, divisor: u32)

Source

pub fn set_qos( &self, session: u64, class: u8, batch_invariant: bool, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn sched_stats(&self) -> Arc<SchedStats> ⓘ

Source

pub fn cancel_registry(&self) -> Arc<CancelSet> ⓘ

Source

pub fn active_registry(&self) -> Arc<Mutex<HashSet<u64>>> ⓘ

Source

pub fn store(&self) -> Arc<Mutex<SessionStore>> ⓘ

Source

pub fn bus(&self) -> Arc<SessionBus> ⓘ

Source

pub fn shutdown(&self)

Source

pub fn signal_shutdown(&self)

Source

pub fn create( &self, parent: Option<u64>, params: GenParams, ) -> Result<u64, DaemonError>

Source

pub fn fork( &self, parent: u64, at_event: u64, params: Option<GenParams>, ) -> Result<u64, DaemonError>

Source

pub fn tree(&self) -> Vec<(u64, Option<u64>, u64)>

Source

pub fn sessions(&self, include_archived: bool) -> Vec<SessionSummary>

Source

pub fn set_meta( &self, session: u64, expected_version: u64, title: Option<String>, archived: Option<bool>, ) -> Result<u64, DaemonError>

Source

pub fn rebase( &self, parent: u64, edits: Vec<RebaseEdit>, params: Option<GenParams>, ) -> Result<u64, DaemonError>

Source

pub fn trim(&self, session: u64, to_event: u64) -> Result<u64, DaemonError>

Source

pub fn pin(&self, session: u64, ttl_ms: u64) -> Result<u64, DaemonError>

Source

pub fn pin_prefix( &self, anchor: Option<u64>, stream: &[u32], upto: usize, ttl_ms: u64, ) -> Result<u64, DaemonError>

Source

pub fn pinned_prefix_tokens( &self, stream: &[u32], uptos: &[usize], ) -> Result<u64, DaemonError>

Source

pub fn unanchor_pins(&self, session: u64)

Source

pub fn purge( &self, session: u64, expected_generation: u64, mode: PurgeMode, ) -> Result<Vec<u64>, DaemonError>

Source

pub fn append( &self, session: u64, text: Option<String>, span: Vec<u32>, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn append_message( &self, session: u64, role: u32, text: String, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn renders_per_message(&self) -> bool

Source

pub fn append_system_full( &self, session: u64, system: Option<String>, tool_jsons: Vec<String>, kwargs: &Map<String, Value>, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn append_system( &self, session: u64, system: Option<String>, tools: Vec<String>, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn supports_reasoning_effort(&self) -> bool

Source

pub fn reasoning_effort_levels(&self) -> Vec<&'static str>

Source

pub fn supports_enable_thinking(&self) -> bool

Source

pub fn validate_template_kwargs( &self, kwargs: &Map<String, Value>, ) -> Result<(), String>

Source

pub fn append_conversation( &self, session: u64, messages: &[ChatMessage], tools: &[String], kwargs: &Map<String, Value>, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn response_format_tag(&self, json_schema: &str) -> Option<String>

Source

pub fn tool_structural_tag( &self, tool_jsons: &[String], at_least_one: bool, ) -> Option<String>

Source

pub fn grammar_create_structural( &self, tag_json: &str, ) -> Result<u32, DaemonError>

Source

pub fn parse_tool_call(&self, raw: &str) -> Option<(String, String)>

Source

pub fn named_tool_call(&self, raw: &str) -> Option<(String, String)>

Source

pub fn parse_tool_call_with( &self, raw: &str, schemas: Option<&ToolSchemas>, ) -> Option<(String, String)>

Source

pub fn tool_fragment_mode(&self) -> ToolFragmentMode

Source

pub fn tool_call_grammar(&self, tool_jsons: &[String]) -> Option<String>

Source

pub fn append_system_with_tools( &self, session: u64, system: Option<String>, tool_jsons: Vec<String>, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn append_assistant_with_tool_calls( &self, session: u64, content: String, calls: Vec<(String, String)>, after_query: bool, ) -> Result<CommittedEvent, DaemonError>

after_query: no user query follows this turn in the conversation (a step of a tool loop), which some templates render differently.

Source

pub fn append_tool_result( &self, session: u64, call_id: u64, content: String, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn append_block( &self, session: u64, role: u32, kind: u32, payload: String, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn request_permission( &self, session: u64, call_id: u64, text: String, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn respond_permission( &self, session: u64, request_id: u64, granted: bool, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn request_tool_cancel( &self, session: u64, call_id: u64, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn append_tool_outcome( &self, session: u64, call_id: u64, outcome: u8, note: String, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn ledger( &self, session: u64, ) -> Result<Vec<(u64, LedgerEntry)>, DaemonError>

Source

pub fn append_tool_history( &self, session: u64, content: String, ) -> Result<CommittedEvent, DaemonError>

Source

pub fn open_tool_calls( &self, session: u64, ) -> Result<Vec<(u64, String, String)>, DaemonError>

Source

pub fn generate( &self, session: u64, max_tokens: u32, ) -> Result<GenerateOutcome, DaemonError>

Source

pub fn generate_streaming( &self, session: u64, max_tokens: u32, on_event: impl FnMut(&CommittedEvent) -> Result<(), DaemonError>, ) -> Result<GenerateOutcome, DaemonError>

Source

pub fn generate_streaming_ex( &self, session: u64, max_tokens: u32, extras: GenExtras, on_event: impl FnMut(&CommittedEvent) -> Result<(), DaemonError>, ) -> Result<GenerateOutcome, DaemonError>

Source

pub fn generate_streaming_ex_lp( &self, session: u64, max_tokens: u32, extras: GenExtras, on_event: impl FnMut(&CommittedEvent) -> Result<(), DaemonError>, on_logprobs: impl FnMut(&[TokenLogprob]), ) -> Result<GenerateOutcome, DaemonError>

Source

pub fn generate_streaming_delta( &self, session: u64, max_tokens: u32, extras: GenExtras, on_event: impl FnMut(&CommittedEvent) -> Result<(), DaemonError>, on_logprobs: impl FnMut(&[TokenLogprob]), on_delta: impl FnMut(u32, &str, u32), ) -> Result<GenerateOutcome, DaemonError>

Source

pub fn read( &self, session: u64, cursor: u64, ) -> Result<Vec<CommittedEvent>, DaemonError>

Source

pub fn session_ids(&self) -> Vec<u64>

Auto Trait Implementations§

§

impl !Freeze for Daemon

§

impl !RefUnwindSafe for Daemon

§

impl !UnwindSafe for Daemon

§

impl Send for Daemon

§

impl Sync for Daemon

§

impl Unpin for Daemon

§

impl UnsafeUnpin for Daemon

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more