Skip to content

Commit d962763

Browse files
committed
use partsValue
1 parent 0adb052 commit d962763

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Sources/GoogleAI/ModelContent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public struct ModelContent: Codable, Equatable {
114114
/// ``Part``. See ``ThrowingPartsRepresentable`` for types that can be interpreted as `Part`s.
115115
public init(role: String? = "user", parts: some PartsRepresentable) {
116116
self.role = role
117-
self.parts = parts.toPartsValue()
117+
self.parts = parts.partsValue
118118
}
119119

120120
/// Creates a new value from a list of ``Part``s.
@@ -135,7 +135,7 @@ public struct ModelContent: Codable, Equatable {
135135
/// ``ThrowingPartsRepresentable``
136136
/// for types that can be interpreted as `Part`s.
137137
public init(role: String? = "user", _ parts: [PartsRepresentable]) {
138-
let content = parts.flatMap { $0.toPartsValue() }
138+
let content = parts.flatMap { $0.partsValue }
139139
self.init(role: role, parts: content)
140140
}
141141
}

Sources/GoogleAI/PartsRepresentable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public protocol ThrowingPartsRepresentable {
2626
/// ``ThrowingPartsRepresentable``
2727
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
2828
public protocol PartsRepresentable: ThrowingPartsRepresentable {
29-
func toPartsValue() -> [ModelContent.Part]
29+
var partsValue: [ModelContent.Part] { get }
3030
}
3131

3232
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
3333
public extension PartsRepresentable {
3434
func tryPartsValue() throws -> [ModelContent.Part] {
35-
return toPartsValue()
35+
return partsValue
3636
}
3737
}
3838

@@ -60,7 +60,7 @@ extension [ThrowingPartsRepresentable]: ThrowingPartsRepresentable {
6060
/// Enables a `String` to be passed in as ``ThrowingPartsRepresentable``.
6161
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
6262
extension String: PartsRepresentable {
63-
public func toPartsValue() -> [ModelContent.Part] {
63+
public var partsValue: [ModelContent.Part] {
6464
return [.text(self)]
6565
}
6666
}

0 commit comments

Comments
 (0)