Skip to content

Commit

Permalink
Update v2.2:
Browse files Browse the repository at this point in the history
- 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))
  • Loading branch information
iHTCboy committed Mar 22, 2023
1 parent 475e6ef commit d9e2501
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 38 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)


### 五、效果示例
Expand All @@ -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)
57 changes: 36 additions & 21 deletions iChatGPT.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -205,7 +207,8 @@
name = iChatGPT;
packageProductDependencies = (
6DAA917F2943448D004ACD01 /* MarkdownText */,
8D204CCD29B5FB7D00AD3056 /* OpenAI */,
6D82C46E29CB1BB4001661D8 /* OpenAI */,
6D82C47129CB1C76001661D8 /* SwiftUIX */,
);
productName = iChatGPT;
productReference = 6DC88ADA2942C8AD00DA6C55 /* iChatGPT.app */;
Expand Down Expand Up @@ -283,7 +286,8 @@
mainGroup = 6DC88AD12942C8AD00DA6C55;
packageReferences = (
6DAA917E2943448D004ACD01 /* XCRemoteSwiftPackageReference "MarkdownText" */,
8D204CCC29B5FB7D00AD3056 /* XCRemoteSwiftPackageReference "OpenAI" */,
6D82C46D29CB1BB4001661D8 /* XCRemoteSwiftPackageReference "OpenAI" */,
6D82C47029CB1C76001661D8 /* XCRemoteSwiftPackageReference "SwiftUIX" */,
);
productRefGroup = 6DC88ADB2942C8AD00DA6C55 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -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;
Expand All @@ -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 = "";
Expand All @@ -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;
Expand All @@ -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 = "";
Expand Down Expand Up @@ -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 */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions iChatGPT/ChatInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import SwiftUI
import SwiftUIX

struct ChatInputView: View {

Expand Down Expand Up @@ -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")
Expand Down
9 changes: 6 additions & 3 deletions iChatGPT/Models/ChatGPT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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..<prompts.count {
if i == prompts.count - 1 {
messages.append(.init(role: "user", content: prompts[i].issue))
messages.append(.init(role: .user, content: prompts[i].issue))
break
}
messages.append(.init(role: "user", content: prompts[i].issue))
messages.append(.init(role: "assistant", content: prompts[i].answer ?? ""))
messages.append(.init(role: .user, content: prompts[i].issue))
messages.append(.init(role: .assistant, content: String((prompts[i].answer ?? "").prefix(100))))
}
print("message:")
print(messages)
Expand Down
4 changes: 2 additions & 2 deletions iChatGPT/TokenSettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct TokenSettingView: View {
HStack {
Spacer().frame(width: 50)
Spacer()
Text("Settings".localized()).font(.headline).fontWeight(.bold).padding([.top, .leading], 12)
Text("Settings".localized()).font(.title3).fontWeight(.bold).padding([.top, .leading], 12)
Spacer()
Button {
isAddPresented = false
Expand Down Expand Up @@ -165,7 +165,7 @@ struct TokenSettingView: View {
.multilineTextAlignment(.center)
.padding(.bottom, 10)

Text("Contributors:[@iHTCboy](https://github.com/iHTCboy) | [@AlphaGogoo](https://github.com/AlphaGogoo) | [@RbBtSn0w](https://github.com/RbBtSn0w)")
Text("Contributors:[@iHTCboy](https://github.com/iHTCboy) | [@AlphaGogoo](https://github.com/AlphaGogoo) | [@RbBtSn0w](https://github.com/RbBtSn0w) | [@0xfeedface1993](https://github.com/0xfeedface1993)")
.font(.footnote)
.foregroundColor(.secondary)
.multilineTextAlignment(.center)
Expand Down

0 comments on commit d9e2501

Please sign in to comment.