Skip to content

Commit

Permalink
updated based on changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrochabrun committed Jun 21, 2024
1 parent 1d535a2 commit 60ec637
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public struct ChatCompletionParameters: Encodable {
public var functions: [ChatFunction]?
/// A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.
public var tools: [Tool]?
/// Whether to enable parallel function calling during tool use. Defaults to true.
public var parallelToolCalls: Bool?
/// Modify the likelihood of specified tokens appearing in the completion.
/// Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. Defaults to null.
public var logitBias: [Int: Double]?
Expand All @@ -48,6 +50,11 @@ public struct ChatCompletionParameters: Encodable {
/// Setting to `{ type: "json_object" }` enables `JSON` mode, which guarantees the message the model generates is valid JSON.
///Important: when using `JSON` mode you must still instruct the model to produce `JSON` yourself via some conversation message, for example via your system message. If you don't do this, the model may generate an unending stream of whitespace until the generation reaches the token limit, which may take a lot of time and give the appearance of a "stuck" request. Also note that the message content may be partial (i.e. cut off) if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
public var responseFormat: ResponseFormat?
/// Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:
/// If set to 'auto', the system will utilize scale tier credits until they are exhausted.
/// If set to 'default', the request will be processed in the shared cluster.
/// When this parameter is set, the response body will include the service_tier utilized.
public var serviceTier: String?
/// This feature is in `Beta`. 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.
public var seed: Int?
Expand Down Expand Up @@ -418,6 +425,15 @@ public struct ChatCompletionParameters: Encodable {
}
}

public enum ServiceTier: String, Encodable {
/// Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:
/// If set to 'auto', the system will utilize scale tier credits until they are exhausted.
/// If set to 'default', the request will be processed in the shared cluster.
/// When this parameter is set, the response body will include the service_tier utilized.
case auto
case `default`
}

public struct StreamOptions: Encodable {
/// If set, an additional chunk will be streamed before the data: [DONE] message.
/// The usage field on this chunk shows the token usage statistics for the entire request,
Expand All @@ -437,6 +453,7 @@ public struct ChatCompletionParameters: Encodable {
case toolChoice = "tool_choice"
case functionCall = "function_call"
case tools
case parallelToolCalls = "parallel_tool_calls"
case functions
case logitBias = "logit_bias"
case logprobs
Expand All @@ -446,6 +463,7 @@ public struct ChatCompletionParameters: Encodable {
case responseFormat = "response_format"
case presencePenalty = "presence_penalty"
case seed
case serviceTier = "service_tier"
case stop
case stream
case streamOptions = "stream_options"
Expand All @@ -462,13 +480,15 @@ public struct ChatCompletionParameters: Encodable {
toolChoice: ToolChoice? = nil,
functions: [ChatFunction]? = nil,
tools: [Tool]? = nil,
parallelToolCalls: Bool? = nil,
logitBias: [Int: Double]? = nil,
logProbs: Bool? = nil,
topLogprobs: Int? = nil,
maxTokens: Int? = nil,
n: Int? = nil,
responseFormat: ResponseFormat? = nil,
presencePenalty: Double? = nil,
serviceTier: ServiceTier? = nil,
seed: Int? = nil,
stop: [String]? = nil,
temperature: Double? = nil,
Expand All @@ -482,13 +502,15 @@ public struct ChatCompletionParameters: Encodable {
self.toolChoice = toolChoice
self.functions = functions
self.tools = tools
self.parallelToolCalls = parallelToolCalls
self.logitBias = logitBias
self.logprobs = logProbs
self.topLogprobs = topLogprobs
self.maxTokens = maxTokens
self.n = n
self.responseFormat = responseFormat
self.presencePenalty = presencePenalty
self.serviceTier = serviceTier?.rawValue
self.seed = seed
self.stop = stop
self.temperature = temperature
Expand Down

0 comments on commit 60ec637

Please sign in to comment.