MCPcopy Create free account
hub / github.com/docker/model-runner / Provider

Interface Provider

model-cli/src/providers/mod.rs:18–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16/// Trait that every LLM provider must implement.
17#[async_trait::async_trait]
18pub trait Provider: Send + Sync {
19 /// Perform a non-streaming chat completion.
20 async fn chat_completion(
21 &self,
22 request: &ChatCompletionRequest,
23 params: &ModelParams,
24 ) -> Result<ChatCompletionResponse, AppError>;
25
26 /// Perform a streaming chat completion, returning an SSE byte stream.
27 async fn chat_completion_stream(
28 &self,
29 request: &ChatCompletionRequest,
30 params: &ModelParams,
31 ) -> Result<ByteStream, AppError>;
32
33 /// Perform an embedding request.
34 async fn embedding(
35 &self,
36 request: &EmbeddingRequest,
37 params: &ModelParams,
38 ) -> Result<EmbeddingResponse, AppError>;
39}
40
41/// Resolve the correct provider implementation for a given provider name.
42pub fn resolve_provider(provider_name: &str) -> Result<Box<dyn Provider>, AppError> {

Callers

nothing calls this directly

Implementers 2

anthropic.rsmodel-cli/src/providers/anthropic.rs
openai.rsmodel-cli/src/providers/openai.rs

Calls

no outgoing calls

Tested by

no test coverage detected