pub struct GroqModel { /* private fields */ }Available on crate feature
groq only.Expand description
Groq model client.
Groq uses an OpenAI-compatible API, so this wraps OpenAIChatModel with the Groq-specific base URL and settings.
Implementations§
Source§impl GroqModel
impl GroqModel
Sourcepub fn new(
model_name: impl Into<String>,
api_key: impl Into<String>,
) -> GroqModel
pub fn new( model_name: impl Into<String>, api_key: impl Into<String>, ) -> GroqModel
Create a new Groq model with an API key.
Sourcepub fn from_env(model_name: impl Into<String>) -> Result<GroqModel, ModelError>
pub fn from_env(model_name: impl Into<String>) -> Result<GroqModel, ModelError>
Create from environment variable GROQ_API_KEY.
Sourcepub fn llama_70b(api_key: impl Into<String>) -> GroqModel
pub fn llama_70b(api_key: impl Into<String>) -> GroqModel
Create a Llama 3.1 70B Versatile model.
Sourcepub fn llama_70b_from_env() -> Result<GroqModel, ModelError>
pub fn llama_70b_from_env() -> Result<GroqModel, ModelError>
Create a Llama 3.1 70B model from environment.
Sourcepub fn model_name(&self) -> &str
pub fn model_name(&self) -> &str
Get the model name.
Trait Implementations§
Source§impl Model for GroqModel
impl Model for GroqModel
Source§fn profile(&self) -> &ModelProfile
fn profile(&self) -> &ModelProfile
Get the model profile (capabilities, schema transforms).
Source§fn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
GroqModel: 'async_trait,
fn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
GroqModel: 'async_trait,
Make a request to the model.
Source§fn request_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ModelResponseStreamEvent, ModelError>> + Send>>, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
GroqModel: 'async_trait,
fn request_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ModelResponseStreamEvent, ModelError>> + Send>>, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
GroqModel: 'async_trait,
Make a streaming request to the model. Read more
Source§fn identifier(&self) -> String
fn identifier(&self) -> String
Get the full model identifier.
Source§fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_messages: &'life1 [ModelRequest],
) -> Pin<Box<dyn Future<Output = Result<u64, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_messages: &'life1 [ModelRequest],
) -> Pin<Box<dyn Future<Output = Result<u64, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Count tokens for messages (if supported). Read more
Source§fn supports(&self, capability: ModelCapability) -> bool
fn supports(&self, capability: ModelCapability) -> bool
Check if the model supports a specific capability.
Auto Trait Implementations§
impl Freeze for GroqModel
impl !RefUnwindSafe for GroqModel
impl Send for GroqModel
impl Sync for GroqModel
impl Unpin for GroqModel
impl !UnwindSafe for GroqModel
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