fix(llm): 处理 OpenAI 错误响应
- 在 ModelService 中添加对 OpenAI错误响应的处理逻辑 - 当响应数据包含 "object" 和 "message" 字段,且 "object" 值为 "error" 时,抛出运行时异常 - 优化了错误处理机制,提高了系统的稳定性和可靠性
This commit is contained in:
parent
23bab6a228
commit
9a31e48b0a
@ -290,6 +290,9 @@ public class ModelService {
|
||||
String jsonData = line.substring(line.indexOf("{"));
|
||||
JSONObject jsonObject = JSON.parseObject(jsonData);
|
||||
log.info("处理后数据: {}", jsonData);
|
||||
if (jsonObject.containsKey("object")&& jsonObject.containsKey("message")&& jsonObject.getString("object").equals("error")){
|
||||
emitter.completeWithError(new RuntimeException(jsonObject.getString("message")));
|
||||
}
|
||||
JSONObject content1 = jsonObject.getJSONArray("choices").getJSONObject(0);
|
||||
// 获取delta对象
|
||||
JSONObject delta = content1.getJSONObject("delta");
|
||||
|
Loading…
x
Reference in New Issue
Block a user