Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENG-1721 #2

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Example/ChatKitExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
46072CB12C7D3091008BAAAD /* SwallowMacrosClient in Frameworks */ = {isa = PBXBuildFile; productRef = 46072CB02C7D3091008BAAAD /* SwallowMacrosClient */; };
468FD7602C298504007F4C41 /* Sideproject in Frameworks */ = {isa = PBXBuildFile; productRef = 468FD75F2C298504007F4C41 /* Sideproject */; };
46978A872B0D27C300DF0752 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46978A592B0D27C200DF0752 /* ContentView.swift */; };
9856E6D42D08AA84009359D9 /* Swallow in Frameworks */ = {isa = PBXBuildFile; productRef = 9856E6D32D08AA84009359D9 /* Swallow */; };
9856E6D62D08AA84009359D9 /* SwallowMacrosClient in Frameworks */ = {isa = PBXBuildFile; productRef = 9856E6D52D08AA84009359D9 /* SwallowMacrosClient */; };
D47A38AB294E861E002C06CA /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47A38AA294E861E002C06CA /* App.swift */; };
D47A38AF294E861F002C06CA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D47A38AE294E861F002C06CA /* Assets.xcassets */; };
/* End PBXBuildFile section */
Expand All @@ -29,6 +31,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9856E6D42D08AA84009359D9 /* Swallow in Frameworks */,
9856E6D62D08AA84009359D9 /* SwallowMacrosClient in Frameworks */,
46072CAF2C7D3091008BAAAD /* Swallow in Frameworks */,
46072CB12C7D3091008BAAAD /* SwallowMacrosClient in Frameworks */,
468FD7602C298504007F4C41 /* Sideproject in Frameworks */,
Expand Down Expand Up @@ -118,6 +122,8 @@
468FD75F2C298504007F4C41 /* Sideproject */,
46072CAE2C7D3091008BAAAD /* Swallow */,
46072CB02C7D3091008BAAAD /* SwallowMacrosClient */,
9856E6D32D08AA84009359D9 /* Swallow */,
9856E6D52D08AA84009359D9 /* SwallowMacrosClient */,
);
productName = ExampleApp;
productReference = D47A38A7294E861E002C06CA /* ChatKitExample.app */;
Expand Down Expand Up @@ -149,6 +155,7 @@
mainGroup = D47A389E294E861E002C06CA;
packageReferences = (
468FD75E2C298504007F4C41 /* XCRemoteSwiftPackageReference "Sideproject" */,
9856E6D22D08AA84009359D9 /* XCRemoteSwiftPackageReference "Swallow" */,
);
productRefGroup = D47A38A8294E861E002C06CA /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -433,6 +440,14 @@
kind = branch;
};
};
9856E6D22D08AA84009359D9 /* XCRemoteSwiftPackageReference "Swallow" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/vmanot/Swallow.git";
requirement = {
branch = master;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -449,6 +464,16 @@
package = 468FD75E2C298504007F4C41 /* XCRemoteSwiftPackageReference "Sideproject" */;
productName = Sideproject;
};
9856E6D32D08AA84009359D9 /* Swallow */ = {
isa = XCSwiftPackageProductDependency;
package = 9856E6D22D08AA84009359D9 /* XCRemoteSwiftPackageReference "Swallow" */;
productName = Swallow;
};
9856E6D52D08AA84009359D9 /* SwallowMacrosClient */ = {
isa = XCSwiftPackageProductDependency;
package = 9856E6D22D08AA84009359D9 /* XCRemoteSwiftPackageReference "Swallow" */;
productName = SwallowMacrosClient;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = D47A389F294E861E002C06CA /* Project object */;
Expand Down
18 changes: 12 additions & 6 deletions Example/Targets/ChatKitExample/Files/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import CorePersistence
import Perplexity
import Sideproject

@Singleton
Expand All @@ -14,6 +15,12 @@ final class DataStore: ObservableObject {
options: .init(readErrorRecoveryStrategy: .discardAndReset)
)
var chats: IdentifierIndexingArrayOf<Sideproject.ChatFile> = []

init() {
chats._forEach(mutating: {
$0.model = Perplexity.Model.llama3SonarLarge32kChat.__conversion()
})
}
}

public struct ContentView: View {
Expand All @@ -22,7 +29,7 @@ public struct ContentView: View {
@UserStorage("navigationSelection", deferUpdates: true)
var selection: Sideproject.ChatFile.ID?

@State var llm: (any LLMRequestHandling)? = Sideproject.shared
@State var llm: Perplexity.Client? = Perplexity.Client(apiKey: "<APIKEY>")

public var body: some View {
NavigationSplitView {
Expand Down Expand Up @@ -54,14 +61,13 @@ public struct ContentView: View {
} detail: {
Group {
if
let llm = llm,
let llm: any LLMRequestHandling = llm,
let selection = selection,
let chat: Sideproject.ChatFile = dataStore.chats[id: selection]
{
Sideproject.ChatView(
messages: chat.messages,
llm: llm
)
let chatBinding: PublishedAsyncBinding<Sideproject.ChatFile> = PublishedAsyncBinding.unwrapping(dataStore, \.chats[id: selection], defaultValue: chat)

Sideproject.ChatView(chatBinding, llm: llm)
}
}
.id(selection)
Expand Down