Created
March 15, 2026 08:32
-
-
Save leptos-null/33b81ef3d3a2d4c13386165a2cc69efa to your computer and use it in GitHub Desktop.
Reverse engineered Swift interface for the ServerLanguageModel API in Apple's FoundationModels framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The following code is reverse engineered from Apple's FoundationModels framework | |
| // | |
| // Primarily reconstructed using information from: | |
| // `swift demangle < "$(xcrun --sdk macosx --show-sdk-path)"/System/Library/Frameworks/FoundationModels.framework/FoundationModels.tbd` | |
| // `ipsw swift-dump /System/Volumes/Preboot/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_arm64e /System/Library/Frameworks/FoundationModels.framework/Versions/A/FoundationModels --demangle` | |
| public struct ServerLanguageModel { | |
| public struct `Protocol`: Equatable { | |
| enum Kind { | |
| case openAI | |
| } | |
| let kind: Self.Kind | |
| public static var openAICompletions: Self | |
| } | |
| let model: String | |
| let url: URL | |
| let headers: [String: String] | |
| let `protocol`: Self.`Protocol` | |
| let authenticator: Authenticator? | |
| let supportsGuidedGeneration: Bool | |
| public init(name: String, url: URL, headers: [String: String], protocol: Self.`Protocol`) | |
| } | |
| extension ServerLanguageModel { | |
| protocol Authenticator { | |
| // not sure what the requirements are | |
| } | |
| } | |
| extension LanguageModelSession { | |
| public init(model: ServerLanguageModel, tools: [any Tool], transcript: Transcript) | |
| public init(model: ServerLanguageModel, tools: [any Tool], instructions: Instructions?) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment