Browse Source

上传代码

weicu
liwei1dao 1 year ago
parent
commit
243647f501
  1. 9
      local_plugins/chat_api/android/src/main/kotlin/com/yunqiinnovation/chat_api/ChatApiService.kt
  2. 4
      local_plugins/chat_api/ios/chat_api/Sources/chat_api/ChatApiService.swift

9
local_plugins/chat_api/android/src/main/kotlin/com/yunqiinnovation/chat_api/ChatApiService.kt

@ -628,6 +628,7 @@ class ChatApiService(private val context: android.content.Context? = null) : Cor
mapOf("context" to "Tool not found: $functionName")
}
if (sessionid == currSessionId) {
if (functionName != "set_user_profile_field"){
// 处理结果
try {
if(!isError){
@ -642,7 +643,6 @@ class ChatApiService(private val context: android.content.Context? = null) : Cor
} catch (e: Exception) {
Log.e(TAG, "onFunctionCallResult回调异常: ${e.message}", e)
}
if (functionName != "set_user_profile_field"){
// 将结果发送回OpenAI继续对话
sendFunctionCallResultInternal(
sessionid= sessionid,
@ -650,6 +650,13 @@ class ChatApiService(private val context: android.content.Context? = null) : Cor
functionCall = functionCall,
functionResult = gson.toJson(result)
)
}else{
try {
getSessionCallback(sessionid)?.onComplete(sessionid)
} catch (ex: Exception) {
Log.e(TAG, "onComplete回调异常: ${ex.message}", ex)
}
clearCurrentSession()
}
}
}

4
local_plugins/chat_api/ios/chat_api/Sources/chat_api/ChatApiService.swift

@ -541,8 +541,10 @@ getSessionCallback(sessionId)?.onFunctionCall(sessionId, jsonFunctionCall)
functionCall: functionCall,
functionResult: self.jsonToString(result) ?? "{}"
)
}else{
self.getSessionCallback(sessionId)?.onComplete(sessionId)
self.clearCurrentSession()
}
}
}
} catch {

Loading…
Cancel
Save