|
|
@ -22,6 +22,7 @@ import kotlinx.coroutines.CoroutineScope |
|
|
import kotlinx.coroutines.Dispatchers |
|
|
import kotlinx.coroutines.Dispatchers |
|
|
import kotlinx.coroutines.launch |
|
|
import kotlinx.coroutines.launch |
|
|
import kotlinx.coroutines.withContext |
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
|
import kotlinx.serialization.json.JsonObject |
|
|
import kotlin.math.min |
|
|
import kotlin.math.min |
|
|
|
|
|
|
|
|
/** OpenAIServicePlugin */ |
|
|
/** OpenAIServicePlugin */ |
|
|
@ -168,25 +169,17 @@ class OpenAIServicePlugin : FlutterPlugin, MethodCallHandler, StreamHandler { |
|
|
Log.e("OpenAIServicePlugin", "context:${functionCall.toString()}") |
|
|
Log.e("OpenAIServicePlugin", "context:${functionCall.toString()}") |
|
|
val context = functionCall["context"] |
|
|
val context = functionCall["context"] |
|
|
if (functionCall.has("meta")) { |
|
|
if (functionCall.has("meta")) { |
|
|
Log.e("OpenAIServicePlugin", |
|
|
val meta = functionCall.get("meta") |
|
|
""" |
|
|
val metaJsonObject:JsonObject = meta as JsonObject |
|
|
工具调用结果 meta 类型: ${functionCall["meta"]?.javaClass?.canonicalName} |
|
|
|
|
|
值内容: ${functionCall["meta"]} |
|
|
|
|
|
""".trimIndent() |
|
|
|
|
|
) |
|
|
|
|
|
val meta = functionCall["meta"].toString() |
|
|
|
|
|
// val meta = mapOf<String, Any>( |
|
|
|
|
|
// "card_spotify" to mapOf<String, Any>( |
|
|
|
|
|
// "name" to "泡沫", |
|
|
|
|
|
// "image" to "https://i.scdn.co/image/ab67616d0000b2739f6a38e4bb9c2f824c215e58", |
|
|
|
|
|
// "url" to "spotify:track:2IfSPLPDW6RGosdB5huwAA", |
|
|
|
|
|
// "sgener" to "Xposed", |
|
|
|
|
|
// ) |
|
|
|
|
|
// ) |
|
|
|
|
|
Log.e("OpenAIServicePlugin", "工具调用结果 context:${context} meta:${meta.toString()}") |
|
|
Log.e("OpenAIServicePlugin", "工具调用结果 context:${context} meta:${meta.toString()}") |
|
|
// 发送函数调用事件 |
|
|
// 发送函数调用事件 |
|
|
mainHandler.post { |
|
|
mainHandler.post { |
|
|
eventSink?.success(mapOf("type" to "functionCall", "content" to context,"meta" to meta)) |
|
|
eventSink?.success(mapOf("type" to "functionCall", "content" to context,"meta" to meta.toString())) |
|
|
|
|
|
} |
|
|
|
|
|
if (metaJsonObject.containsKey("card_spotify")) { |
|
|
|
|
|
mainHandler.post { |
|
|
|
|
|
eventSink?.success(mapOf("type" to "complete")) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|