通过对话使 SwiftUI 应用更易访问且更强大

ConvoKit

目标:

利用对话功能提高 SwiftUI 应用的可访问性和功能性。

原因:

我爸爸患有帕金森症,这让他很难使用触摸屏,尤其是在他的颤抖恶化时。

我曾尝试开发基于计算机视觉的眼动追踪控制应用程序,但我们发现这些应用程序不太准确,希望 ConvoKit 能够提供帮助。

此外,ConvoKit 可以让每个人都更轻松地使用应用程序,尤其对患有智力障碍的人员。

理念:

使用 Whisper 转录口语自然语言请求,并利用微型 LLM 理解请求背后的上下文,以决定要调用哪个 swift 函数。

开发体验非常简单,只需向你希望向 LLM 公开其功能的类添加一个宏,并在你的 SwiftUI View 中初始化框架。

设置:

@Observable
// Exposes all public functions to ConvoKit
@ConvoAccessible
class ContentViewModel {
        
    var navigationPath = NavigationPath()
    
    public func navigateToHome() {
        navigationPath.append(ViewType.home)
    }
    // Public functions are exposed to ConvoKit
    public func printNumber(number: Int) {
        print(number)
    }
}

// Initializes a view model that can interpret natural language through voice and speak back if you have a backend endpoint
@StateObject var streamer = ConvoStreamer(baseThinkURL: "", baseSpeakURL: "", localWhisperURL:  Bundle.main.url(forResource: "ggml-tiny.en", withExtension: "bin")!)

func request(text: String) async {
    // A string that holds all options (the functions you marked as public)
    let options = #GetConvoState
    // LLM decides which function to call here
    if let function = await streamer.llmManager.chooseFunction(text: text, options: options) {
        callFunctionIfNeeded(functionName: function.functionName, args: function.args)
    }
}
    
func callFunctionIfNeeded(functionName: String, args: [String]) {
    // A macro that injects a bunch of if statements to handle the called function
    #ConvoConnector
}

基本输入 + 输出:

SwiftUIApps