MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / LlmProviderTrait

Interface LlmProviderTrait

core/src/llm/providers.rs:591–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

589/// Trait that all LLM providers must implement
590#[async_trait]
591pub trait LlmProviderTrait: Send + Sync {
592 /// Get the provider name
593 fn provider_name(&self) -> &str;
594
595 /// Get the model name
596 fn model_name(&self) -> &str;
597
598 /// Send a request to the LLM and get a response
599 async fn complete(&self, request: LlmRequest) -> GraphBitResult<LlmResponse>;
600
601 /// Stream a response from the LLM (optional implementation)
602 async fn stream(
603 &self,
604 _request: LlmRequest,
605 ) -> GraphBitResult<Box<dyn futures::Stream<Item = GraphBitResult<LlmResponse>> + Unpin + Send>>
606 {
607 Err(crate::errors::GraphBitError::config(
608 "Streaming not supported by this provider",
609 ))
610 }
611
612 /// Check if the provider supports streaming
613 fn supports_streaming(&self) -> bool {
614 false
615 }
616
617 /// Check if the provider supports function calling
618 fn supports_function_calling(&self) -> bool {
619 false
620 }
621
622 /// Get the maximum context length for this provider/model
623 fn max_context_length(&self) -> Option<u32> {
624 None
625 }
626
627 /// Get the cost per token for this provider/model
628 fn cost_per_token(&self) -> Option<(f64, f64)> {
629 None // (input_cost, output_cost)
630 }
631}
632
633/// Wrapper for LLM providers
634pub struct LlmProvider {

Callers

nothing calls this directly

Implementers 15

huggingface.rscore/src/llm/huggingface.rs
anthropic.rscore/src/llm/anthropic.rs
azurellm.rscore/src/llm/azurellm.rs
perplexity.rscore/src/llm/perplexity.rs
mistralai.rscore/src/llm/mistralai.rs
openai.rscore/src/llm/openai.rs
replicate.rscore/src/llm/replicate.rs
fireworks.rscore/src/llm/fireworks.rs
ai21.rscore/src/llm/ai21.rs
togetherai.rscore/src/llm/togetherai.rs
openrouter.rscore/src/llm/openrouter.rs
xai.rscore/src/llm/xai.rs

Calls

no outgoing calls

Tested by

no test coverage detected