Skip to content

Commit

Permalink
Merge pull request #27 from AryaanSheth/update-docs
Browse files Browse the repository at this point in the history
Add docs to new functions
  • Loading branch information
AryaanSheth authored Sep 11, 2024
2 parents f0752c7 + 7d6790c commit 02ace33
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/gloq.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -88,77 +88,103 @@ 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,
) -> GroqRequestBuilder {
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,
) -> GroqRequestBuilder {
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,
) -> GroqRequestBuilder {
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,
) -> GroqRequestBuilder {
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,
) -> GroqRequestBuilder {
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,
) -> GroqRequestBuilder {
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,
) -> GroqRequestBuilder {
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,
) -> GroqRequestBuilder {
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,
) -> GroqRequestBuilder {
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,
Expand Down

0 comments on commit 02ace33

Please sign in to comment.