Skip to content

Commit

Permalink
Added public initializers to the chat datatypes, so they can be const…
Browse files Browse the repository at this point in the history
…ructed outside the package as intended.
  • Loading branch information
btfranklin committed Apr 25, 2023
1 parent b1f253f commit 9704c0b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Sources/CleverBird/chat/datatypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ public struct ChatCompletionRequest: Codable {
public let frequencyPenalty: Penalty?
public let user: String?
public let messages: [ChatMessage]

public init(model: Model,
temperature: Percentage,
topP: Percentage? = nil,
stop: [String]? = nil,
presencePenalty: Penalty? = nil,
frequencyPenalty: Penalty? = nil,
user: String? = nil,
messages: [ChatMessage]) {
self.model = model
self.temperature = temperature
self.topP = topP
self.stop = stop
self.presencePenalty = presencePenalty
self.frequencyPenalty = frequencyPenalty
self.user = user
self.messages = messages
}
}

public struct ChatMessage: Codable {
Expand All @@ -19,4 +37,10 @@ public struct ChatMessage: Codable {
}
public let role: Role
public let content: String

public init(role: Role,
content: String) {
self.role = role
self.content = content
}
}

0 comments on commit 9704c0b

Please sign in to comment.