You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/OpenAIKit/Models/ChatCompletionsRequest.swift
+18-17Lines changed: 18 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -26,27 +26,28 @@ public struct ChatCompletionsRequest: Codable {
26
26
publicvarpresencePenalty:Double?=nil
27
27
/// Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. The maximum value for `logprobs` is 5.
28
28
publicvarlogprobs:Int?=nil
29
-
/// An object specifying the format that the model must output.
30
-
/// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates
31
-
/// is valid JSON.
32
-
/// **Important:** when using JSON mode, you must also instruct the model to produce JSON yourself via a system or
33
-
/// user message. Without this, the model may generate an unending stream of whitespace until the generation reaches
34
-
/// the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content
35
-
/// may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the
36
-
/// conversation exceeded the max context length.
37
-
publicvarresponseFormat:ResponseFormat?
29
+
/// An object specifying the format that the model must output.
30
+
/// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates
31
+
/// is valid JSON.
32
+
/// **Important:** when using JSON mode, you must also instruct the model to produce JSON yourself via a system or
33
+
/// user message. Without this, the model may generate an unending stream of whitespace until the generation reaches
34
+
/// the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content
35
+
/// may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the
36
+
/// conversation exceeded the max context length.
37
+
publicvarresponseFormat:ResponseFormat?
38
38
/// Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
39
39
publicvarstop:[String]?=nil
40
40
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
41
41
publicvaruser:String?=nil
42
42
/// Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available
Copy file name to clipboardExpand all lines: Sources/OpenAIKit/OpenAIKitRequests/Chat.swift
+75-72Lines changed: 75 additions & 72 deletions
Original file line number
Diff line number
Diff line change
@@ -26,27 +26,28 @@ public extension OpenAIKit {
26
26
/// - logprobs: Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. The maximum value for `logprobs` is 5.
27
27
/// - stop: Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
28
28
/// - user: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
returnawaitwithCheckedContinuation{ continuation in
76
-
sendChatCompletion(
77
-
newMessage: newMessage,
78
-
previousMessages: previousMessages,
79
-
model: model,
80
-
maxTokens: maxTokens,
81
-
temperature: temperature,
82
-
n: n,
83
-
topP: topP,
84
-
frequencyPenalty: frequencyPenalty,
85
-
presencePenalty: presencePenalty,
86
-
logprobs: logprobs,
87
-
stop: stop,
88
-
responseFormat: responseFormat,
89
-
user: user
90
-
){ result in
77
+
sendChatCompletion(
78
+
newMessage: newMessage,
79
+
previousMessages: previousMessages,
80
+
model: model,
81
+
maxTokens: maxTokens,
82
+
temperature: temperature,
83
+
n: n,
84
+
topP: topP,
85
+
frequencyPenalty: frequencyPenalty,
86
+
presencePenalty: presencePenalty,
87
+
logprobs: logprobs,
88
+
stop: stop,
89
+
responseFormat: responseFormat,
90
+
user: user
91
+
){ result in
91
92
continuation.resume(returning: result)
92
93
}
93
94
}
@@ -114,20 +115,21 @@ public extension OpenAIKit {
114
115
/// - logprobs: Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. The maximum value for `logprobs` is 5.
115
116
/// - stop: Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
116
117
/// - user: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
openAI?.sendChatCompletion(newMessage:AIMessage(role:.user, content:"Write a 100-word essay about the earth"), previousMessages:[AIMessage(role:.system, content:"You are a helpful assistant designed to output JSON.")], model:.custom("gpt-3.5-turbo-1106"), maxTokens:300, temperature:0.7, responseFormat:.json){ result in
0 commit comments