requestLLM method
请求LLM
方法成功调用后,房间内的成员可以接收到来自LLM的响应。
调用时机
请在引擎初始化之后,且在加入房间后调用。
参数说明
request - 包含 dstUid 和 params 的请求对象
- dstUid: AI在会中的uid,默认可以写0,sdk会自动查找
- params: LLM请求参数
返回值
返回 Future
- taskId: 任务ID
- code: 错误码,0表示成功
- errorMsg: 错误信息
Implementation
Future<NERtcLLMRequestResult> requestLLM(
RequestLLMRequest arg_request) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.nertc_core_platform_interface.EngineApi.requestLLM',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_request]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as NERtcLLMRequestResult?)!;
}
}