diff --git a/README.md b/README.md index 205aa3c..a3bf1b9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,12 @@ OpenAI ChatGPT app for iOS, iPadOS, macoS #### 更新说明 -最新版本 v2.1: +最新版本 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)) + +v2.1: - support GPT-4 Model(支持 GPT-4 模型) - support English language(支持英文语言) - display configured API Key(显示已配置的 API Key) @@ -107,6 +112,7 @@ TestFlight 下载地址:[https://testflight.apple.com/join/GR4BOt2M](https://t * [@iHTCboy](https://github.com/iHTCboy) * [@AlphaGogoo (BWQ)](https://github.com/AlphaGogoo) * [@RbBtSn0w (Snow Wu)](https://github.com/RbBtSn0w) +* [@0xfeedface1993 (John Corner)](https://github.com/0xfeedface1993) ### 五、效果示例 @@ -127,3 +133,4 @@ TestFlight 下载地址:[https://testflight.apple.com/join/GR4BOt2M](https://t - [A-kirami/nonebot-plugin-chatgpt](https://github.com/A-kirami/nonebot-plugin-chatgpt) - [shaps80/MarkdownText](https://github.com/shaps80/MarkdownText) - [MacPaw/OpenAI](https://github.com/MacPaw/OpenAI) +- [SwiftUIX/SwiftUIX](https://github.com/SwiftUIX/SwiftUIX) diff --git a/iChatGPT.xcodeproj/project.pbxproj b/iChatGPT.xcodeproj/project.pbxproj index 65220aa..11ec3d0 100644 --- a/iChatGPT.xcodeproj/project.pbxproj +++ b/iChatGPT.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXBuildFile section */ 6D37A73B29C6D76800EF1F7B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D37A73D29C6D76800EF1F7B /* Localizable.strings */; }; 6D5C556B2944408700FCF891 /* ImageLoaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5C556A2944408700FCF891 /* ImageLoaderView.swift */; }; + 6D82C46F29CB1BB4001661D8 /* OpenAI in Frameworks */ = {isa = PBXBuildFile; productRef = 6D82C46E29CB1BB4001661D8 /* OpenAI */; }; + 6D82C47229CB1C76001661D8 /* SwiftUIX in Frameworks */ = {isa = PBXBuildFile; productRef = 6D82C47129CB1C76001661D8 /* SwiftUIX */; }; 6DAA91802943448D004ACD01 /* MarkdownText in Frameworks */ = {isa = PBXBuildFile; productRef = 6DAA917F2943448D004ACD01 /* MarkdownText */; }; 6DAA9182294346D8004ACD01 /* MarkdownStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DAA9181294346D8004ACD01 /* MarkdownStyles.swift */; }; 6DC88ADE2942C8AD00DA6C55 /* iChatGPTApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC88ADD2942C8AD00DA6C55 /* iChatGPTApp.swift */; }; @@ -26,7 +28,6 @@ 6DC88B142942C8E000DA6C55 /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC88B132942C8E000DA6C55 /* Strings.swift */; }; 6DC88B192942D0B700DA6C55 /* Dates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC88B182942D0B700DA6C55 /* Dates.swift */; }; 6DC88B1B2942E84A00DA6C55 /* MultilineTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC88B1A2942E84A00DA6C55 /* MultilineTextField.swift */; }; - 8D204CCE29B5FB7D00AD3056 /* OpenAI in Frameworks */ = {isa = PBXBuildFile; productRef = 8D204CCD29B5FB7D00AD3056 /* OpenAI */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -79,7 +80,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8D204CCE29B5FB7D00AD3056 /* OpenAI in Frameworks */, + 6D82C47229CB1C76001661D8 /* SwiftUIX in Frameworks */, + 6D82C46F29CB1BB4001661D8 /* OpenAI in Frameworks */, 6DAA91802943448D004ACD01 /* MarkdownText in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -205,7 +207,8 @@ name = iChatGPT; packageProductDependencies = ( 6DAA917F2943448D004ACD01 /* MarkdownText */, - 8D204CCD29B5FB7D00AD3056 /* OpenAI */, + 6D82C46E29CB1BB4001661D8 /* OpenAI */, + 6D82C47129CB1C76001661D8 /* SwiftUIX */, ); productName = iChatGPT; productReference = 6DC88ADA2942C8AD00DA6C55 /* iChatGPT.app */; @@ -283,7 +286,8 @@ mainGroup = 6DC88AD12942C8AD00DA6C55; packageReferences = ( 6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */, - 8D204CCC29B5FB7D00AD3056 /* XCRemoteSwiftPackageReference "OpenAI" */, + 6D82C46D29CB1BB4001661D8 /* XCRemoteSwiftPackageReference "OpenAI" */, + 6D82C47029CB1C76001661D8 /* XCRemoteSwiftPackageReference "SwiftUIX" */, ); productRefGroup = 6DC88ADB2942C8AD00DA6C55 /* Products */; projectDirPath = ""; @@ -511,9 +515,8 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_IDENTITY = "Apple Development"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 2023.3.20; + CURRENT_PROJECT_VERSION = 2023.3.22; DEVELOPMENT_ASSET_PATHS = "\"iChatGPT/Preview Content\""; DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; @@ -531,7 +534,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.1; + MARKETING_VERSION = 2.2; PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iChatGPT; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -551,9 +554,8 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_IDENTITY = "Apple Development"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 2023.3.20; + CURRENT_PROJECT_VERSION = 2023.3.22; DEVELOPMENT_ASSET_PATHS = "\"iChatGPT/Preview Content\""; DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; @@ -571,7 +573,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.1; + MARKETING_VERSION = 2.2; PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iChatGPT; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -698,35 +700,48 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */ = { + 6D82C46D29CB1BB4001661D8 /* XCRemoteSwiftPackageReference "OpenAI" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/shaps80/MarkdownText.git"; + repositoryURL = "https://github.com/MacPaw/OpenAI.git"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 1.0.0; + minimumVersion = 0.0.6; }; }; - 8D204CCC29B5FB7D00AD3056 /* XCRemoteSwiftPackageReference "OpenAI" */ = { + 6D82C47029CB1C76001661D8 /* XCRemoteSwiftPackageReference "SwiftUIX" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "git@github.com:MacPaw/OpenAI.git"; + repositoryURL = "https://github.com/SwiftUIX/SwiftUIX.git"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 0.0.5; + minimumVersion = 0.1.4; + }; + }; + 6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/shaps80/MarkdownText.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.0.0; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 6D82C46E29CB1BB4001661D8 /* OpenAI */ = { + isa = XCSwiftPackageProductDependency; + package = 6D82C46D29CB1BB4001661D8 /* XCRemoteSwiftPackageReference "OpenAI" */; + productName = OpenAI; + }; + 6D82C47129CB1C76001661D8 /* SwiftUIX */ = { + isa = XCSwiftPackageProductDependency; + package = 6D82C47029CB1C76001661D8 /* XCRemoteSwiftPackageReference "SwiftUIX" */; + productName = SwiftUIX; + }; 6DAA917F2943448D004ACD01 /* MarkdownText */ = { isa = XCSwiftPackageProductDependency; package = 6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */; productName = MarkdownText; }; - 8D204CCD29B5FB7D00AD3056 /* OpenAI */ = { - isa = XCSwiftPackageProductDependency; - package = 8D204CCC29B5FB7D00AD3056 /* XCRemoteSwiftPackageReference "OpenAI" */; - productName = OpenAI; - }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 6DC88AD22942C8AD00DA6C55 /* Project object */; diff --git a/iChatGPT.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/iChatGPT.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 343a079..570814b 100644 --- a/iChatGPT.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/iChatGPT.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -12,10 +12,10 @@ { "identity" : "openai", "kind" : "remoteSourceControl", - "location" : "git@github.com:MacPaw/OpenAI.git", + "location" : "https://github.com/MacPaw/OpenAI.git", "state" : { - "revision" : "d0493cfca4986af77ac140bbf4eb30cc5ff8512f", - "version" : "0.0.5" + "revision" : "57b7af6e3dc6d167c5b483418126c1c873a5a2df", + "version" : "0.0.6" } }, { @@ -44,6 +44,15 @@ "revision" : "d9842f24656ff7c6116dc207b60f0b6d302a5a9a", "version" : "1.9.0" } + }, + { + "identity" : "swiftuix", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SwiftUIX/SwiftUIX.git", + "state" : { + "revision" : "1b8b443b61b8b37fafb06c1abad9b6be244c9de9", + "version" : "0.1.4" + } } ], "version" : 2 diff --git a/iChatGPT/ChatInputView.swift b/iChatGPT/ChatInputView.swift index feea256..5c5abe3 100644 --- a/iChatGPT/ChatInputView.swift +++ b/iChatGPT/ChatInputView.swift @@ -7,6 +7,7 @@ // import SwiftUI +import SwiftUIX struct ChatInputView: View { @@ -39,16 +40,10 @@ struct ChatInputView: View { .padding(.trailing, 5) } - let serachBar = TextField("Just ask..".localized(), text: $searchText, onEditingChanged: changedSearch, onCommit: fetchSearch) - .textFieldStyle(.plain) + CocoaTextField("Just ask..".localized(), text: $searchText, onEditingChanged: changedSearch(isEditing:), onCommit: fetchSearch) + .returnKeyType(.send) .padding(.trailing, 8) - if #available(iOS 15.0, *) { - serachBar.submitLabel(.send) - } else { - serachBar - } - if searchText.count > 0 { Button(action: clearSearch) { Image(systemName: "multiply.circle.fill") diff --git a/iChatGPT/Models/ChatGPT.swift b/iChatGPT/Models/ChatGPT.swift index 32438c0..2d7e004 100644 --- a/iChatGPT/Models/ChatGPT.swift +++ b/iChatGPT/Models/ChatGPT.swift @@ -11,6 +11,7 @@ import Combine import OpenAI class Chatbot { + var timeout: TimeInterval = 60 var userAvatarUrl = "https://raw.githubusercontent.com/37iOS/iChatGPT/main/icon.png" var openAIKey = "" var openAI: OpenAI @@ -30,13 +31,15 @@ class Chatbot { print("prompts") print(prompts) var messages: [OpenAI.Chat] = [] + // 每次只放此次提问之前三轮问答,且答案只放前面100字,已经足够AI推理了 + let prompts = Array(prompts.suffix(4)) for i in 0..