From a2fe60c0afc95bfc7ebae53b6aed4f51d726654d Mon Sep 17 00:00:00 2001 From: ujhong7 Date: Thu, 28 Mar 2024 10:36:47 +0900 Subject: [PATCH 01/12] =?UTF-8?q?config:=20.gitignore=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/.gitignore | 115 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 ChatBot/.gitignore diff --git a/ChatBot/.gitignore b/ChatBot/.gitignore new file mode 100644 index 00000000..2995c9bf --- /dev/null +++ b/ChatBot/.gitignore @@ -0,0 +1,115 @@ +# Created by https://www.toptal.com/developers/gitignore/api/xcode,swift,cocoapods +# Edit at https://www.toptal.com/developers/gitignore?templates=xcode,swift,cocoapods + +### CocoaPods ### +## CocoaPods GitIgnore Template + +# CocoaPods - Only use to conserve bandwidth / Save time on Pushing +# - Also handy if you have a large number of dependant pods +# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE +Pods/ + +### Swift ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# Pods/ +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ + +### Xcode ### +# Xcode +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + + +### DS_Store ### +.DS_Store + + +## Gcc Patch +/*.gcno + +### Xcode Patch ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +**/xcshareddata/WorkspaceSettings.xcsettings + +# End of https://www.toptal.com/developers/gitignore/api/xcode,swift,cocoapods From b83c94e2bf4862c0469fb1db3e1af097d6bf392d Mon Sep 17 00:00:00 2001 From: ujhong7 Date: Thu, 28 Mar 2024 13:14:43 +0900 Subject: [PATCH 02/12] =?UTF-8?q?config:=20=EB=A9=94=EC=9D=B8=EC=8A=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=EB=B3=B4=EB=93=9C=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/ChatBot.xcodeproj/project.pbxproj | 14 ------------- ChatBot/ChatBot/Base.lproj/Main.storyboard | 24 ---------------------- ChatBot/ChatBot/Info.plist | 2 -- ChatBot/ChatBot/SceneDelegate.swift | 11 +++++++--- 4 files changed, 8 insertions(+), 43 deletions(-) delete mode 100644 ChatBot/ChatBot/Base.lproj/Main.storyboard diff --git a/ChatBot/ChatBot.xcodeproj/project.pbxproj b/ChatBot/ChatBot.xcodeproj/project.pbxproj index b0f43154..4de44769 100644 --- a/ChatBot/ChatBot.xcodeproj/project.pbxproj +++ b/ChatBot/ChatBot.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ B4B3E2BD2B42D1BB00818B3C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2BC2B42D1BB00818B3C /* AppDelegate.swift */; }; B4B3E2BF2B42D1BB00818B3C /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2BE2B42D1BB00818B3C /* SceneDelegate.swift */; }; B4B3E2C12B42D1BB00818B3C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2C02B42D1BB00818B3C /* ViewController.swift */; }; - B4B3E2C42B42D1BB00818B3C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B4B3E2C22B42D1BB00818B3C /* Main.storyboard */; }; B4B3E2C62B42D1BC00818B3C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B4B3E2C52B42D1BC00818B3C /* Assets.xcassets */; }; B4B3E2C92B42D1BC00818B3C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B4B3E2C72B42D1BC00818B3C /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ @@ -20,7 +19,6 @@ B4B3E2BC2B42D1BB00818B3C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; B4B3E2BE2B42D1BB00818B3C /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; B4B3E2C02B42D1BB00818B3C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - B4B3E2C32B42D1BB00818B3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; B4B3E2C52B42D1BC00818B3C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; B4B3E2C82B42D1BC00818B3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; B4B3E2CA2B42D1BC00818B3C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -59,7 +57,6 @@ B4B3E2BC2B42D1BB00818B3C /* AppDelegate.swift */, B4B3E2BE2B42D1BB00818B3C /* SceneDelegate.swift */, B4B3E2C02B42D1BB00818B3C /* ViewController.swift */, - B4B3E2C22B42D1BB00818B3C /* Main.storyboard */, B4B3E2C52B42D1BC00818B3C /* Assets.xcassets */, B4B3E2C72B42D1BC00818B3C /* LaunchScreen.storyboard */, B4B3E2CA2B42D1BC00818B3C /* Info.plist */, @@ -127,7 +124,6 @@ files = ( B4B3E2C92B42D1BC00818B3C /* LaunchScreen.storyboard in Resources */, B4B3E2C62B42D1BC00818B3C /* Assets.xcassets in Resources */, - B4B3E2C42B42D1BB00818B3C /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -147,14 +143,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - B4B3E2C22B42D1BB00818B3C /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - B4B3E2C32B42D1BB00818B3C /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; B4B3E2C72B42D1BC00818B3C /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -297,7 +285,6 @@ INFOPLIST_FILE = ChatBot/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; - INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -326,7 +313,6 @@ INFOPLIST_FILE = ChatBot/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; - INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; diff --git a/ChatBot/ChatBot/Base.lproj/Main.storyboard b/ChatBot/ChatBot/Base.lproj/Main.storyboard deleted file mode 100644 index 25a76385..00000000 --- a/ChatBot/ChatBot/Base.lproj/Main.storyboard +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChatBot/ChatBot/Info.plist b/ChatBot/ChatBot/Info.plist index dd3c9afd..0eb786dc 100644 --- a/ChatBot/ChatBot/Info.plist +++ b/ChatBot/ChatBot/Info.plist @@ -15,8 +15,6 @@ Default Configuration UISceneDelegateClassName $(PRODUCT_MODULE_NAME).SceneDelegate - UISceneStoryboardFile - Main diff --git a/ChatBot/ChatBot/SceneDelegate.swift b/ChatBot/ChatBot/SceneDelegate.swift index 290e44c2..b11fdd3e 100644 --- a/ChatBot/ChatBot/SceneDelegate.swift +++ b/ChatBot/ChatBot/SceneDelegate.swift @@ -9,11 +9,16 @@ import UIKit class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - guard let _ = (scene as? UIWindowScene) else { return } + guard let windowScene = (scene as? UIWindowScene) else { return } + + let window = UIWindow(windowScene: windowScene) + window.rootViewController = ViewController() + window.makeKeyAndVisible() + self.window = window } - + func sceneDidDisconnect(_ scene: UIScene) { } func sceneDidBecomeActive(_ scene: UIScene) { } func sceneWillResignActive(_ scene: UIScene) { } From 347578901f2c002b3e01a8f86c36ac6b3f866b71 Mon Sep 17 00:00:00 2001 From: ujhong7 Date: Thu, 28 Mar 2024 13:27:46 +0900 Subject: [PATCH 03/12] =?UTF-8?q?feat:=20=EC=9A=94=EC=B2=AD=20=EB=B0=8F=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/ChatBot/Model/MessageDTO.swift | 13 ++++++++ ChatBot/ChatBot/Model/RequestDTO.swift | 18 +++++++++++ ChatBot/ChatBot/Model/ResponseDTO.swift | 43 +++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 ChatBot/ChatBot/Model/MessageDTO.swift create mode 100644 ChatBot/ChatBot/Model/RequestDTO.swift create mode 100644 ChatBot/ChatBot/Model/ResponseDTO.swift diff --git a/ChatBot/ChatBot/Model/MessageDTO.swift b/ChatBot/ChatBot/Model/MessageDTO.swift new file mode 100644 index 00000000..4d7705e6 --- /dev/null +++ b/ChatBot/ChatBot/Model/MessageDTO.swift @@ -0,0 +1,13 @@ +// +// MessageDTO.swift +// ChatBot +// +// Created by yujaehong on 3/28/24. +// + +import Foundation + +struct MessageDTO: Codable { + let role: String + let content: String +} diff --git a/ChatBot/ChatBot/Model/RequestDTO.swift b/ChatBot/ChatBot/Model/RequestDTO.swift new file mode 100644 index 00000000..633ea58a --- /dev/null +++ b/ChatBot/ChatBot/Model/RequestDTO.swift @@ -0,0 +1,18 @@ +// +// RequestDTO.swift +// ChatBot +// +// Created by yujaehong on 3/28/24. +// + +import Foundation + +struct RequestDTO: Codable { + let model: GPTModel + let stream: Bool + let messages: [MessageDTO] +} + +enum GPTModel: String, Codable { + case main = "gpt-3.5-turbo-1106" +} diff --git a/ChatBot/ChatBot/Model/ResponseDTO.swift b/ChatBot/ChatBot/Model/ResponseDTO.swift new file mode 100644 index 00000000..d0134b50 --- /dev/null +++ b/ChatBot/ChatBot/Model/ResponseDTO.swift @@ -0,0 +1,43 @@ +// +// ResponseDTO.swift +// ChatBot +// +// Created by yujaehong on 3/28/24. +// + +import Foundation + +struct ResponseDTO: Codable { + let id: String + let object: String + let created: Int + let model: String + let systemFingerprint: String + let choices: [Choice] + let usage: Usage +} + +struct Choice: Codable { + let index: Int + let message: MessageDTO + let finishReason: String + + enum CodingKeys: String, CodingKey { + case index + case message + case finishReason = "finish_reason" + } +} + +struct Usage: Codable { + let promptTokens: Int + let completionTokens: Int + let totalTokens: Int + + enum CodingKeys: String, CodingKey { + case promptTokens = "prompt_tokens" + case completionTokens = "completion_tokens" + case totalTokens = "total_tokens" + } +} + From 37851ddc88670b24c39cface45fc5bc772315e14 Mon Sep 17 00:00:00 2001 From: ujhong7 Date: Fri, 29 Mar 2024 00:44:04 +0900 Subject: [PATCH 04/12] =?UTF-8?q?chore:=20=EB=AA=A8=EB=8D=B8=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChatBot/Model/{RequestDTO.swift => ChatRequest.swift} | 6 +++--- .../ChatBot/Model/{ResponseDTO.swift => ChatResponse.swift} | 6 +++--- ChatBot/ChatBot/Model/{MessageDTO.swift => Message.swift} | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename ChatBot/ChatBot/Model/{RequestDTO.swift => ChatRequest.swift} (70%) rename ChatBot/ChatBot/Model/{ResponseDTO.swift => ChatResponse.swift} (90%) rename ChatBot/ChatBot/Model/{MessageDTO.swift => Message.swift} (71%) diff --git a/ChatBot/ChatBot/Model/RequestDTO.swift b/ChatBot/ChatBot/Model/ChatRequest.swift similarity index 70% rename from ChatBot/ChatBot/Model/RequestDTO.swift rename to ChatBot/ChatBot/Model/ChatRequest.swift index 633ea58a..b66c76a5 100644 --- a/ChatBot/ChatBot/Model/RequestDTO.swift +++ b/ChatBot/ChatBot/Model/ChatRequest.swift @@ -1,5 +1,5 @@ // -// RequestDTO.swift +// ChatRequest.swift // ChatBot // // Created by yujaehong on 3/28/24. @@ -7,10 +7,10 @@ import Foundation -struct RequestDTO: Codable { +struct ChatRequest: Codable { let model: GPTModel let stream: Bool - let messages: [MessageDTO] + let messages: [Message] } enum GPTModel: String, Codable { diff --git a/ChatBot/ChatBot/Model/ResponseDTO.swift b/ChatBot/ChatBot/Model/ChatResponse.swift similarity index 90% rename from ChatBot/ChatBot/Model/ResponseDTO.swift rename to ChatBot/ChatBot/Model/ChatResponse.swift index d0134b50..8852a6ec 100644 --- a/ChatBot/ChatBot/Model/ResponseDTO.swift +++ b/ChatBot/ChatBot/Model/ChatResponse.swift @@ -1,5 +1,5 @@ // -// ResponseDTO.swift +// ChatResponse.swift // ChatBot // // Created by yujaehong on 3/28/24. @@ -7,7 +7,7 @@ import Foundation -struct ResponseDTO: Codable { +struct ChatResponse: Codable { let id: String let object: String let created: Int @@ -19,7 +19,7 @@ struct ResponseDTO: Codable { struct Choice: Codable { let index: Int - let message: MessageDTO + let message: Message let finishReason: String enum CodingKeys: String, CodingKey { diff --git a/ChatBot/ChatBot/Model/MessageDTO.swift b/ChatBot/ChatBot/Model/Message.swift similarity index 71% rename from ChatBot/ChatBot/Model/MessageDTO.swift rename to ChatBot/ChatBot/Model/Message.swift index 4d7705e6..617a0542 100644 --- a/ChatBot/ChatBot/Model/MessageDTO.swift +++ b/ChatBot/ChatBot/Model/Message.swift @@ -1,5 +1,5 @@ // -// MessageDTO.swift +// Message.swift // ChatBot // // Created by yujaehong on 3/28/24. @@ -7,7 +7,7 @@ import Foundation -struct MessageDTO: Codable { +struct Message: Codable { let role: String let content: String } From 782cbe3aee928808db17a3a43165ac1126991d19 Mon Sep 17 00:00:00 2001 From: ujhong7 Date: Mon, 1 Apr 2024 17:53:20 +0900 Subject: [PATCH 05/12] =?UTF-8?q?feat:=20=EA=B8=B0=EB=B3=B8=20=EA=B5=AC?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/ChatBot/App/AppDelegate.swift | 21 +++++++++++++++ ChatBot/ChatBot/App/SceneDelegate.swift | 27 +++++++++++++++++++ .../ChatBot/Controller/ViewController.swift | 16 +++++++++++ .../AccentColor.colorset/Contents.json | 11 ++++++++ .../AppIcon.appiconset/Contents.json | 13 +++++++++ .../Resouces/Assets.xcassets/Contents.json | 6 +++++ .../Base.lproj/LaunchScreen.storyboard | 25 +++++++++++++++++ ChatBot/ChatBot/Resouces/Info.plist | 23 ++++++++++++++++ 8 files changed, 142 insertions(+) create mode 100644 ChatBot/ChatBot/App/AppDelegate.swift create mode 100644 ChatBot/ChatBot/App/SceneDelegate.swift create mode 100644 ChatBot/ChatBot/Controller/ViewController.swift create mode 100644 ChatBot/ChatBot/Resouces/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 ChatBot/ChatBot/Resouces/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 ChatBot/ChatBot/Resouces/Assets.xcassets/Contents.json create mode 100644 ChatBot/ChatBot/Resouces/Base.lproj/LaunchScreen.storyboard create mode 100644 ChatBot/ChatBot/Resouces/Info.plist diff --git a/ChatBot/ChatBot/App/AppDelegate.swift b/ChatBot/ChatBot/App/AppDelegate.swift new file mode 100644 index 00000000..735b872a --- /dev/null +++ b/ChatBot/ChatBot/App/AppDelegate.swift @@ -0,0 +1,21 @@ +// +// AppDelegate.swift +// ChatBot +// +// Created by Tacocat on 1/1/24. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + return true + } + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { } +} diff --git a/ChatBot/ChatBot/App/SceneDelegate.swift b/ChatBot/ChatBot/App/SceneDelegate.swift new file mode 100644 index 00000000..b11fdd3e --- /dev/null +++ b/ChatBot/ChatBot/App/SceneDelegate.swift @@ -0,0 +1,27 @@ +// +// SceneDelegate.swift +// ChatBot +// +// Created by Tacocat on 1/1/24. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + var window: UIWindow? + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + guard let windowScene = (scene as? UIWindowScene) else { return } + + let window = UIWindow(windowScene: windowScene) + window.rootViewController = ViewController() + window.makeKeyAndVisible() + self.window = window + } + + func sceneDidDisconnect(_ scene: UIScene) { } + func sceneDidBecomeActive(_ scene: UIScene) { } + func sceneWillResignActive(_ scene: UIScene) { } + func sceneWillEnterForeground(_ scene: UIScene) { } + func sceneDidEnterBackground(_ scene: UIScene) { } +} diff --git a/ChatBot/ChatBot/Controller/ViewController.swift b/ChatBot/ChatBot/Controller/ViewController.swift new file mode 100644 index 00000000..17ab98d0 --- /dev/null +++ b/ChatBot/ChatBot/Controller/ViewController.swift @@ -0,0 +1,16 @@ +// +// ViewController.swift +// ChatBot +// +// Created by Tacocat on 1/1/24. +// + +import UIKit + +class ViewController: UIViewController { + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = .green + } +} diff --git a/ChatBot/ChatBot/Resouces/Assets.xcassets/AccentColor.colorset/Contents.json b/ChatBot/ChatBot/Resouces/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/ChatBot/ChatBot/Resouces/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ChatBot/ChatBot/Resouces/Assets.xcassets/AppIcon.appiconset/Contents.json b/ChatBot/ChatBot/Resouces/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/ChatBot/ChatBot/Resouces/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ChatBot/ChatBot/Resouces/Assets.xcassets/Contents.json b/ChatBot/ChatBot/Resouces/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/ChatBot/ChatBot/Resouces/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ChatBot/ChatBot/Resouces/Base.lproj/LaunchScreen.storyboard b/ChatBot/ChatBot/Resouces/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/ChatBot/ChatBot/Resouces/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ChatBot/ChatBot/Resouces/Info.plist b/ChatBot/ChatBot/Resouces/Info.plist new file mode 100644 index 00000000..0eb786dc --- /dev/null +++ b/ChatBot/ChatBot/Resouces/Info.plist @@ -0,0 +1,23 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + + From 64f97d6d4e777696ae9e1fbe798aabe1c3a9178d Mon Sep 17 00:00:00 2001 From: ujhong7 Date: Mon, 1 Apr 2024 20:34:27 +0900 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20=ED=8C=8C=EC=9D=BC=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=9E=AC=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/ChatBot.xcodeproj/project.pbxproj | 96 ++++++++++++++----- ChatBot/ChatBot/AppDelegate.swift | 21 ---- .../AccentColor.colorset/Contents.json | 11 --- .../AppIcon.appiconset/Contents.json | 13 --- .../Resouces/Assets.xcassets/Contents.json | 6 -- .../Base.lproj/LaunchScreen.storyboard | 25 ----- ChatBot/ChatBot/Resouces/Info.plist | 23 ----- .../AccentColor.colorset/Contents.json | 0 .../AppIcon.appiconset/Contents.json | 0 .../Assets.xcassets/Contents.json | 0 .../Base.lproj/LaunchScreen.storyboard | 0 ChatBot/ChatBot/{ => Resources}/Info.plist | 0 ChatBot/ChatBot/SceneDelegate.swift | 27 ------ ChatBot/ChatBot/ViewController.swift | 14 --- 14 files changed, 70 insertions(+), 166 deletions(-) delete mode 100644 ChatBot/ChatBot/AppDelegate.swift delete mode 100644 ChatBot/ChatBot/Resouces/Assets.xcassets/AccentColor.colorset/Contents.json delete mode 100644 ChatBot/ChatBot/Resouces/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 ChatBot/ChatBot/Resouces/Assets.xcassets/Contents.json delete mode 100644 ChatBot/ChatBot/Resouces/Base.lproj/LaunchScreen.storyboard delete mode 100644 ChatBot/ChatBot/Resouces/Info.plist rename ChatBot/ChatBot/{ => Resources}/Assets.xcassets/AccentColor.colorset/Contents.json (100%) rename ChatBot/ChatBot/{ => Resources}/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename ChatBot/ChatBot/{ => Resources}/Assets.xcassets/Contents.json (100%) rename ChatBot/ChatBot/{ => Resources}/Base.lproj/LaunchScreen.storyboard (100%) rename ChatBot/ChatBot/{ => Resources}/Info.plist (100%) delete mode 100644 ChatBot/ChatBot/SceneDelegate.swift delete mode 100644 ChatBot/ChatBot/ViewController.swift diff --git a/ChatBot/ChatBot.xcodeproj/project.pbxproj b/ChatBot/ChatBot.xcodeproj/project.pbxproj index 4de44769..151c86f9 100644 --- a/ChatBot/ChatBot.xcodeproj/project.pbxproj +++ b/ChatBot/ChatBot.xcodeproj/project.pbxproj @@ -7,21 +7,27 @@ objects = { /* Begin PBXBuildFile section */ - B4B3E2BD2B42D1BB00818B3C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2BC2B42D1BB00818B3C /* AppDelegate.swift */; }; - B4B3E2BF2B42D1BB00818B3C /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2BE2B42D1BB00818B3C /* SceneDelegate.swift */; }; - B4B3E2C12B42D1BB00818B3C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B3E2C02B42D1BB00818B3C /* ViewController.swift */; }; - B4B3E2C62B42D1BC00818B3C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B4B3E2C52B42D1BC00818B3C /* Assets.xcassets */; }; - B4B3E2C92B42D1BC00818B3C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B4B3E2C72B42D1BC00818B3C /* LaunchScreen.storyboard */; }; + 1D312FB42BBACF8000169AD3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */; }; + 1D312FB52BBACF8000169AD3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */; }; + 1D312FBC2BBACFA100169AD3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FBA2BBACFA100169AD3 /* ViewController.swift */; }; + 1D312FC22BBACFAF00169AD3 /* ChatRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FBD2BBACFAF00169AD3 /* ChatRequest.swift */; }; + 1D312FC32BBACFAF00169AD3 /* ChatResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FBE2BBACFAF00169AD3 /* ChatResponse.swift */; }; + 1D312FC42BBACFAF00169AD3 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FBF2BBACFAF00169AD3 /* Message.swift */; }; + 1D312FCB2BBACFC200169AD3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1D312FC62BBACFC200169AD3 /* Assets.xcassets */; }; + 1D312FCD2BBACFC200169AD3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1D312FC92BBACFC200169AD3 /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 1D312FBA2BBACFA100169AD3 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 1D312FBD2BBACFAF00169AD3 /* ChatRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatRequest.swift; sourceTree = ""; }; + 1D312FBE2BBACFAF00169AD3 /* ChatResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatResponse.swift; sourceTree = ""; }; + 1D312FBF2BBACFAF00169AD3 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = ""; }; + 1D312FC62BBACFC200169AD3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 1D312FC72BBACFC200169AD3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 1D312FC82BBACFC200169AD3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; B4B3E2B92B42D1BB00818B3C /* ChatBot.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChatBot.app; sourceTree = BUILT_PRODUCTS_DIR; }; - B4B3E2BC2B42D1BB00818B3C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - B4B3E2BE2B42D1BB00818B3C /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - B4B3E2C02B42D1BB00818B3C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - B4B3E2C52B42D1BC00818B3C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - B4B3E2C82B42D1BC00818B3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - B4B3E2CA2B42D1BC00818B3C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,6 +41,43 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1D312FB32BBACF8000169AD3 /* App */ = { + isa = PBXGroup; + children = ( + 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */, + 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */, + ); + path = App; + sourceTree = ""; + }; + 1D312FBB2BBACFA100169AD3 /* Controller */ = { + isa = PBXGroup; + children = ( + 1D312FBA2BBACFA100169AD3 /* ViewController.swift */, + ); + path = Controller; + sourceTree = ""; + }; + 1D312FC12BBACFAF00169AD3 /* Model */ = { + isa = PBXGroup; + children = ( + 1D312FBD2BBACFAF00169AD3 /* ChatRequest.swift */, + 1D312FBE2BBACFAF00169AD3 /* ChatResponse.swift */, + 1D312FBF2BBACFAF00169AD3 /* Message.swift */, + ); + path = Model; + sourceTree = ""; + }; + 1D312FCA2BBACFC200169AD3 /* Resources */ = { + isa = PBXGroup; + children = ( + 1D312FC62BBACFC200169AD3 /* Assets.xcassets */, + 1D312FC72BBACFC200169AD3 /* Info.plist */, + 1D312FC92BBACFC200169AD3 /* LaunchScreen.storyboard */, + ); + path = Resources; + sourceTree = ""; + }; B4B3E2B02B42D1BB00818B3C = { isa = PBXGroup; children = ( @@ -54,12 +97,10 @@ B4B3E2BB2B42D1BB00818B3C /* ChatBot */ = { isa = PBXGroup; children = ( - B4B3E2BC2B42D1BB00818B3C /* AppDelegate.swift */, - B4B3E2BE2B42D1BB00818B3C /* SceneDelegate.swift */, - B4B3E2C02B42D1BB00818B3C /* ViewController.swift */, - B4B3E2C52B42D1BC00818B3C /* Assets.xcassets */, - B4B3E2C72B42D1BC00818B3C /* LaunchScreen.storyboard */, - B4B3E2CA2B42D1BC00818B3C /* Info.plist */, + 1D312FB32BBACF8000169AD3 /* App */, + 1D312FC12BBACFAF00169AD3 /* Model */, + 1D312FCA2BBACFC200169AD3 /* Resources */, + 1D312FBB2BBACFA100169AD3 /* Controller */, ); path = ChatBot; sourceTree = ""; @@ -122,8 +163,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - B4B3E2C92B42D1BC00818B3C /* LaunchScreen.storyboard in Resources */, - B4B3E2C62B42D1BC00818B3C /* Assets.xcassets in Resources */, + 1D312FCB2BBACFC200169AD3 /* Assets.xcassets in Resources */, + 1D312FCD2BBACFC200169AD3 /* LaunchScreen.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -134,19 +175,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B4B3E2C12B42D1BB00818B3C /* ViewController.swift in Sources */, - B4B3E2BD2B42D1BB00818B3C /* AppDelegate.swift in Sources */, - B4B3E2BF2B42D1BB00818B3C /* SceneDelegate.swift in Sources */, + 1D312FC32BBACFAF00169AD3 /* ChatResponse.swift in Sources */, + 1D312FB42BBACF8000169AD3 /* AppDelegate.swift in Sources */, + 1D312FC22BBACFAF00169AD3 /* ChatRequest.swift in Sources */, + 1D312FC42BBACFAF00169AD3 /* Message.swift in Sources */, + 1D312FBC2BBACFA100169AD3 /* ViewController.swift in Sources */, + 1D312FB52BBACF8000169AD3 /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - B4B3E2C72B42D1BC00818B3C /* LaunchScreen.storyboard */ = { + 1D312FC92BBACFC200169AD3 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( - B4B3E2C82B42D1BC00818B3C /* Base */, + 1D312FC82BBACFC200169AD3 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; @@ -282,7 +326,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = W9647FYSN7; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = ChatBot/Info.plist; + INFOPLIST_FILE = ChatBot/Resources/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; @@ -310,7 +354,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = W9647FYSN7; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = ChatBot/Info.plist; + INFOPLIST_FILE = ChatBot/Resources/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; diff --git a/ChatBot/ChatBot/AppDelegate.swift b/ChatBot/ChatBot/AppDelegate.swift deleted file mode 100644 index 735b872a..00000000 --- a/ChatBot/ChatBot/AppDelegate.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// AppDelegate.swift -// ChatBot -// -// Created by Tacocat on 1/1/24. -// - -import UIKit - -@main -class AppDelegate: UIResponder, UIApplicationDelegate { - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - return true - } - - func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { - return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) - } - - func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { } -} diff --git a/ChatBot/ChatBot/Resouces/Assets.xcassets/AccentColor.colorset/Contents.json b/ChatBot/ChatBot/Resouces/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index eb878970..00000000 --- a/ChatBot/ChatBot/Resouces/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/ChatBot/ChatBot/Resouces/Assets.xcassets/AppIcon.appiconset/Contents.json b/ChatBot/ChatBot/Resouces/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 13613e3e..00000000 --- a/ChatBot/ChatBot/Resouces/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "platform" : "ios", - "size" : "1024x1024" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/ChatBot/ChatBot/Resouces/Assets.xcassets/Contents.json b/ChatBot/ChatBot/Resouces/Assets.xcassets/Contents.json deleted file mode 100644 index 73c00596..00000000 --- a/ChatBot/ChatBot/Resouces/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/ChatBot/ChatBot/Resouces/Base.lproj/LaunchScreen.storyboard b/ChatBot/ChatBot/Resouces/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index 865e9329..00000000 --- a/ChatBot/ChatBot/Resouces/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChatBot/ChatBot/Resouces/Info.plist b/ChatBot/ChatBot/Resouces/Info.plist deleted file mode 100644 index 0eb786dc..00000000 --- a/ChatBot/ChatBot/Resouces/Info.plist +++ /dev/null @@ -1,23 +0,0 @@ - - - - - UIApplicationSceneManifest - - UIApplicationSupportsMultipleScenes - - UISceneConfigurations - - UIWindowSceneSessionRoleApplication - - - UISceneConfigurationName - Default Configuration - UISceneDelegateClassName - $(PRODUCT_MODULE_NAME).SceneDelegate - - - - - - diff --git a/ChatBot/ChatBot/Assets.xcassets/AccentColor.colorset/Contents.json b/ChatBot/ChatBot/Resources/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from ChatBot/ChatBot/Assets.xcassets/AccentColor.colorset/Contents.json rename to ChatBot/ChatBot/Resources/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/ChatBot/ChatBot/Assets.xcassets/AppIcon.appiconset/Contents.json b/ChatBot/ChatBot/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from ChatBot/ChatBot/Assets.xcassets/AppIcon.appiconset/Contents.json rename to ChatBot/ChatBot/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/ChatBot/ChatBot/Assets.xcassets/Contents.json b/ChatBot/ChatBot/Resources/Assets.xcassets/Contents.json similarity index 100% rename from ChatBot/ChatBot/Assets.xcassets/Contents.json rename to ChatBot/ChatBot/Resources/Assets.xcassets/Contents.json diff --git a/ChatBot/ChatBot/Base.lproj/LaunchScreen.storyboard b/ChatBot/ChatBot/Resources/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from ChatBot/ChatBot/Base.lproj/LaunchScreen.storyboard rename to ChatBot/ChatBot/Resources/Base.lproj/LaunchScreen.storyboard diff --git a/ChatBot/ChatBot/Info.plist b/ChatBot/ChatBot/Resources/Info.plist similarity index 100% rename from ChatBot/ChatBot/Info.plist rename to ChatBot/ChatBot/Resources/Info.plist diff --git a/ChatBot/ChatBot/SceneDelegate.swift b/ChatBot/ChatBot/SceneDelegate.swift deleted file mode 100644 index b11fdd3e..00000000 --- a/ChatBot/ChatBot/SceneDelegate.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// SceneDelegate.swift -// ChatBot -// -// Created by Tacocat on 1/1/24. -// - -import UIKit - -class SceneDelegate: UIResponder, UIWindowSceneDelegate { - var window: UIWindow? - - func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - guard let windowScene = (scene as? UIWindowScene) else { return } - - let window = UIWindow(windowScene: windowScene) - window.rootViewController = ViewController() - window.makeKeyAndVisible() - self.window = window - } - - func sceneDidDisconnect(_ scene: UIScene) { } - func sceneDidBecomeActive(_ scene: UIScene) { } - func sceneWillResignActive(_ scene: UIScene) { } - func sceneWillEnterForeground(_ scene: UIScene) { } - func sceneDidEnterBackground(_ scene: UIScene) { } -} diff --git a/ChatBot/ChatBot/ViewController.swift b/ChatBot/ChatBot/ViewController.swift deleted file mode 100644 index 2ed5f125..00000000 --- a/ChatBot/ChatBot/ViewController.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// ViewController.swift -// ChatBot -// -// Created by Tacocat on 1/1/24. -// - -import UIKit - -class ViewController: UIViewController { - override func viewDidLoad() { - super.viewDidLoad() - } -} From 1391adf5d6615095e45645eee618b622eba2cb87 Mon Sep 17 00:00:00 2001 From: ujhong7 Date: Wed, 3 Apr 2024 16:26:29 +0900 Subject: [PATCH 07/12] =?UTF-8?q?docs:=20TODO=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/ChatBot/App/SceneDelegate.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/ChatBot/ChatBot/App/SceneDelegate.swift b/ChatBot/ChatBot/App/SceneDelegate.swift index b11fdd3e..6b4e84a4 100644 --- a/ChatBot/ChatBot/App/SceneDelegate.swift +++ b/ChatBot/ChatBot/App/SceneDelegate.swift @@ -13,6 +13,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } + // TODO: - rootViewController 설정 let window = UIWindow(windowScene: windowScene) window.rootViewController = ViewController() window.makeKeyAndVisible() From 5f39c6860937b15ff13eb95eb7103e61d599e221 Mon Sep 17 00:00:00 2001 From: ujhong7 Date: Wed, 3 Apr 2024 16:28:11 +0900 Subject: [PATCH 08/12] =?UTF-8?q?refactor:=20model,=20stream=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=EA=B0=92=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/ChatBot/Model/ChatRequest.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ChatBot/ChatBot/Model/ChatRequest.swift b/ChatBot/ChatBot/Model/ChatRequest.swift index b66c76a5..8e757bc1 100644 --- a/ChatBot/ChatBot/Model/ChatRequest.swift +++ b/ChatBot/ChatBot/Model/ChatRequest.swift @@ -8,11 +8,9 @@ import Foundation struct ChatRequest: Codable { - let model: GPTModel - let stream: Bool + var model: String = "gpt-3.5-turbo-1106" + var stream: Bool = false let messages: [Message] } -enum GPTModel: String, Codable { - case main = "gpt-3.5-turbo-1106" -} + From b325621a6ebc94ad4c12f751f5d2b4800c40e457 Mon Sep 17 00:00:00 2001 From: rlwhs12 <150293158+rlwhs12@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:04:51 +0900 Subject: [PATCH 09/12] test --- ChatBot/ChatBot/Model/Message.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChatBot/ChatBot/Model/Message.swift b/ChatBot/ChatBot/Model/Message.swift index 617a0542..da2ea700 100644 --- a/ChatBot/ChatBot/Model/Message.swift +++ b/ChatBot/ChatBot/Model/Message.swift @@ -11,3 +11,5 @@ struct Message: Codable { let role: String let content: String } + +// test From 990d5b97da7f269071db305a7e0ebc593f72beab Mon Sep 17 00:00:00 2001 From: rlwhs12 <150293158+rlwhs12@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:12:05 +0900 Subject: [PATCH 10/12] =?UTF-8?q?feat:=20api=20key=20=EC=88=A8=EA=B8=B0?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes ChatBot/.gitignore | 3 +++ ChatBot/ChatBot.xcodeproj/project.pbxproj | 4 ++++ 3 files changed, 7 insertions(+) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7baf41ebd99fd65ae7e1688a6329f3b13f14b443 GIT binary patch literal 6148 zcmeHK%}T>S5T0$TO({YT3Oz1(Etr-f7B3;z7cim+m736EgE3p$)E-J9XMG``#OHBl zcLP>?@FZeqVE3DypWVy{*&hH9{(RU5XaInNjZl!XLCCz(RkFc^LeJrYf-G9hCQ-6s zqQ7XOZ?D1`j3I;!K7GH6(DN2el6aQ6?z84HYJ)~|x$L;@mh7DL zRxP>gb=;Qh9(Px(nsab?bb2v(OrBEpVyG0zx|ThQ1-zp2rK;y(nkFiJKu?iXL^Co2 z%m6dM3~Uzz_8f5P+f_DK%M36BKVX3N2Z@c)vzQyyTL*S@eI|c}kOXylOAtznp2gfC zdQgN(MKr0xJ~4zzN4vCfp2ggtNe7`<#(C_@#p6Zj)zL0>I0(-m_sjq@u+Bi)3>$R* zpW`pH@sYot!XsvY8Te-mh)O@``&g7cTfdb@XRX9`kBx-la#B!GU%Le0fcBB5b{fAV a9pgNUxj~wR>^dEhF9Mnn?wEmJVBiCo`b+5m literal 0 HcmV?d00001 diff --git a/ChatBot/.gitignore b/ChatBot/.gitignore index 2995c9bf..e5dd6d4f 100644 --- a/ChatBot/.gitignore +++ b/ChatBot/.gitignore @@ -112,4 +112,7 @@ iOSInjectionProject/ !*.xcworkspace/contents.xcworkspacedata **/xcshareddata/WorkspaceSettings.xcsettings +## APIKEY +Api_Key.plist + # End of https://www.toptal.com/developers/gitignore/api/xcode,swift,cocoapods diff --git a/ChatBot/ChatBot.xcodeproj/project.pbxproj b/ChatBot/ChatBot.xcodeproj/project.pbxproj index 151c86f9..28bd7ce2 100644 --- a/ChatBot/ChatBot.xcodeproj/project.pbxproj +++ b/ChatBot/ChatBot.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 15D33E822BBFE96D00F88B25 /* Api_key.plist in Resources */ = {isa = PBXBuildFile; fileRef = 15D33E812BBFE96D00F88B25 /* Api_key.plist */; }; 1D312FB42BBACF8000169AD3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */; }; 1D312FB52BBACF8000169AD3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */; }; 1D312FBC2BBACFA100169AD3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FBA2BBACFA100169AD3 /* ViewController.swift */; }; @@ -18,6 +19,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 15D33E812BBFE96D00F88B25 /* Api_key.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Api_key.plist; sourceTree = ""; }; 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 1D312FBA2BBACFA100169AD3 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -71,6 +73,7 @@ 1D312FCA2BBACFC200169AD3 /* Resources */ = { isa = PBXGroup; children = ( + 15D33E812BBFE96D00F88B25 /* Api_key.plist */, 1D312FC62BBACFC200169AD3 /* Assets.xcassets */, 1D312FC72BBACFC200169AD3 /* Info.plist */, 1D312FC92BBACFC200169AD3 /* LaunchScreen.storyboard */, @@ -163,6 +166,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15D33E822BBFE96D00F88B25 /* Api_key.plist in Resources */, 1D312FCB2BBACFC200169AD3 /* Assets.xcassets in Resources */, 1D312FCD2BBACFC200169AD3 /* LaunchScreen.storyboard in Resources */, ); From bb481bc83f6c7475d31db692de736515d209fe76 Mon Sep 17 00:00:00 2001 From: rlwhs12 <150293158+rlwhs12@users.noreply.github.com> Date: Mon, 8 Apr 2024 14:19:01 +0900 Subject: [PATCH 11/12] =?UTF-8?q?feat:=20=EB=84=A4=ED=8A=B8=EC=9B=8C?= =?UTF-8?q?=ED=81=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/ChatBot.xcodeproj/project.pbxproj | 36 ++++++++- .../ChatBot/Extension/Bundel+Extension.swift | 19 +++++ ChatBot/ChatBot/Model/Message.swift | 2 - ChatBot/ChatBot/Network/NetworkError.swift | 25 ++++++ ChatBot/ChatBot/Network/NetworkManager.swift | 76 +++++++++++++++++++ 5 files changed, 152 insertions(+), 6 deletions(-) create mode 100644 ChatBot/ChatBot/Extension/Bundel+Extension.swift create mode 100644 ChatBot/ChatBot/Network/NetworkError.swift create mode 100644 ChatBot/ChatBot/Network/NetworkManager.swift diff --git a/ChatBot/ChatBot.xcodeproj/project.pbxproj b/ChatBot/ChatBot.xcodeproj/project.pbxproj index 28bd7ce2..3484f8d7 100644 --- a/ChatBot/ChatBot.xcodeproj/project.pbxproj +++ b/ChatBot/ChatBot.xcodeproj/project.pbxproj @@ -7,7 +7,10 @@ objects = { /* Begin PBXBuildFile section */ - 15D33E822BBFE96D00F88B25 /* Api_key.plist in Resources */ = {isa = PBXBuildFile; fileRef = 15D33E812BBFE96D00F88B25 /* Api_key.plist */; }; + 1512D68D2BC3B42F00FDB7F6 /* Bundel+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1512D68C2BC3B42F00FDB7F6 /* Bundel+Extension.swift */; }; + 1512D6902BC3B4E800FDB7F6 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1512D68F2BC3B4E800FDB7F6 /* NetworkManager.swift */; }; + 1512D6922BC3B58900FDB7F6 /* NetworkError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1512D6912BC3B58900FDB7F6 /* NetworkError.swift */; }; + 15D33E822BBFE96D00F88B25 /* Api_Key.plist in Resources */ = {isa = PBXBuildFile; fileRef = 15D33E812BBFE96D00F88B25 /* Api_Key.plist */; }; 1D312FB42BBACF8000169AD3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */; }; 1D312FB52BBACF8000169AD3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */; }; 1D312FBC2BBACFA100169AD3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FBA2BBACFA100169AD3 /* ViewController.swift */; }; @@ -19,7 +22,10 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 15D33E812BBFE96D00F88B25 /* Api_key.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Api_key.plist; sourceTree = ""; }; + 1512D68C2BC3B42F00FDB7F6 /* Bundel+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundel+Extension.swift"; sourceTree = ""; }; + 1512D68F2BC3B4E800FDB7F6 /* NetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkManager.swift; sourceTree = ""; }; + 1512D6912BC3B58900FDB7F6 /* NetworkError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkError.swift; sourceTree = ""; }; + 15D33E812BBFE96D00F88B25 /* Api_Key.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Api_Key.plist; sourceTree = ""; }; 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 1D312FBA2BBACFA100169AD3 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -43,6 +49,23 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1512D68B2BC3B41A00FDB7F6 /* Extension */ = { + isa = PBXGroup; + children = ( + 1512D68C2BC3B42F00FDB7F6 /* Bundel+Extension.swift */, + ); + path = Extension; + sourceTree = ""; + }; + 1512D68E2BC3B4D400FDB7F6 /* Network */ = { + isa = PBXGroup; + children = ( + 1512D68F2BC3B4E800FDB7F6 /* NetworkManager.swift */, + 1512D6912BC3B58900FDB7F6 /* NetworkError.swift */, + ); + path = Network; + sourceTree = ""; + }; 1D312FB32BBACF8000169AD3 /* App */ = { isa = PBXGroup; children = ( @@ -73,7 +96,7 @@ 1D312FCA2BBACFC200169AD3 /* Resources */ = { isa = PBXGroup; children = ( - 15D33E812BBFE96D00F88B25 /* Api_key.plist */, + 15D33E812BBFE96D00F88B25 /* Api_Key.plist */, 1D312FC62BBACFC200169AD3 /* Assets.xcassets */, 1D312FC72BBACFC200169AD3 /* Info.plist */, 1D312FC92BBACFC200169AD3 /* LaunchScreen.storyboard */, @@ -100,6 +123,8 @@ B4B3E2BB2B42D1BB00818B3C /* ChatBot */ = { isa = PBXGroup; children = ( + 1512D68E2BC3B4D400FDB7F6 /* Network */, + 1512D68B2BC3B41A00FDB7F6 /* Extension */, 1D312FB32BBACF8000169AD3 /* App */, 1D312FC12BBACFAF00169AD3 /* Model */, 1D312FCA2BBACFC200169AD3 /* Resources */, @@ -166,7 +191,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 15D33E822BBFE96D00F88B25 /* Api_key.plist in Resources */, + 15D33E822BBFE96D00F88B25 /* Api_Key.plist in Resources */, 1D312FCB2BBACFC200169AD3 /* Assets.xcassets in Resources */, 1D312FCD2BBACFC200169AD3 /* LaunchScreen.storyboard in Resources */, ); @@ -183,7 +208,10 @@ 1D312FB42BBACF8000169AD3 /* AppDelegate.swift in Sources */, 1D312FC22BBACFAF00169AD3 /* ChatRequest.swift in Sources */, 1D312FC42BBACFAF00169AD3 /* Message.swift in Sources */, + 1512D6902BC3B4E800FDB7F6 /* NetworkManager.swift in Sources */, 1D312FBC2BBACFA100169AD3 /* ViewController.swift in Sources */, + 1512D6922BC3B58900FDB7F6 /* NetworkError.swift in Sources */, + 1512D68D2BC3B42F00FDB7F6 /* Bundel+Extension.swift in Sources */, 1D312FB52BBACF8000169AD3 /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ChatBot/ChatBot/Extension/Bundel+Extension.swift b/ChatBot/ChatBot/Extension/Bundel+Extension.swift new file mode 100644 index 00000000..6e875124 --- /dev/null +++ b/ChatBot/ChatBot/Extension/Bundel+Extension.swift @@ -0,0 +1,19 @@ + +import Foundation + +extension Bundle { + + // 생성한 .plist 파일 경로 불러오기 + var OPENAI_API_KEY: String { + guard let file = self.path(forResource: "Api_Key", ofType: "plist") else { return "" } + + // .plist를 딕셔너리로 받아오기 + guard let resource = NSDictionary(contentsOfFile: file) else { return "" } + + // 딕셔너리에서 값 찾기 + guard let key = resource["myApiKey"] as? String else { + fatalError("API_KEY error") + } + return key + } +} diff --git a/ChatBot/ChatBot/Model/Message.swift b/ChatBot/ChatBot/Model/Message.swift index da2ea700..617a0542 100644 --- a/ChatBot/ChatBot/Model/Message.swift +++ b/ChatBot/ChatBot/Model/Message.swift @@ -11,5 +11,3 @@ struct Message: Codable { let role: String let content: String } - -// test diff --git a/ChatBot/ChatBot/Network/NetworkError.swift b/ChatBot/ChatBot/Network/NetworkError.swift new file mode 100644 index 00000000..d6f6353c --- /dev/null +++ b/ChatBot/ChatBot/Network/NetworkError.swift @@ -0,0 +1,25 @@ + +import Foundation + +enum NetworkError: Error { + case urlError + case dataError + case decoderError + case requestError + case invalidResponse + + var errorMessage: String { + switch self { + case .urlError: + return "URL 에러 입니다." + case .dataError: + return "데이터 에러 입니다." + case .decoderError: + return "JSON 에러 입니다" + case .requestError: + return "request 에러 입니다." + case .invalidResponse: + return "invalidResponse 에러 입니다." + } + } +} diff --git a/ChatBot/ChatBot/Network/NetworkManager.swift b/ChatBot/ChatBot/Network/NetworkManager.swift new file mode 100644 index 00000000..a2012d53 --- /dev/null +++ b/ChatBot/ChatBot/Network/NetworkManager.swift @@ -0,0 +1,76 @@ + +import Foundation + +struct NetworkManger { + + let apiKey = Bundle.main.OPENAI_API_KEY + + func UrlComponents() -> URL?{ + var urlComponents = URLComponents() + urlComponents.scheme = "https" + urlComponents.host = "api.openai.com" + urlComponents.path = "/v1/chat/completions" + + return urlComponents.url + } + + func UrlRequset() -> URLRequest? { + guard let url = UrlComponents() else { + return nil + } + + var request = URLRequest(url: url) + request.httpMethod = "POST" + let header = ["Authorization": "Bearer \(apiKey)"] + print(header) + print("apikey\(apiKey)") + request.allHTTPHeaderFields = header + request.setValue("application/json", forHTTPHeaderField: "Content-Type") + + let bodyData = ChatRequest(messages: [.init(role: "system", content: "어렵다"),Message(role: "user", content: "swift 설명해줘 ")]) + + guard let body = try? JSONEncoder().encode(bodyData) else { + return nil + } + request.httpBody = body + + return request + + } + + func DecodedData(data: Data?) -> (Result) { + guard + let data = data + else { + return .failure(.dataError) + } + do { + let decodedData = try JSONDecoder().decode(T.self, from: data) + return .success(decodedData) + } catch { + print("Decoding failed with error:", error) + return .failure(.decoderError) + } + } + + func urlDataTaks(completion: @escaping (Result) -> Void) { + guard let request = UrlRequset() else { + completion(.failure(NetworkError.urlError)) + return + } + URLSession.shared.dataTask(with: request) { (data, response, error) in + if error != nil { + completion(.failure(NetworkError.dataError)) + } + guard let response = response as? HTTPURLResponse, (200...299).contains(response.statusCode) else { + completion(.failure(NetworkError.invalidResponse)) + return + } + guard let data = data else { + completion(.failure(NetworkError.dataError)) + return + } + completion(.success(data)) + }.resume() + } +} From c695795e0fc9f54f64bbcfa135df91c93afe7397 Mon Sep 17 00:00:00 2001 From: rlwhs12 <150293158+rlwhs12@users.noreply.github.com> Date: Mon, 8 Apr 2024 14:38:29 +0900 Subject: [PATCH 12/12] =?UTF-8?q?feat:=20=EB=AA=A8=EB=8D=B8=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20=EC=8B=A4=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatBot/ChatBot.xcodeproj/project.pbxproj | 8 ++++++ .../ChatBot/Controller/ViewController.swift | 24 ++++++++++++++-- ChatBot/ChatBot/Model/ChatRequest.swift | 10 +++++-- ChatBot/ChatBot/Model/ChatResponse.swift | 28 +++++-------------- ChatBot/ChatBot/Model/Choice.swift | 16 +++++++++++ ChatBot/ChatBot/Model/Usage.swift | 14 ++++++++++ ChatBot/ChatBot/Network/NetworkManager.swift | 4 +-- 7 files changed, 75 insertions(+), 29 deletions(-) create mode 100644 ChatBot/ChatBot/Model/Choice.swift create mode 100644 ChatBot/ChatBot/Model/Usage.swift diff --git a/ChatBot/ChatBot.xcodeproj/project.pbxproj b/ChatBot/ChatBot.xcodeproj/project.pbxproj index 3484f8d7..6d30523a 100644 --- a/ChatBot/ChatBot.xcodeproj/project.pbxproj +++ b/ChatBot/ChatBot.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ 1512D68D2BC3B42F00FDB7F6 /* Bundel+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1512D68C2BC3B42F00FDB7F6 /* Bundel+Extension.swift */; }; 1512D6902BC3B4E800FDB7F6 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1512D68F2BC3B4E800FDB7F6 /* NetworkManager.swift */; }; 1512D6922BC3B58900FDB7F6 /* NetworkError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1512D6912BC3B58900FDB7F6 /* NetworkError.swift */; }; + 1512D6942BC3B66B00FDB7F6 /* Choice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1512D6932BC3B66B00FDB7F6 /* Choice.swift */; }; + 1512D6962BC3B68F00FDB7F6 /* Usage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1512D6952BC3B68F00FDB7F6 /* Usage.swift */; }; 15D33E822BBFE96D00F88B25 /* Api_Key.plist in Resources */ = {isa = PBXBuildFile; fileRef = 15D33E812BBFE96D00F88B25 /* Api_Key.plist */; }; 1D312FB42BBACF8000169AD3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */; }; 1D312FB52BBACF8000169AD3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */; }; @@ -25,6 +27,8 @@ 1512D68C2BC3B42F00FDB7F6 /* Bundel+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundel+Extension.swift"; sourceTree = ""; }; 1512D68F2BC3B4E800FDB7F6 /* NetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkManager.swift; sourceTree = ""; }; 1512D6912BC3B58900FDB7F6 /* NetworkError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkError.swift; sourceTree = ""; }; + 1512D6932BC3B66B00FDB7F6 /* Choice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Choice.swift; sourceTree = ""; }; + 1512D6952BC3B68F00FDB7F6 /* Usage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Usage.swift; sourceTree = ""; }; 15D33E812BBFE96D00F88B25 /* Api_Key.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Api_Key.plist; sourceTree = ""; }; 1D312FB12BBACF8000169AD3 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 1D312FB22BBACF8000169AD3 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -88,6 +92,8 @@ children = ( 1D312FBD2BBACFAF00169AD3 /* ChatRequest.swift */, 1D312FBE2BBACFAF00169AD3 /* ChatResponse.swift */, + 1512D6932BC3B66B00FDB7F6 /* Choice.swift */, + 1512D6952BC3B68F00FDB7F6 /* Usage.swift */, 1D312FBF2BBACFAF00169AD3 /* Message.swift */, ); path = Model; @@ -208,8 +214,10 @@ 1D312FB42BBACF8000169AD3 /* AppDelegate.swift in Sources */, 1D312FC22BBACFAF00169AD3 /* ChatRequest.swift in Sources */, 1D312FC42BBACFAF00169AD3 /* Message.swift in Sources */, + 1512D6962BC3B68F00FDB7F6 /* Usage.swift in Sources */, 1512D6902BC3B4E800FDB7F6 /* NetworkManager.swift in Sources */, 1D312FBC2BBACFA100169AD3 /* ViewController.swift in Sources */, + 1512D6942BC3B66B00FDB7F6 /* Choice.swift in Sources */, 1512D6922BC3B58900FDB7F6 /* NetworkError.swift in Sources */, 1512D68D2BC3B42F00FDB7F6 /* Bundel+Extension.swift in Sources */, 1D312FB52BBACF8000169AD3 /* SceneDelegate.swift in Sources */, diff --git a/ChatBot/ChatBot/Controller/ViewController.swift b/ChatBot/ChatBot/Controller/ViewController.swift index 17ab98d0..8a651ce0 100644 --- a/ChatBot/ChatBot/Controller/ViewController.swift +++ b/ChatBot/ChatBot/Controller/ViewController.swift @@ -8,9 +8,29 @@ import UIKit class ViewController: UIViewController { + + var networkManger = NetworkManger() + override func viewDidLoad() { super.viewDidLoad() - - view.backgroundColor = .green + view.backgroundColor = .white + fetchChatMessage() + } + + func fetchChatMessage() { + networkManger.urlDataTaks { result in + switch result { + case .success(let data): + let decodedResult: Result = self.networkManger.DecodedData(data: data) + switch decodedResult { + case .success(let decodedData): + print("Decoded data:", decodedData) + case .failure(let error): + print("Decoding failed with error:", error.localizedDescription) + } + case .failure(let error): + print("Error:", error.localizedDescription) + } + } } } diff --git a/ChatBot/ChatBot/Model/ChatRequest.swift b/ChatBot/ChatBot/Model/ChatRequest.swift index 8e757bc1..548b80be 100644 --- a/ChatBot/ChatBot/Model/ChatRequest.swift +++ b/ChatBot/ChatBot/Model/ChatRequest.swift @@ -9,8 +9,12 @@ import Foundation struct ChatRequest: Codable { var model: String = "gpt-3.5-turbo-1106" - var stream: Bool = false + var isFalse: Bool = false let messages: [Message] + + enum CodingKeys: String ,CodingKey { + case model + case isFalse = "stream" + case messages + } } - - diff --git a/ChatBot/ChatBot/Model/ChatResponse.swift b/ChatBot/ChatBot/Model/ChatResponse.swift index 8852a6ec..972899e9 100644 --- a/ChatBot/ChatBot/Model/ChatResponse.swift +++ b/ChatBot/ChatBot/Model/ChatResponse.swift @@ -15,29 +15,15 @@ struct ChatResponse: Codable { let systemFingerprint: String let choices: [Choice] let usage: Usage -} - -struct Choice: Codable { - let index: Int - let message: Message - let finishReason: String - - enum CodingKeys: String, CodingKey { - case index - case message - case finishReason = "finish_reason" - } -} - -struct Usage: Codable { - let promptTokens: Int - let completionTokens: Int - let totalTokens: Int enum CodingKeys: String, CodingKey { - case promptTokens = "prompt_tokens" - case completionTokens = "completion_tokens" - case totalTokens = "total_tokens" + case id + case object + case created + case model + case choices + case usage + case systemFingerprint = "system_fingerprint" } } diff --git a/ChatBot/ChatBot/Model/Choice.swift b/ChatBot/ChatBot/Model/Choice.swift new file mode 100644 index 00000000..1fa01827 --- /dev/null +++ b/ChatBot/ChatBot/Model/Choice.swift @@ -0,0 +1,16 @@ + +import Foundation + +struct Choice: Codable { + let index: Int + let message: Message + let logprobs: String? + let finishReason: String + + enum CodingKeys: String, CodingKey { + case index + case message + case logprobs + case finishReason = "finish_reason" + } +} diff --git a/ChatBot/ChatBot/Model/Usage.swift b/ChatBot/ChatBot/Model/Usage.swift new file mode 100644 index 00000000..3e6bde45 --- /dev/null +++ b/ChatBot/ChatBot/Model/Usage.swift @@ -0,0 +1,14 @@ + +import Foundation + +struct Usage: Codable { + let promptTokens: Int + let completionTokens: Int + let totalTokens: Int + + enum CodingKeys: String, CodingKey { + case promptTokens = "prompt_tokens" + case completionTokens = "completion_tokens" + case totalTokens = "total_tokens" + } +} diff --git a/ChatBot/ChatBot/Network/NetworkManager.swift b/ChatBot/ChatBot/Network/NetworkManager.swift index a2012d53..92681527 100644 --- a/ChatBot/ChatBot/Network/NetworkManager.swift +++ b/ChatBot/ChatBot/Network/NetworkManager.swift @@ -22,12 +22,10 @@ struct NetworkManger { var request = URLRequest(url: url) request.httpMethod = "POST" let header = ["Authorization": "Bearer \(apiKey)"] - print(header) - print("apikey\(apiKey)") request.allHTTPHeaderFields = header request.setValue("application/json", forHTTPHeaderField: "Content-Type") - let bodyData = ChatRequest(messages: [.init(role: "system", content: "어렵다"),Message(role: "user", content: "swift 설명해줘 ")]) + let bodyData = ChatRequest(messages: [.init(role: "system", content: "어렵다"),Message(role: "user", content: "swift언어 설명해줘 ")]) guard let body = try? JSONEncoder().encode(bodyData) else { return nil