diff --git a/src/gloq.gleam b/src/gloq.gleam index cf4a3fd..8bf163b 100644 --- a/src/gloq.gleam +++ b/src/gloq.gleam @@ -88,6 +88,8 @@ pub fn with_model( GroqRequestBuilder(..builder, model: model) } +/// Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency +/// in the text so far, decreasing the model's likelihood to repeat the same line verbatim. pub fn with_frequency_penalty( builder: GroqRequestBuilder, frequency_penalty: Float, @@ -95,6 +97,8 @@ pub fn with_frequency_penalty( GroqRequestBuilder(..builder, frequency_penalty: Some(frequency_penalty)) } +/// This is not yet supported by any of our models. Whether to return log probabilities of the output tokens or not. +/// If true, returns the log probabilities of each output token returned in the `content` of `message`. pub fn with_logprobs( builder: GroqRequestBuilder, logprobs: Bool, @@ -102,6 +106,8 @@ pub fn with_logprobs( GroqRequestBuilder(..builder, logprobs: Some(logprobs)) } +/// The maximum number of tokens that can be generated in the chat completion. +/// The total length of input tokens and generated tokens is limited by the model's context length. pub fn with_max_tokens( builder: GroqRequestBuilder, max_tokens: Int, @@ -109,10 +115,13 @@ pub fn with_max_tokens( GroqRequestBuilder(..builder, max_tokens: Some(max_tokens)) } +/// How many chat completion choices to generate for each input message. +/// Note that the current moment, only n=1 is supported. Other values will result in a 400 response. pub fn with_n(builder: GroqRequestBuilder, n: Int) -> GroqRequestBuilder { GroqRequestBuilder(..builder, n: Some(n)) } +/// Whether to enable parallel function calling during tool use. pub fn with_parallel_tool_calls( builder: GroqRequestBuilder, parallel_tool_calls: Bool, @@ -120,6 +129,8 @@ pub fn with_parallel_tool_calls( GroqRequestBuilder(..builder, parallel_tool_calls: Some(parallel_tool_calls)) } +/// Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they +/// appear in the text so far, increasing the model's likelihood to talk about new topics. pub fn with_presence_penalty( builder: GroqRequestBuilder, presence_penalty: Float, @@ -127,10 +138,15 @@ pub fn with_presence_penalty( GroqRequestBuilder(..builder, presence_penalty: Some(presence_penalty)) } +/// If specified, our system will make a best effort to sample deterministically, such that +/// repeated requests with the same seed and parameters should return the same result. +/// Determinism is not guaranteed, and you should refer to the system_fingerprint response +/// parameter to monitor changes in the backend. pub fn with_seed(builder: GroqRequestBuilder, seed: Int) -> GroqRequestBuilder { GroqRequestBuilder(..builder, seed: Some(seed)) } +/// Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. pub fn with_stop( builder: GroqRequestBuilder, stop: String, @@ -138,6 +154,8 @@ pub fn with_stop( GroqRequestBuilder(..builder, stop: Some(stop)) } +/// If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, +/// with the stream terminated by a data: [DONE] message. pub fn with_stream( builder: GroqRequestBuilder, stream: Bool, @@ -145,6 +163,8 @@ pub fn with_stream( GroqRequestBuilder(..builder, stream: Some(stream)) } +/// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower +/// values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both pub fn with_temperature( builder: GroqRequestBuilder, temperature: Float, @@ -152,6 +172,10 @@ pub fn with_temperature( GroqRequestBuilder(..builder, temperature: Some(temperature)) } +/// Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. +/// auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. +/// Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool. none is the default +/// when no tools are present. auto is the default if tools are present. pub fn with_tool_choice( builder: GroqRequestBuilder, tool_choice: String, @@ -159,6 +183,8 @@ pub fn with_tool_choice( GroqRequestBuilder(..builder, tool_choice: Some(tool_choice)) } +/// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. +/// So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. pub fn with_top_p( builder: GroqRequestBuilder, top_p: Float,