Skip to content

Commit 9612bb8

Browse files
andrewheardG.Dev.Ssomsak
authored andcommitted
Add ModelContent tests for fileData parts (google-gemini#163)
1 parent 4b25d81 commit 9612bb8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Sources/GoogleAI/ModelContent.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public struct ModelContent: Equatable {
3535

3636
/// URI-based data with a specified media type.
3737
///
38+
/// > Important: Files must be uploaded using the
39+
/// > [`media.upload` REST API](https://ai.google.dev/api/rest/v1beta/media/upload) or another
40+
/// > Gemini SDK.
41+
///
3842
/// > Note: Supported media types depends on the model; see
3943
/// > [supported file
4044
/// > formats](https://ai.google.dev/tutorials/prompting_with_media#supported_file_formats)

Tests/GoogleAITests/GoogleAITests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ final class GoogleGenerativeAITests: XCTestCase {
9191
let _ = try await genAI.generateContent(str)
9292
let _ = try await genAI.generateContent([str])
9393
let _ = try await genAI.generateContent(str, "abc", "def")
94+
let _ = try await genAI.generateContent(
95+
str,
96+
ModelContent.Part.fileData(
97+
mimetype: "image/jpeg",
98+
uri: "https://generativelanguage.googleapis.com/v1beta/files/rand0mha5sh"
99+
)
100+
)
94101
#if canImport(UIKit)
95102
_ = try await genAI.generateContent(UIImage())
96103
_ = try await genAI.generateContent([UIImage()])

0 commit comments

Comments
 (0)