You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicstaticvoidmain(String[] args) {
// Get an access_token through personal access token or oauth.Stringtoken = "xxx";
StringbotID = "123";
StringuserID = "asd";
TokenAuthauthCli = newTokenAuth(token);
// Init the Coze client through the access_token.CozeAPIcoze = newCozeAPI.Builder()
.baseURL("https://www.coze.cn/")
.auth(authCli)
.readTimeout(10000)
.build();
// Call the upload file interface to get the image id.StringimagePath = "D:\\test.jpeg";
FileInfoimageInfo = coze.files().upload(UploadFileReq.of(imagePath)).getFileInfo();
/* * Step one, create chat * Call the coze.chat().stream() method to create a chat. The create method is a streaming * chat and will return a Flowable ChatEvent. Developers should iterate the iterator to get * chat event and handle them. * */CreateChatReqreq =
CreateChatReq.builder()
.botID(botID)
.userID(userID)
.messages(
Collections.singletonList(
Message.buildUserQuestionObjects(
Arrays.asList(
MessageObjectString.buildText("Describe this picture"),
MessageObjectString.buildImageByID(imageInfo.getID())))))
.build();
Flowable<ChatEvent> resp = coze.chat().stream(req);
resp.blockingForEach(
event -> {
if (ChatEventType.CONVERSATION_MESSAGE_DELTA.equals(event.getEvent())) {
System.out.print(event.getMessage().getContent());
}
});
}
Exception in thread "main" java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 2]
at com.coze.openapi.service.utils.Utils.execute(Utils.java:44)
at com.coze.openapi.service.service.file.FileService.uploadFile(FileService.java:61)
at com.coze.openapi.service.service.file.FileService.upload(FileService.java:39)
at Chat.main(Chat.java:42)
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2418)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:749)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:673)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:2082)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:805)
at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:357)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2095)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1513)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:33)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:204)
at com.coze.openapi.service.service.APIResponseCallAdapter$1.execute(APIResponseCallAdapter.java:35)
at com.coze.openapi.service.utils.Utils.execute(Utils.java:22)
... 3 more
The text was updated successfully, but these errors were encountered:
示例代码example/src/main/java/example/chat/ChatWithImageExample.java
pom
错误提示
The text was updated successfully, but these errors were encountered: