-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Description
代码:
public async IAsyncEnumerable<(ResultType resultType, string result)> SendMessageStream(ApiChatInput input)
{
Credential cred = new Credential {
SecretId = SecretId,
SecretKey = SecretKey
};
HunyuanClient _client = new HunyuanClient(cred, "ap-guangzhou");
var req = new ChatProRequest()
{
Messages = GetMsgBody(input)
};
var resp = await _client.ChatPro(req);
foreach (var sse in resp)
{
var o = JObject.Parse(sse.Data);
yield return (ResultType.Answer, o["Choices"][0]["Delta"]["Content"].Value());
}
}
在IAsyncEnumerable类型的方法内部不允许使用try catch,但如果这个请求过程中出现参数错误之类的它又会直接抛出异常,我如何获取到请求异常后的Message呢?比如地域不支持,或者余额不足之类的。
Metadata
Metadata
Assignees
Labels
No labels