swiftide_integrations/groq/mod.rs
1//! This module provides integration with `Groq`'s API, enabling the use of language models within
2//! the Swiftide project. It includes the `Groq` struct for managing API clients and default options
3//! for prompt models. The module is conditionally compiled based on the "groq" feature flag.
4
5use crate::openai;
6
7use self::config::GroqConfig;
8
9mod config;
10
11/// The `Groq` struct encapsulates a `Groq` client that implements [`swiftide_core::SimplePrompt`]
12///
13/// There is also a builder available.
14///
15/// By default it will look for a `GROQ_API_KEY` environment variable. Note that a model
16/// always needs to be set, either with [`Groq::with_default_prompt_model`] or via the builder.
17/// You can find available models in the Groq documentation.
18///
19/// Under the hood it uses [`async_openai`], with the Groq openai mapping. This means
20/// some features might not work as expected. See the Groq documentation for details.
21pub type Groq = openai::GenericOpenAI<GroqConfig>;
22pub type GroqBuilder = openai::GenericOpenAIBuilder<GroqConfig>;
23pub type GroqBuilderError = openai::GenericOpenAIBuilderError;
24pub use openai::{Options, OptionsBuilder, OptionsBuilderError};
25
26impl Groq {
27 pub fn builder() -> GroqBuilder {
28 GroqBuilder::default()
29 }
30}
31
32impl Default for Groq {
33 fn default() -> Self {
34 Self::builder().build().unwrap()
35 }
36}