Skip to content

Commit

Permalink
2024011
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang-hongshen committed Apr 11, 2024
1 parent ba1b0ec commit 2586edb
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 30 deletions.
Binary file added ModelCraft.dmg
Binary file not shown.
55 changes: 47 additions & 8 deletions ModelCraft.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
70271B3A2BC0455000E21A6E /* ollama in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70271B382BC0452C00E21A6E /* ollama */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
7019541A2BC7891C00CD2ED3 /* ollama in Resources */ = {isa = PBXBuildFile; fileRef = 701954192BC7891C00CD2ED3 /* ollama */; };
7019541B2BC7892900CD2ED3 /* ollama in CopyFiles */ = {isa = PBXBuildFile; fileRef = 701954192BC7891C00CD2ED3 /* ollama */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
7019541E2BC78DF100CD2ED3 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 7019541D2BC78DF100CD2ED3 /* Sparkle */; };
701954202BC78E1800CD2ED3 /* CheckForUpdatesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7019541F2BC78E1800CD2ED3 /* CheckForUpdatesView.swift */; };
70271B3C2BC046F300E21A6E /* KnowledgaBaseModelActor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70271B3B2BC046F300E21A6E /* KnowledgaBaseModelActor.swift */; };
70271B5E2BC1A97900E21A6E /* ModelStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70271B5D2BC1A97900E21A6E /* ModelStore.swift */; };
70271B782BC4412E00E21A6E /* SpeechRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70271B772BC4412E00E21A6E /* SpeechRecognizer.swift */; };
Expand Down Expand Up @@ -100,15 +103,16 @@
dstPath = "";
dstSubfolderSpec = 6;
files = (
70271B3A2BC0455000E21A6E /* ollama in CopyFiles */,
7019541B2BC7892900CD2ED3 /* ollama in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
701954192BC7891C00CD2ED3 /* ollama */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = ollama; sourceTree = "<group>"; };
7019541F2BC78E1800CD2ED3 /* CheckForUpdatesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckForUpdatesView.swift; sourceTree = "<group>"; };
70271B362BBEFAA500E21A6E /* OllamaKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = OllamaKit; path = ../OllamaKit; sourceTree = "<group>"; };
70271B382BC0452C00E21A6E /* ollama */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = ollama; sourceTree = "<group>"; };
70271B3B2BC046F300E21A6E /* KnowledgaBaseModelActor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KnowledgaBaseModelActor.swift; sourceTree = "<group>"; };
70271B5D2BC1A97900E21A6E /* ModelStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModelStore.swift; sourceTree = "<group>"; };
70271B772BC4412E00E21A6E /* SpeechRecognizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeechRecognizer.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -179,6 +183,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7019541E2BC78DF100CD2ED3 /* Sparkle in Frameworks */,
70A574A82BB0716A008E3750 /* OrderedCollections in Frameworks */,
70C22FDF2BAFD463002754C7 /* Kingfisher in Frameworks */,
70E201722BADE31700CFE1D7 /* Alamofire in Frameworks */,
Expand Down Expand Up @@ -207,6 +212,22 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
701954182BC788D200CD2ED3 /* Executables */ = {
isa = PBXGroup;
children = (
701954192BC7891C00CD2ED3 /* ollama */,
);
path = Executables;
sourceTree = "<group>";
};
701954212BC78E5000CD2ED3 /* Update */ = {
isa = PBXGroup;
children = (
7019541F2BC78E1800CD2ED3 /* CheckForUpdatesView.swift */,
);
path = Update;
sourceTree = "<group>";
};
70271B792BC4E2CC00E21A6E /* Models */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -355,7 +376,6 @@
70CE605B2BAD2D4500A2D0B0 = {
isa = PBXGroup;
children = (
70271B382BC0452C00E21A6E /* ollama */,
70271B362BBEFAA500E21A6E /* OllamaKit */,
70CE60662BAD2D4500A2D0B0 /* ModelCraft */,
70CE607A2BAD2D4700A2D0B0 /* ModelCraftTests */,
Expand All @@ -377,6 +397,7 @@
70CE60662BAD2D4500A2D0B0 /* ModelCraft */ = {
isa = PBXGroup;
children = (
701954182BC788D200CD2ED3 /* Executables */,
70CE606F2BAD2D4600A2D0B0 /* ModelCraft.entitlements */,
7045BF462BB3FE0A00CE61D1 /* Info.plist */,
70CE60692BAD2D4500A2D0B0 /* ContentView.swift */,
Expand Down Expand Up @@ -436,6 +457,7 @@
70CE60C92BAD7A4700A2D0B0 /* Features */ = {
isa = PBXGroup;
children = (
701954212BC78E5000CD2ED3 /* Update */,
70CE4D2D2BB94C4300E1DEE2 /* KnowledgeBase */,
7078AB302BB510A1004B3819 /* Model */,
70E201792BAE825100CFE1D7 /* Chat */,
Expand Down Expand Up @@ -488,6 +510,7 @@
70A574AC2BB0894A008E3750 /* ActivityIndicatorView */,
703422102BB6A38C00332E04 /* OllamaKit */,
70B13D012BBAF27700A42F3C /* SVDB */,
7019541D2BC78DF100CD2ED3 /* Sparkle */,
);
productName = ModelCraft;
productReference = 70CE60642BAD2D4500A2D0B0 /* ModelCraft.app */;
Expand Down Expand Up @@ -570,6 +593,7 @@
70A574A62BB0716A008E3750 /* XCRemoteSwiftPackageReference "swift-collections" */,
70A574AB2BB0894A008E3750 /* XCRemoteSwiftPackageReference "ActivityIndicatorView" */,
70B13D002BBAF27700A42F3C /* XCRemoteSwiftPackageReference "SVDB" */,
7019541C2BC78DF100CD2ED3 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = 70CE60652BAD2D4500A2D0B0 /* Products */;
projectDirPath = "";
Expand All @@ -587,6 +611,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7019541A2BC7891C00CD2ED3 /* ollama in Resources */,
70CE60722BAD2D4600A2D0B0 /* Preview Assets.xcassets in Resources */,
70CE606E2BAD2D4600A2D0B0 /* Assets.xcassets in Resources */,
70A574AA2BB07264008E3750 /* Localizable.xcstrings in Resources */,
Expand Down Expand Up @@ -634,6 +659,7 @@
70E201872BAEC0C700CFE1D7 /* TextOutputFormat.swift in Sources */,
705483F62BBE96AF00256094 /* LocalModelsView.swift in Sources */,
70271B5E2BC1A97900E21A6E /* ModelStore.swift in Sources */,
701954202BC78E1800CD2ED3 /* CheckForUpdatesView.swift in Sources */,
70C22FC62BAECD10002754C7 /* VIew+.swift in Sources */,
70CE4D392BB9718900E1DEE2 /* FileManager+.swift in Sources */,
70CE60C62BAD61F600A2D0B0 /* UserDefaults+.swift in Sources */,
Expand Down Expand Up @@ -829,7 +855,7 @@
CODE_SIGN_ENTITLEMENTS = ModelCraft/ModelCraft.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"ModelCraft/Preview Content\"";
DEVELOPMENT_TEAM = DTZV6LDYD5;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -854,7 +880,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.zhanghongshen.ModelCraft;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand All @@ -874,7 +900,7 @@
CODE_SIGN_ENTITLEMENTS = ModelCraft/ModelCraft.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"ModelCraft/Preview Content\"";
DEVELOPMENT_TEAM = DTZV6LDYD5;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -899,7 +925,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.zhanghongshen.ModelCraft;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down Expand Up @@ -1042,6 +1068,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
7019541C2BC78DF100CD2ED3 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.6.0;
};
};
70A574A62BB0716A008E3750 /* XCRemoteSwiftPackageReference "swift-collections" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-collections.git";
Expand Down Expand Up @@ -1101,6 +1135,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
7019541D2BC78DF100CD2ED3 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 7019541C2BC78DF100CD2ED3 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
703422102BB6A38C00332E04 /* OllamaKit */ = {
isa = XCSwiftPackageProductDependency;
productName = OllamaKit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "5b4e8b501ecf133576f9e303b5affd7c83502cb2d135473d1cc0fb4b04b0386b",
"originHash" : "787c9c7b4939384d7f2703dff4bbda06554c3b527273a5bcbc5f43f1543cb5fe",
"pins" : [
{
"identity" : "activityindicatorview",
Expand Down Expand Up @@ -37,6 +37,15 @@
"version" : "6.0.0"
}
},
{
"identity" : "sparkle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "0a4caaf7a81eea2cece651ef4b17331fa0634dff",
"version" : "2.6.0"
}
},
{
"identity" : "splash",
"kind" : "remoteSourceControl",
Expand Down
25 changes: 19 additions & 6 deletions ModelCraft/Components/ModelDownloadProgress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,34 @@ struct ModelDownloadProgress: View {
ProgressView().controlSize(.small)
case .running:
Button {
modelContext.delete(task)
try? modelContext.save()
deleteTask(task)
} label: {
Image(systemName: "xmark.circle.fill")
}.buttonStyle(.borderless)
case .stopped:
Button {
restartTask(task)
} label: {
Image(systemName: "play.fill")
}.buttonStyle(.borderless)
case .failed:
Button("Retry") {
modelContext.delete(task)
modelContext.insert(ModelTask(modelName: task.modelName, type: .download))
try? modelContext.save()
restartTask(task)
}
default: EmptyView()
}
}

}

func deleteTask(_ task: ModelTask) {
modelContext.delete(task)
try? modelContext.save()
}

func restartTask(_ task: ModelTask) {
modelContext.delete(task)
modelContext.insert(ModelTask(modelName: task.modelName, type: .download))
try? modelContext.save()
}
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ModelCraft/Features/Model/LocalModelsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct LocalModelsView: View {
sort: \ModelTask.createdAt,
order: .reverse)
private var deleteTasks: [ModelTask] = []
@Query(filter: ModelTask.predicateByType(.download),
@Query(filter: ModelTask.predicateUnCompletedDownloadTask(),
sort: \ModelTask.createdAt,
order: .reverse)
private var downloadTasks: [ModelTask] = []
Expand Down
6 changes: 6 additions & 0 deletions ModelCraft/Features/Settings/Models/ModelTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,10 @@ extension ModelTask {
let typeID = type.rawValue
return #Predicate<ModelTask> { $0.typeID == typeID }
}

static func predicateUnCompletedDownloadTask() -> Predicate<ModelTask> {
let typeID = TaskType.download.rawValue
let statusID = TaskStatus.completed.rawValue
return #Predicate<ModelTask> { $0.typeID == typeID && $0.statusID != statusID }
}
}
37 changes: 37 additions & 0 deletions ModelCraft/Features/Update/CheckForUpdatesView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// CheckForUpdatesView.swift
// ModelCraft
//
// Created by 张鸿燊 on 11/4/2024.
//

import SwiftUI
import Sparkle

// This view model class publishes when new updates can be checked by the user
final class CheckForUpdatesViewModel: ObservableObject {
@Published var canCheckForUpdates = false

init(updater: SPUUpdater) {
updater.publisher(for: \.canCheckForUpdates)
.assign(to: &$canCheckForUpdates)
}
}


struct CheckForUpdatesView: View {
@ObservedObject private var checkForUpdatesViewModel: CheckForUpdatesViewModel
private let updater: SPUUpdater

init(updater: SPUUpdater) {
self.updater = updater

// Create our view model for our CheckForUpdatesView
self.checkForUpdatesViewModel = CheckForUpdatesViewModel(updater: updater)
}

var body: some View {
Button("Check for Updates…", action: updater.checkForUpdates)
.disabled(!checkForUpdatesViewModel.canCheckForUpdates)
}
}
4 changes: 4 additions & 0 deletions ModelCraft/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
<dict>
<key>NSAppTransportSecurity</key>
<dict/>
<key>SUFeedURL</key>
<string>https://github.com/zhang-hongshen/ModelCraft/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>kd8PcpzZyUDjtIcES6rUPqz0HKWVl1LY34wvhF0iPw4</string>
</dict>
</plist>
3 changes: 3 additions & 0 deletions ModelCraft/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
}
}
}
},
"Check for Updates…" : {

},
"Choose a model to chat" : {
"extractionState" : "stale",
Expand Down
Loading

0 comments on commit 2586edb

Please sign in to comment.