Skip to content

Commit

Permalink
Added missing initialisers.
Browse files Browse the repository at this point in the history
  • Loading branch information
randomeizer committed Jul 17, 2022
1 parent 72e9fb0 commit 01b87b4
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
62 changes: 62 additions & 0 deletions Sources/OpenAIGPT3/Completions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,42 @@ extension Completions {
public let bestOf: Percentage?
public let logitBias: [Token: Double]?
public let user: String?

public init(
model: Model.ID,
prompt: Prompt? = nil,
suffix: String? = nil,
maxTokens: Int? = nil,
temperature: Percentage? = nil,
topP: Percentage? = nil,
n: Percentage? = nil,
stream: Bool? = nil,
logprobs: Int? = nil,
echo: Bool? = nil,
stop: [String]? = nil,
presencePenalty: Penalty? = nil,
frequencyPenalty: Penalty? = nil,
bestOf: Percentage? = nil,
logitBias: [Token : Double]? = nil,
user: String? = nil
) {
self.model = model
self.prompt = prompt
self.suffix = suffix
self.maxTokens = maxTokens
self.temperature = temperature
self.topP = topP
self.n = n
self.stream = stream
self.logprobs = logprobs
self.echo = echo
self.stop = stop
self.presencePenalty = presencePenalty
self.frequencyPenalty = frequencyPenalty
self.bestOf = bestOf
self.logitBias = logitBias
self.user = user
}
}
}

Expand Down Expand Up @@ -65,6 +101,20 @@ extension Completions {
public let model: Model.ID
public let choices: [Choice]
public let usage: Usage

public init(
id: ID,
created: Date,
model: Model.ID,
choices: [Choice],
usage: Usage
) {
self.id = id
self.created = created
self.model = model
self.choices = choices
self.usage = usage
}
}

/// One of the completion choices.
Expand All @@ -80,5 +130,17 @@ extension Completions {

/// The reason for finishing.
public let finishReason: String

public init(
text: String,
index: Int,
logprobs: [String],
finishReason: String
) {
self.text = text
self.index = index
self.logprobs = logprobs
self.finishReason = finishReason
}
}
}
9 changes: 8 additions & 1 deletion Sources/OpenAIGPT3/Edits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ extension Edits {
public let temperature: Percentage?
public let topP: Percentage?

public init(model: Model.ID, input: String? = nil, instruction: String, n: Int? = nil, temperature: Percentage? = nil, topP: Percentage? = nil) {
public init(
model: Model.ID,
input: String? = nil,
instruction: String,
n: Int? = nil,
temperature: Percentage? = nil,
topP: Percentage? = nil
) {
self.model = model
self.input = input
self.instruction = instruction
Expand Down
9 changes: 8 additions & 1 deletion Sources/OpenAIGPT3/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ public struct Model: Equatable, Codable {
public let root: Model.ID
public let parent: Model.ID?

public init(id: Model.ID, created: Date, ownedBy: String, permissions: [Model.Permission], root: Model.ID, parent: Model.ID?) {
public init(
id: Model.ID,
created: Date,
ownedBy: String,
permissions: [Model.Permission],
root: Model.ID,
parent: Model.ID? = nil
) {
self.id = id
self.created = created
self.ownedBy = ownedBy
Expand Down

0 comments on commit 01b87b4

Please sign in to comment.