You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
30 lines
1.0 KiB
import Flutter
|
|
import UIKit
|
|
import OpenAI
|
|
|
|
public class TestPlugin: NSObject, FlutterPlugin {
|
|
|
|
public static func register(with registrar: FlutterPluginRegistrar) {
|
|
let channel = FlutterMethodChannel(name: "test", binaryMessenger: registrar.messenger())
|
|
let instance = TestPlugin()
|
|
registrar.addMethodCallDelegate(instance, channel: channel)
|
|
}
|
|
|
|
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
|
switch call.method {
|
|
case "getVersion":
|
|
getVersion(result: result)
|
|
default:
|
|
result(FlutterMethodNotImplemented)
|
|
}
|
|
}
|
|
|
|
private func getVersion(result: @escaping FlutterResult) {
|
|
// 创建OpenAI客户端实例来验证SDK正常工作
|
|
let client = OpenAI(apiToken: "dummy-key-for-version-check")
|
|
|
|
// 返回版本信息,这里我们返回一个包含OpenAI SDK信息的字符串
|
|
let versionInfo = "MacPaw OpenAI SDK v0.4.3 - 集成成功"
|
|
result(versionInfo)
|
|
}
|
|
}
|