Simple and extensible Drop-in ChatGPT UI Solution for Apple Platforms.
- iOS 17
- macOS 14
- visionOS 1.x
- File > Swift Packages > Add Package Dependency
- Copy and paste this URL
https://github.com/alfianlosari/ChatGPTUI.gitImport to your project source file.
import ChatGPTUIRegister for API key fromx OpenAI. Initialize with api key
Privacy - Microphone Usage Description in info.plist when using this otherwise your app will crash
For App Sandbox, check these checkboxes in Xcode:
- Network Outgoing Connections (Client)
- Hardware Audio Input (For Voice Chat)
- Resource Access Audio Input (For Voice Chat)
Simply initialize passing the apiKey in SwiftUI View
var body: some View {
NavigationStack {
TextChatView(apiKey: apiKey)
.navigationTitle("XCA ChatGPTUI")
}
}Pass these optional params for customization:
senderImageandbotImagefrom asset or remote image URL to render as sender and bot images.modelChatGPTModel enum (gpt-4o, gpt-4turbo, gpt-3.5, etc)systemTextsystem text prompt used by ChatGPT.temperatureTemperature used by ChatGPT for response.
var body: some View {
NavigationStack {
TextChatView(
senderImage: senderImage,
botImage: botImage,
model: .gpt_hyphen_4o,
systemText: "You're master of Swift Programming",
temperature: 1.0,
apiKey: apiKey)
.navigationTitle("XCA ChatGPTUI")
}
}Make sure you are in tier that eligible for gpt4 models access. You can learn more from here How can I access GPT-4, GPT-4 Turbo and GPT-4o?.
If you're not sure just pass gpt-3.5 models, by default it uses gpt-3.5turbo
Converse with ChatGPT using Voice. It uses 3 OpenAI APIs under the hood:
- Transcribe user speech to text.
- Prompt ChatGPT API using the text.
- Convert text to speech (TTS) using Whisper API.
Privacy - Microphone Usage Description in info.plist when using this otherwise your app will crash
Simply initialize passing the apiKey in SwiftUI View
var body: some View {
NavigationStack {
VoiceChatView(apiKey: apiKey)
.navigationTitle("XCA ChatGPTUI")
}
}Pass these optional params for customization:
Voice Type: select voice type fromalloy(default),echo,fable,onyx,nova,shimmermodelChatGPTModel enum (gpt-4o, gpt-4turbo, gpt-3.5, etc)systemTextsystem text prompt used by ChatGPT.temperatureTemperature used by ChatGPT for response.
var body: some View {
NavigationStack {
VoiceChatView(
voiceType: .nova,
model: .gpt_hyphen_4o,
systemText: "You're master of Swift Programming",
temperature: 1.0,
apiKey: apiKey)
.navigationTitle("XCA ChatGPTUI")
}
}