| 589 | /// Trait that all LLM providers must implement |
| 590 | #[async_trait] |
| 591 | pub 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 |
| 634 | pub struct LlmProvider { |
nothing calls this directly
no outgoing calls
no test coverage detected