From 21a33116948f55848fb603376cec19dd3a9fdac7 Mon Sep 17 00:00:00 2001 From: Purav Manot Date: Sat, 23 Nov 2024 04:17:47 +0530 Subject: [PATCH 1/3] Update package --- .../OllamaScraper/OllamaSite.swift | 107 ++++++++++++++++++ .../Sideproject/OllamaScraper/String++.swift | 15 +++ 2 files changed, 122 insertions(+) create mode 100644 Sources/Sideproject/OllamaScraper/OllamaSite.swift create mode 100644 Sources/Sideproject/OllamaScraper/String++.swift diff --git a/Sources/Sideproject/OllamaScraper/OllamaSite.swift b/Sources/Sideproject/OllamaScraper/OllamaSite.swift new file mode 100644 index 0000000..148a900 --- /dev/null +++ b/Sources/Sideproject/OllamaScraper/OllamaSite.swift @@ -0,0 +1,107 @@ +// +// File.swift +// Sideproject +// +// Created by Purav Manot on 22/11/24. +// + +import Foundation +import SwiftSoup + +// TODO: - Come up with a better name +public enum OllamaSite { + public static let baseURL = URL(string: "https://registry.ollama.ai")! + public static let libraryURL = baseURL.appending(path: "library") + + public static var endpoints: [String] { + get async throws { + let html = try await String(url: OllamaSite.libraryURL) + let libraryDocument = try SwiftSoup.parse(html, OllamaSite.baseURL.absoluteString) + + return try libraryDocument.select("#repo").array()[0].select("[href]").map { try $0.attr("href") } + } + } + +} + +public extension OllamaSite { + struct ModelFamily { + public let name: String + public let models: [Model] + + public var url: URL? { + URL(string: "https://registry.ollama.ai/library/\(name)") + } + + public init(name: String) async throws { + self.name = name + + let url = URL(string: "https://registry.ollama.ai/library/\(name)/tags")! + let html = try await String(url: url) + let document = try SwiftSoup.parse(html, OllamaSite.baseURL.absoluteString) + + self.models = try await withThrowingTaskGroup(of: OllamaSite.Model.self, returning: [OllamaSite.Model].self) { group in + try document.select("section").first()!.select("a").array().forEach { element in + group.addTask { + let name = try element.attr("href") + return try await Model(name: name) + } + } + + return try await group.collect() + } + } + } + + struct Model { + public let familyName: String + public let variantName: String + + public let systemPrompt: String + public let template: String + public let license: String + + public var name: String { [familyName, variantName].joined(separator: ":") } + + public var url: URL? { + URL(string: "https://registry.ollama.ai/library/\(name)") + } + + public init(name: String) async throws { + let components = name.components(separatedBy: ":") + + guard components.count == 2 else { throw Error.invalidModelName } + + self.familyName = components[0] + self.variantName = components[1] + + let html = try await String(url: OllamaSite.baseURL.appending(path: name)) + let document = try SwiftSoup.parse(html) + + let properties = try document.select("#file-explorer").first()!.select("[href]").array() + print(properties) + guard properties.count == 4 else { throw Error.unexpectedNumberOfElements(url: OllamaSite.baseURL.appending(path: name)) } + + _ = try properties[0].attr("href") + self.systemPrompt = try properties[1].attr("href") + self.template = try properties[2].attr("href") + self.license = try properties[3].attr("href") + + /* + withThrowingTaskGroup(of: Void.self) { group in + group.addTask { + + } + }*/ + } + } +} + +// MARK: - Error handling + +extension OllamaSite { + public enum Error: Swift.Error { + case invalidModelName + case unexpectedNumberOfElements(url: URL) + } +} diff --git a/Sources/Sideproject/OllamaScraper/String++.swift b/Sources/Sideproject/OllamaScraper/String++.swift new file mode 100644 index 0000000..69a21ec --- /dev/null +++ b/Sources/Sideproject/OllamaScraper/String++.swift @@ -0,0 +1,15 @@ +// +// File.swift +// Sideproject +// +// Created by Purav Manot on 22/11/24. +// + +import Foundation + +extension String { + public init(url: URL) async throws { + let (data, _) = try await URLSession.shared.data(from: url) + try self.init(data: data) + } +} From c89dbe160caa9795b100df5a764d5105694f6d09 Mon Sep 17 00:00:00 2001 From: Purav Manot Date: Sat, 23 Nov 2024 04:22:16 +0530 Subject: [PATCH 2/3] Add CLI tool --- .../project.pbxproj | 337 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/swiftpm/Package.resolved | 96 +++++ .../OllamaCommandLineScraper/main.swift | 32 ++ 4 files changed, 472 insertions(+) create mode 100644 Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.pbxproj create mode 100644 Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 Sources/OllamaCommandLineScraper/OllamaCommandLineScraper/main.swift diff --git a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.pbxproj b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b664da0 --- /dev/null +++ b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.pbxproj @@ -0,0 +1,337 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + 982567712CF0F98F009E4ABA /* Sideproject in Frameworks */ = {isa = PBXBuildFile; productRef = 982567702CF0F98F009E4ABA /* Sideproject */; }; + 98E5E0B62CEF65FE009487DA /* BrowserKit in Frameworks */ = {isa = PBXBuildFile; productRef = 98E5E0B52CEF65FE009487DA /* BrowserKit */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 98E5E0A82CEF65D0009487DA /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 98E5E0AA2CEF65D0009487DA /* OllamaCommandLineScraper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = OllamaCommandLineScraper; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 98E5E0AC2CEF65D0009487DA /* OllamaCommandLineScraper */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = OllamaCommandLineScraper; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 98E5E0A72CEF65D0009487DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 98E5E0B62CEF65FE009487DA /* BrowserKit in Frameworks */, + 982567712CF0F98F009E4ABA /* Sideproject in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9825676D2CF0F4CC009E4ABA /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; + 98E5E0A12CEF65D0009487DA = { + isa = PBXGroup; + children = ( + 98E5E0AC2CEF65D0009487DA /* OllamaCommandLineScraper */, + 9825676D2CF0F4CC009E4ABA /* Frameworks */, + 98E5E0AB2CEF65D0009487DA /* Products */, + ); + sourceTree = ""; + }; + 98E5E0AB2CEF65D0009487DA /* Products */ = { + isa = PBXGroup; + children = ( + 98E5E0AA2CEF65D0009487DA /* OllamaCommandLineScraper */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 98E5E0A92CEF65D0009487DA /* OllamaCommandLineScraper */ = { + isa = PBXNativeTarget; + buildConfigurationList = 98E5E0B12CEF65D0009487DA /* Build configuration list for PBXNativeTarget "OllamaCommandLineScraper" */; + buildPhases = ( + 98E5E0A62CEF65D0009487DA /* Sources */, + 98E5E0A72CEF65D0009487DA /* Frameworks */, + 98E5E0A82CEF65D0009487DA /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 98E5E0AC2CEF65D0009487DA /* OllamaCommandLineScraper */, + ); + name = OllamaCommandLineScraper; + packageProductDependencies = ( + 98E5E0B52CEF65FE009487DA /* BrowserKit */, + 982567702CF0F98F009E4ABA /* Sideproject */, + ); + productName = OllamaCommandLineScraper; + productReference = 98E5E0AA2CEF65D0009487DA /* OllamaCommandLineScraper */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 98E5E0A22CEF65D0009487DA /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1610; + LastUpgradeCheck = 1610; + TargetAttributes = { + 98E5E0A92CEF65D0009487DA = { + CreatedOnToolsVersion = 16.1; + }; + }; + }; + buildConfigurationList = 98E5E0A52CEF65D0009487DA /* Build configuration list for PBXProject "OllamaCommandLineScraper" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 98E5E0A12CEF65D0009487DA; + minimizedProjectReferenceProxies = 1; + packageReferences = ( + 98E5E0B42CEF65FE009487DA /* XCRemoteSwiftPackageReference "BrowserKit" */, + ); + preferredProjectObjectVersion = 77; + productRefGroup = 98E5E0AB2CEF65D0009487DA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 98E5E0A92CEF65D0009487DA /* OllamaCommandLineScraper */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 98E5E0A62CEF65D0009487DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 98E5E0AF2CEF65D0009487DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 15.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 98E5E0B02CEF65D0009487DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 15.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + 98E5E0B22CEF65D0009487DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9GMDZT68HT; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 98E5E0B32CEF65D0009487DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9GMDZT68HT; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 98E5E0A52CEF65D0009487DA /* Build configuration list for PBXProject "OllamaCommandLineScraper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 98E5E0AF2CEF65D0009487DA /* Debug */, + 98E5E0B02CEF65D0009487DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 98E5E0B12CEF65D0009487DA /* Build configuration list for PBXNativeTarget "OllamaCommandLineScraper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 98E5E0B22CEF65D0009487DA /* Debug */, + 98E5E0B32CEF65D0009487DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 98E5E0B42CEF65FE009487DA /* XCRemoteSwiftPackageReference "BrowserKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/vmanot/BrowserKit"; + requirement = { + branch = main; + kind = branch; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 982567702CF0F98F009E4ABA /* Sideproject */ = { + isa = XCSwiftPackageProductDependency; + productName = Sideproject; + }; + 98E5E0B52CEF65FE009487DA /* BrowserKit */ = { + isa = XCSwiftPackageProductDependency; + package = 98E5E0B42CEF65FE009487DA /* XCRemoteSwiftPackageReference "BrowserKit" */; + productName = BrowserKit; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 98E5E0A22CEF65D0009487DA /* Project object */; +} diff --git a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..14a4da3 --- /dev/null +++ b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,96 @@ +{ + "originHash" : "9e7e4e5f73426851b8f150a0a88a1a1a51b31706f143e531055987f8dabea8f8", + "pins" : [ + { + "identity" : "browserkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vmanot/BrowserKit", + "state" : { + "branch" : "main", + "revision" : "2d20df8329f18f972fa486c936b617e15d1b4f57" + } + }, + { + "identity" : "corepersistence", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vmanot/CorePersistence.git", + "state" : { + "branch" : "main", + "revision" : "76191333e43123b0c8417094fecbb0d2a522a59a" + } + }, + { + "identity" : "merge", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vmanot/Merge.git", + "state" : { + "branch" : "master", + "revision" : "860e67569be17b3af64008d09e5ef06fd2256e4e" + } + }, + { + "identity" : "networkkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vmanot/NetworkKit.git", + "state" : { + "branch" : "master", + "revision" : "8daa1ba22e5d18e1b8e469d5a0dd0c58b675eb87" + } + }, + { + "identity" : "swallow", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vmanot/Swallow.git", + "state" : { + "branch" : "master", + "revision" : "77ba4912b07d6be4ed76262b4cb6fb5426e171c0" + } + }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections", + "state" : { + "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7", + "version" : "1.1.4" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-syntax.git", + "state" : { + "revision" : "0687f71944021d616d34d922343dcef086855920", + "version" : "600.0.1" + } + }, + { + "identity" : "swiftapi", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vmanot/SwiftAPI.git", + "state" : { + "branch" : "master", + "revision" : "3e47cc5f9b0cefe9ed1d0971aff22583bd9ac7b0" + } + }, + { + "identity" : "swiftsoup", + "kind" : "remoteSourceControl", + "location" : "https://github.com/scinfu/SwiftSoup.git", + "state" : { + "revision" : "0e96a20ffd37a515c5c963952d4335c89bed50a6", + "version" : "2.6.0" + } + }, + { + "identity" : "swiftuix", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SwiftUIX/SwiftUIX.git", + "state" : { + "branch" : "master", + "revision" : "db0412aa1ef59ddff357432bf2e416e38a34cdb2" + } + } + ], + "version" : 3 +} diff --git a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper/main.swift b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper/main.swift new file mode 100644 index 0000000..d4d2924 --- /dev/null +++ b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper/main.swift @@ -0,0 +1,32 @@ +// +// main.swift +// OllamaCommandLineScraper +// +// Created by Purav Manot on 21/11/24. +// + +import Foundation +import SwiftSoup +import Sideproject +import BrowserKit + + + +let names = try await OllamaSite.endpoints.map { String($0.split(separator: "/").last!) } +let tagURLs = names.map { URL(string: "https://registry.ollama.ai/library/\($0)/tags") } +print(names) + +do { + try await withThrowingTaskGroup(of: Void.self) { group in + for name in names.prefix(4) { + group.addTask { + let family = try await OllamaSite.ModelFamily(name: name) + print(family.models) + } + } + + try await group.waitForAll() + } +} catch { + print(error) +} From 0c5f5c5fb3cc93a8bf3a921b61674b722e2a3eda Mon Sep 17 00:00:00 2001 From: Purav Manot Date: Tue, 26 Nov 2024 21:08:55 +0530 Subject: [PATCH 3/3] Remove CLI tool --- .../project.pbxproj | 337 ------------------ .../contents.xcworkspacedata | 7 - .../xcshareddata/swiftpm/Package.resolved | 96 ----- .../OllamaCommandLineScraper/main.swift | 32 -- 4 files changed, 472 deletions(-) delete mode 100644 Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.pbxproj delete mode 100644 Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved delete mode 100644 Sources/OllamaCommandLineScraper/OllamaCommandLineScraper/main.swift diff --git a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.pbxproj b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.pbxproj deleted file mode 100644 index b664da0..0000000 --- a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.pbxproj +++ /dev/null @@ -1,337 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 77; - objects = { - -/* Begin PBXBuildFile section */ - 982567712CF0F98F009E4ABA /* Sideproject in Frameworks */ = {isa = PBXBuildFile; productRef = 982567702CF0F98F009E4ABA /* Sideproject */; }; - 98E5E0B62CEF65FE009487DA /* BrowserKit in Frameworks */ = {isa = PBXBuildFile; productRef = 98E5E0B52CEF65FE009487DA /* BrowserKit */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 98E5E0A82CEF65D0009487DA /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 98E5E0AA2CEF65D0009487DA /* OllamaCommandLineScraper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = OllamaCommandLineScraper; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFileSystemSynchronizedRootGroup section */ - 98E5E0AC2CEF65D0009487DA /* OllamaCommandLineScraper */ = { - isa = PBXFileSystemSynchronizedRootGroup; - path = OllamaCommandLineScraper; - sourceTree = ""; - }; -/* End PBXFileSystemSynchronizedRootGroup section */ - -/* Begin PBXFrameworksBuildPhase section */ - 98E5E0A72CEF65D0009487DA /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 98E5E0B62CEF65FE009487DA /* BrowserKit in Frameworks */, - 982567712CF0F98F009E4ABA /* Sideproject in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 9825676D2CF0F4CC009E4ABA /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; - 98E5E0A12CEF65D0009487DA = { - isa = PBXGroup; - children = ( - 98E5E0AC2CEF65D0009487DA /* OllamaCommandLineScraper */, - 9825676D2CF0F4CC009E4ABA /* Frameworks */, - 98E5E0AB2CEF65D0009487DA /* Products */, - ); - sourceTree = ""; - }; - 98E5E0AB2CEF65D0009487DA /* Products */ = { - isa = PBXGroup; - children = ( - 98E5E0AA2CEF65D0009487DA /* OllamaCommandLineScraper */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 98E5E0A92CEF65D0009487DA /* OllamaCommandLineScraper */ = { - isa = PBXNativeTarget; - buildConfigurationList = 98E5E0B12CEF65D0009487DA /* Build configuration list for PBXNativeTarget "OllamaCommandLineScraper" */; - buildPhases = ( - 98E5E0A62CEF65D0009487DA /* Sources */, - 98E5E0A72CEF65D0009487DA /* Frameworks */, - 98E5E0A82CEF65D0009487DA /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - fileSystemSynchronizedGroups = ( - 98E5E0AC2CEF65D0009487DA /* OllamaCommandLineScraper */, - ); - name = OllamaCommandLineScraper; - packageProductDependencies = ( - 98E5E0B52CEF65FE009487DA /* BrowserKit */, - 982567702CF0F98F009E4ABA /* Sideproject */, - ); - productName = OllamaCommandLineScraper; - productReference = 98E5E0AA2CEF65D0009487DA /* OllamaCommandLineScraper */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 98E5E0A22CEF65D0009487DA /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1610; - LastUpgradeCheck = 1610; - TargetAttributes = { - 98E5E0A92CEF65D0009487DA = { - CreatedOnToolsVersion = 16.1; - }; - }; - }; - buildConfigurationList = 98E5E0A52CEF65D0009487DA /* Build configuration list for PBXProject "OllamaCommandLineScraper" */; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 98E5E0A12CEF65D0009487DA; - minimizedProjectReferenceProxies = 1; - packageReferences = ( - 98E5E0B42CEF65FE009487DA /* XCRemoteSwiftPackageReference "BrowserKit" */, - ); - preferredProjectObjectVersion = 77; - productRefGroup = 98E5E0AB2CEF65D0009487DA /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 98E5E0A92CEF65D0009487DA /* OllamaCommandLineScraper */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 98E5E0A62CEF65D0009487DA /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 98E5E0AF2CEF65D0009487DA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 15.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 98E5E0B02CEF65D0009487DA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 15.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - }; - name = Release; - }; - 98E5E0B22CEF65D0009487DA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 9GMDZT68HT; - ENABLE_HARDENED_RUNTIME = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 98E5E0B32CEF65D0009487DA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 9GMDZT68HT; - ENABLE_HARDENED_RUNTIME = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 98E5E0A52CEF65D0009487DA /* Build configuration list for PBXProject "OllamaCommandLineScraper" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 98E5E0AF2CEF65D0009487DA /* Debug */, - 98E5E0B02CEF65D0009487DA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 98E5E0B12CEF65D0009487DA /* Build configuration list for PBXNativeTarget "OllamaCommandLineScraper" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 98E5E0B22CEF65D0009487DA /* Debug */, - 98E5E0B32CEF65D0009487DA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCRemoteSwiftPackageReference section */ - 98E5E0B42CEF65FE009487DA /* XCRemoteSwiftPackageReference "BrowserKit" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/vmanot/BrowserKit"; - requirement = { - branch = main; - kind = branch; - }; - }; -/* End XCRemoteSwiftPackageReference section */ - -/* Begin XCSwiftPackageProductDependency section */ - 982567702CF0F98F009E4ABA /* Sideproject */ = { - isa = XCSwiftPackageProductDependency; - productName = Sideproject; - }; - 98E5E0B52CEF65FE009487DA /* BrowserKit */ = { - isa = XCSwiftPackageProductDependency; - package = 98E5E0B42CEF65FE009487DA /* XCRemoteSwiftPackageReference "BrowserKit" */; - productName = BrowserKit; - }; -/* End XCSwiftPackageProductDependency section */ - }; - rootObject = 98E5E0A22CEF65D0009487DA /* Project object */; -} diff --git a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 14a4da3..0000000 --- a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,96 +0,0 @@ -{ - "originHash" : "9e7e4e5f73426851b8f150a0a88a1a1a51b31706f143e531055987f8dabea8f8", - "pins" : [ - { - "identity" : "browserkit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vmanot/BrowserKit", - "state" : { - "branch" : "main", - "revision" : "2d20df8329f18f972fa486c936b617e15d1b4f57" - } - }, - { - "identity" : "corepersistence", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vmanot/CorePersistence.git", - "state" : { - "branch" : "main", - "revision" : "76191333e43123b0c8417094fecbb0d2a522a59a" - } - }, - { - "identity" : "merge", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vmanot/Merge.git", - "state" : { - "branch" : "master", - "revision" : "860e67569be17b3af64008d09e5ef06fd2256e4e" - } - }, - { - "identity" : "networkkit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vmanot/NetworkKit.git", - "state" : { - "branch" : "master", - "revision" : "8daa1ba22e5d18e1b8e469d5a0dd0c58b675eb87" - } - }, - { - "identity" : "swallow", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vmanot/Swallow.git", - "state" : { - "branch" : "master", - "revision" : "77ba4912b07d6be4ed76262b4cb6fb5426e171c0" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections", - "state" : { - "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7", - "version" : "1.1.4" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "0687f71944021d616d34d922343dcef086855920", - "version" : "600.0.1" - } - }, - { - "identity" : "swiftapi", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vmanot/SwiftAPI.git", - "state" : { - "branch" : "master", - "revision" : "3e47cc5f9b0cefe9ed1d0971aff22583bd9ac7b0" - } - }, - { - "identity" : "swiftsoup", - "kind" : "remoteSourceControl", - "location" : "https://github.com/scinfu/SwiftSoup.git", - "state" : { - "revision" : "0e96a20ffd37a515c5c963952d4335c89bed50a6", - "version" : "2.6.0" - } - }, - { - "identity" : "swiftuix", - "kind" : "remoteSourceControl", - "location" : "https://github.com/SwiftUIX/SwiftUIX.git", - "state" : { - "branch" : "master", - "revision" : "db0412aa1ef59ddff357432bf2e416e38a34cdb2" - } - } - ], - "version" : 3 -} diff --git a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper/main.swift b/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper/main.swift deleted file mode 100644 index d4d2924..0000000 --- a/Sources/OllamaCommandLineScraper/OllamaCommandLineScraper/main.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// main.swift -// OllamaCommandLineScraper -// -// Created by Purav Manot on 21/11/24. -// - -import Foundation -import SwiftSoup -import Sideproject -import BrowserKit - - - -let names = try await OllamaSite.endpoints.map { String($0.split(separator: "/").last!) } -let tagURLs = names.map { URL(string: "https://registry.ollama.ai/library/\($0)/tags") } -print(names) - -do { - try await withThrowingTaskGroup(of: Void.self) { group in - for name in names.prefix(4) { - group.addTask { - let family = try await OllamaSite.ModelFamily(name: name) - print(family.models) - } - } - - try await group.waitForAll() - } -} catch { - print(error) -}