Example of including an image + prompt to gpt-4o?
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 25/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- swift
調査の方向性
Start by checking the package's existing examples and the ChatQuery.ChatCompletionMessageParam API used in the issue, especially how a user message can carry both text and an image for gpt-4o. Done looks like an example showing an image from assets or the device sent with a prompt; the issue has had no comment for over two years, so confirm the request is still relevant before starting.
索引モデルが issue の本文から書いたものです。
説明
Hi.
Pretty new to both Swift and this package.
Can anyone include an example of how to supply an image from assets or uploaded from the device with a prompt to the gpt-4o endpoint?
My current progress is below, but I feel like I'm doing something terribly wrong.
Only requirement is making it work at this point :D.
Current Error:
Current Code:
private func sendDataToAPI() async {
let washRoutine = UserDefaults.standard.string(forKey: "washRoutine") ?? ""
let beforeBedRoutine = UserDefaults.standard.string(forKey: "beforeBedRoutine") ?? ""
let otherHairCare = UserDefaults.standard.string(forKey: "otherHairCare") ?? ""
var messages: [ChatQuery.ChatCompletionMessageParam] = [
.user(.init(content: .string("Here are my current hair care routines:"))),
.user(.init(content: .string("Wash Routine: \(washRoutine)"))),
.user(.init(content: .string("Before Bed Routine: \(beforeBedRoutine)"))),
.user(.init(content: .string("Other Hair Care: \(otherHairCare)")))
]
if let image = UIImage(named: "curly_1"),
let imageData = image.jpegData(compressionQuality: 1.0) {
let base64String = imageData.base64EncodedString()
let imageUrl = "data:image/jpeg;base64,\(base64String)"
let imageParam = ChatQuery.ChatCompletionMessageParam.ChatCompletionUserMessageParam.init(content: .string(imageUrl))
messages.append(.user(imageParam))
}
let openAI = OpenAI(apiToken: "<api_token>")
let query = ChatQuery(messages: messages, model: .gpt4_o)
do {
let result = try await openAI.chats(query: query)
let content = result.choices.first?.message.content?.string
let tokenCount = result.usage?.promptTokens ?? 0
DispatchQueue.main.async {
self.apiResult = "\nPrompt tokens: \(tokenCount)\n\n\(content ?? "No content")"
}
} catch {
DispatchQueue.main.async {
self.apiResult = "Error fetching chats: \(error.localizedDescription)"
}
}
}
- 主要言語
- Swift
- スター
- 2.9k
- フォーク
- 519
- 平均マージ
- 1日 17時間
- マージ済み PR(30日)
- 10
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MacPaw/OpenAI のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信
-
Enable batch promptsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
MacPaw/OpenAI#73 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
enhancement impact:U1 P3 reach:R2 size:S
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Follow-ups: #35163 Agent chat: a sent prompt glides into place from the bottom and from an up-scrollオープンarea: agents follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
manaflow-ai/cmux#35868 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
mozilla-mobile/firefox-ios#36439 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
blinklabs-io/bursa#1200 ·
メンテナーはふだん 1 日以内に返信