Skip to content

Commit d9e2501

Browse files
committed
Update v2.2:
- Increased request timeout from 30 seconds to 60 seconds.(请求超时从 30 秒增加到 60 秒。) - When sending dialog context, only send the first three Q&A rounds, and submit only the first 100 characters of the answer.(发送对话上下文时,只发送提问的前三轮问答,且答案只提交前100个字。) - Fixed Chinese Pinyin input method typing interruption problem (thanks to @ypwhs/@coder-free/@0xfeedface1993).(修复中文拼音输入法打字中断的问题(感谢 @ypwhs@coder-free@0xfeedface1993))
1 parent 475e6ef commit d9e2501

File tree

6 files changed

+67
-38
lines changed

6 files changed

+67
-38
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ OpenAI ChatGPT app for iOS, iPadOS, macoS
1010

1111
#### 更新说明
1212

13-
最新版本 v2.1:
13+
最新版本 v2.2:
14+
- Increased request timeout from 30 seconds to 60 seconds.(请求超时从 30 秒增加到 60 秒。)
15+
- When sending dialog context, only send the first three Q&A rounds, and submit only the first 100 characters of the answer.(发送对话上下文时,只发送提问的前三轮问答,且答案只提交前100个字。)
16+
- Fixed Chinese Pinyin input method typing interruption problem (thanks to @ypwhs/@coder-free/@0xfeedface1993).(修复中文拼音输入法打字中断的问题(感谢 @ypwhs@coder-free@0xfeedface1993))
17+
18+
v2.1:
1419
- support GPT-4 Model(支持 GPT-4 模型)
1520
- support English language(支持英文语言)
1621
- display configured API Key(显示已配置的 API Key)
@@ -107,6 +112,7 @@ TestFlight 下载地址:[https://testflight.apple.com/join/GR4BOt2M](https://t
107112
* [@iHTCboy](https://github.com/iHTCboy)
108113
* [@AlphaGogoo (BWQ)](https://github.com/AlphaGogoo)
109114
* [@RbBtSn0w (Snow Wu)](https://github.com/RbBtSn0w)
115+
* [@0xfeedface1993 (John Corner)](https://github.com/0xfeedface1993)
110116

111117

112118
### 五、效果示例
@@ -127,3 +133,4 @@ TestFlight 下载地址:[https://testflight.apple.com/join/GR4BOt2M](https://t
127133
- [A-kirami/nonebot-plugin-chatgpt](https://github.com/A-kirami/nonebot-plugin-chatgpt)
128134
- [shaps80/MarkdownText](https://github.com/shaps80/MarkdownText)
129135
- [MacPaw/OpenAI](https://github.com/MacPaw/OpenAI)
136+
- [SwiftUIX/SwiftUIX](https://github.com/SwiftUIX/SwiftUIX)

iChatGPT.xcodeproj/project.pbxproj

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/* Begin PBXBuildFile section */
1010
6D37A73B29C6D76800EF1F7B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D37A73D29C6D76800EF1F7B /* Localizable.strings */; };
1111
6D5C556B2944408700FCF891 /* ImageLoaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5C556A2944408700FCF891 /* ImageLoaderView.swift */; };
12+
6D82C46F29CB1BB4001661D8 /* OpenAI in Frameworks */ = {isa = PBXBuildFile; productRef = 6D82C46E29CB1BB4001661D8 /* OpenAI */; };
13+
6D82C47229CB1C76001661D8 /* SwiftUIX in Frameworks */ = {isa = PBXBuildFile; productRef = 6D82C47129CB1C76001661D8 /* SwiftUIX */; };
1214
6DAA91802943448D004ACD01 /* MarkdownText in Frameworks */ = {isa = PBXBuildFile; productRef = 6DAA917F2943448D004ACD01 /* MarkdownText */; };
1315
6DAA9182294346D8004ACD01 /* MarkdownStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DAA9181294346D8004ACD01 /* MarkdownStyles.swift */; };
1416
6DC88ADE2942C8AD00DA6C55 /* iChatGPTApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC88ADD2942C8AD00DA6C55 /* iChatGPTApp.swift */; };
@@ -26,7 +28,6 @@
2628
6DC88B142942C8E000DA6C55 /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC88B132942C8E000DA6C55 /* Strings.swift */; };
2729
6DC88B192942D0B700DA6C55 /* Dates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC88B182942D0B700DA6C55 /* Dates.swift */; };
2830
6DC88B1B2942E84A00DA6C55 /* MultilineTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC88B1A2942E84A00DA6C55 /* MultilineTextField.swift */; };
29-
8D204CCE29B5FB7D00AD3056 /* OpenAI in Frameworks */ = {isa = PBXBuildFile; productRef = 8D204CCD29B5FB7D00AD3056 /* OpenAI */; };
3031
/* End PBXBuildFile section */
3132

3233
/* Begin PBXContainerItemProxy section */
@@ -79,7 +80,8 @@
7980
isa = PBXFrameworksBuildPhase;
8081
buildActionMask = 2147483647;
8182
files = (
82-
8D204CCE29B5FB7D00AD3056 /* OpenAI in Frameworks */,
83+
6D82C47229CB1C76001661D8 /* SwiftUIX in Frameworks */,
84+
6D82C46F29CB1BB4001661D8 /* OpenAI in Frameworks */,
8385
6DAA91802943448D004ACD01 /* MarkdownText in Frameworks */,
8486
);
8587
runOnlyForDeploymentPostprocessing = 0;
@@ -205,7 +207,8 @@
205207
name = iChatGPT;
206208
packageProductDependencies = (
207209
6DAA917F2943448D004ACD01 /* MarkdownText */,
208-
8D204CCD29B5FB7D00AD3056 /* OpenAI */,
210+
6D82C46E29CB1BB4001661D8 /* OpenAI */,
211+
6D82C47129CB1C76001661D8 /* SwiftUIX */,
209212
);
210213
productName = iChatGPT;
211214
productReference = 6DC88ADA2942C8AD00DA6C55 /* iChatGPT.app */;
@@ -283,7 +286,8 @@
283286
mainGroup = 6DC88AD12942C8AD00DA6C55;
284287
packageReferences = (
285288
6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */,
286-
8D204CCC29B5FB7D00AD3056 /* XCRemoteSwiftPackageReference "OpenAI" */,
289+
6D82C46D29CB1BB4001661D8 /* XCRemoteSwiftPackageReference "OpenAI" */,
290+
6D82C47029CB1C76001661D8 /* XCRemoteSwiftPackageReference "SwiftUIX" */,
287291
);
288292
productRefGroup = 6DC88ADB2942C8AD00DA6C55 /* Products */;
289293
projectDirPath = "";
@@ -511,9 +515,8 @@
511515
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
512516
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
513517
CODE_SIGN_IDENTITY = "Apple Development";
514-
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
515518
CODE_SIGN_STYLE = Manual;
516-
CURRENT_PROJECT_VERSION = 2023.3.20;
519+
CURRENT_PROJECT_VERSION = 2023.3.22;
517520
DEVELOPMENT_ASSET_PATHS = "\"iChatGPT/Preview Content\"";
518521
DEVELOPMENT_TEAM = "";
519522
ENABLE_PREVIEWS = YES;
@@ -531,7 +534,7 @@
531534
"$(inherited)",
532535
"@executable_path/Frameworks",
533536
);
534-
MARKETING_VERSION = 2.1;
537+
MARKETING_VERSION = 2.2;
535538
PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iChatGPT;
536539
PRODUCT_NAME = "$(TARGET_NAME)";
537540
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -551,9 +554,8 @@
551554
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
552555
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
553556
CODE_SIGN_IDENTITY = "Apple Development";
554-
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
555557
CODE_SIGN_STYLE = Manual;
556-
CURRENT_PROJECT_VERSION = 2023.3.20;
558+
CURRENT_PROJECT_VERSION = 2023.3.22;
557559
DEVELOPMENT_ASSET_PATHS = "\"iChatGPT/Preview Content\"";
558560
DEVELOPMENT_TEAM = "";
559561
ENABLE_PREVIEWS = YES;
@@ -571,7 +573,7 @@
571573
"$(inherited)",
572574
"@executable_path/Frameworks",
573575
);
574-
MARKETING_VERSION = 2.1;
576+
MARKETING_VERSION = 2.2;
575577
PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iChatGPT;
576578
PRODUCT_NAME = "$(TARGET_NAME)";
577579
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -698,35 +700,48 @@
698700
/* End XCConfigurationList section */
699701

700702
/* Begin XCRemoteSwiftPackageReference section */
701-
6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */ = {
703+
6D82C46D29CB1BB4001661D8 /* XCRemoteSwiftPackageReference "OpenAI" */ = {
702704
isa = XCRemoteSwiftPackageReference;
703-
repositoryURL = "https://github.com/shaps80/MarkdownText.git";
705+
repositoryURL = "https://github.com/MacPaw/OpenAI.git";
704706
requirement = {
705707
kind = upToNextMajorVersion;
706-
minimumVersion = 1.0.0;
708+
minimumVersion = 0.0.6;
707709
};
708710
};
709-
8D204CCC29B5FB7D00AD3056 /* XCRemoteSwiftPackageReference "OpenAI" */ = {
711+
6D82C47029CB1C76001661D8 /* XCRemoteSwiftPackageReference "SwiftUIX" */ = {
710712
isa = XCRemoteSwiftPackageReference;
711-
repositoryURL = "git@github.com:MacPaw/OpenAI.git";
713+
repositoryURL = "https://github.com/SwiftUIX/SwiftUIX.git";
712714
requirement = {
713715
kind = upToNextMajorVersion;
714-
minimumVersion = 0.0.5;
716+
minimumVersion = 0.1.4;
717+
};
718+
};
719+
6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */ = {
720+
isa = XCRemoteSwiftPackageReference;
721+
repositoryURL = "https://github.com/shaps80/MarkdownText.git";
722+
requirement = {
723+
kind = upToNextMajorVersion;
724+
minimumVersion = 1.0.0;
715725
};
716726
};
717727
/* End XCRemoteSwiftPackageReference section */
718728

719729
/* Begin XCSwiftPackageProductDependency section */
730+
6D82C46E29CB1BB4001661D8 /* OpenAI */ = {
731+
isa = XCSwiftPackageProductDependency;
732+
package = 6D82C46D29CB1BB4001661D8 /* XCRemoteSwiftPackageReference "OpenAI" */;
733+
productName = OpenAI;
734+
};
735+
6D82C47129CB1C76001661D8 /* SwiftUIX */ = {
736+
isa = XCSwiftPackageProductDependency;
737+
package = 6D82C47029CB1C76001661D8 /* XCRemoteSwiftPackageReference "SwiftUIX" */;
738+
productName = SwiftUIX;
739+
};
720740
6DAA917F2943448D004ACD01 /* MarkdownText */ = {
721741
isa = XCSwiftPackageProductDependency;
722742
package = 6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */;
723743
productName = MarkdownText;
724744
};
725-
8D204CCD29B5FB7D00AD3056 /* OpenAI */ = {
726-
isa = XCSwiftPackageProductDependency;
727-
package = 8D204CCC29B5FB7D00AD3056 /* XCRemoteSwiftPackageReference "OpenAI" */;
728-
productName = OpenAI;
729-
};
730745
/* End XCSwiftPackageProductDependency section */
731746
};
732747
rootObject = 6DC88AD22942C8AD00DA6C55 /* Project object */;

iChatGPT.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iChatGPT/ChatInputView.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import SwiftUI
10+
import SwiftUIX
1011

1112
struct ChatInputView: View {
1213

@@ -39,16 +40,10 @@ struct ChatInputView: View {
3940
.padding(.trailing, 5)
4041
}
4142

42-
let serachBar = TextField("Just ask..".localized(), text: $searchText, onEditingChanged: changedSearch, onCommit: fetchSearch)
43-
.textFieldStyle(.plain)
43+
CocoaTextField("Just ask..".localized(), text: $searchText, onEditingChanged: changedSearch(isEditing:), onCommit: fetchSearch)
44+
.returnKeyType(.send)
4445
.padding(.trailing, 8)
4546

46-
if #available(iOS 15.0, *) {
47-
serachBar.submitLabel(.send)
48-
} else {
49-
serachBar
50-
}
51-
5247
if searchText.count > 0 {
5348
Button(action: clearSearch) {
5449
Image(systemName: "multiply.circle.fill")

iChatGPT/Models/ChatGPT.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Combine
1111
import OpenAI
1212

1313
class Chatbot {
14+
var timeout: TimeInterval = 60
1415
var userAvatarUrl = "https://raw.githubusercontent.com/37iOS/iChatGPT/main/icon.png"
1516
var openAIKey = ""
1617
var openAI: OpenAI
@@ -30,13 +31,15 @@ class Chatbot {
3031
print("prompts")
3132
print(prompts)
3233
var messages: [OpenAI.Chat] = []
34+
// 每次只放此次提问之前三轮问答,且答案只放前面100字,已经足够AI推理了
35+
let prompts = Array(prompts.suffix(4))
3336
for i in 0..<prompts.count {
3437
if i == prompts.count - 1 {
35-
messages.append(.init(role: "user", content: prompts[i].issue))
38+
messages.append(.init(role: .user, content: prompts[i].issue))
3639
break
3740
}
38-
messages.append(.init(role: "user", content: prompts[i].issue))
39-
messages.append(.init(role: "assistant", content: prompts[i].answer ?? ""))
41+
messages.append(.init(role: .user, content: prompts[i].issue))
42+
messages.append(.init(role: .assistant, content: String((prompts[i].answer ?? "").prefix(100))))
4043
}
4144
print("message:")
4245
print(messages)

iChatGPT/TokenSettingView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct TokenSettingView: View {
4040
HStack {
4141
Spacer().frame(width: 50)
4242
Spacer()
43-
Text("Settings".localized()).font(.headline).fontWeight(.bold).padding([.top, .leading], 12)
43+
Text("Settings".localized()).font(.title3).fontWeight(.bold).padding([.top, .leading], 12)
4444
Spacer()
4545
Button {
4646
isAddPresented = false
@@ -165,7 +165,7 @@ struct TokenSettingView: View {
165165
.multilineTextAlignment(.center)
166166
.padding(.bottom, 10)
167167

168-
Text("Contributors:[@iHTCboy](https://github.com/iHTCboy) | [@AlphaGogoo](https://github.com/AlphaGogoo) | [@RbBtSn0w](https://github.com/RbBtSn0w)")
168+
Text("Contributors:[@iHTCboy](https://github.com/iHTCboy) | [@AlphaGogoo](https://github.com/AlphaGogoo) | [@RbBtSn0w](https://github.com/RbBtSn0w) | [@0xfeedface1993](https://github.com/0xfeedface1993)")
169169
.font(.footnote)
170170
.foregroundColor(.secondary)
171171
.multilineTextAlignment(.center)

0 commit comments

Comments
 (0)