This repository was archived by the owner on Jun 6, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
main/java/com/theokanning/openai
java/com/theokanning/openai
client/src/main/java/com/theokanning/openai/client
main/java/com/theokanning/openai/service
test/java/com/theokanning/openai/service Expand file tree Collapse file tree Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ public class Message {
5050 /**
5151 * The content of the message in an array of text and/or images.
5252 */
53- List <Object > content ;
53+ List <MessageContent > content ;
5454
5555 /**
5656 * If applicable, the ID of the assistant that authored this message.
Original file line number Diff line number Diff line change 11package com .theokanning .openai .messages ;
22
3+ import com .fasterxml .jackson .annotation .JsonProperty ;
4+ import com .theokanning .openai .messages .content .ImageFile ;
5+ import com .theokanning .openai .messages .content .Text ;
36import lombok .Data ;
47
58
@@ -15,5 +18,14 @@ public class MessageContent {
1518 */
1619 String type ;
1720
18- // todo handle different content types
21+ /**
22+ * Text content of the message. Only present if type == text
23+ */
24+ Text text ;
25+
26+ /**
27+ * The image content of a message. Only present if type == image_file
28+ */
29+ @ JsonProperty ("image_file" )
30+ ImageFile imageFile ;
1931}
Original file line number Diff line number Diff line change 1+ package com .theokanning .openai .messages .content ;
2+
3+ import com .fasterxml .jackson .annotation .JsonProperty ;
4+ import lombok .AllArgsConstructor ;
5+ import lombok .Data ;
6+ import lombok .NoArgsConstructor ;
7+
8+ /**
9+ * An annotation for a text Message
10+ * <p>
11+ * https://platform.openai.com/docs/api-reference/messages/object
12+ */
13+ @ Data
14+ @ NoArgsConstructor
15+ @ AllArgsConstructor
16+ public class Annotation {
17+ /**
18+ * The type of annotation, either file_citation or file_path
19+ */
20+ String type ;
21+
22+ /**
23+ * The text in the message content that needs to be replaced
24+ */
25+ String text ;
26+
27+ /**
28+ * File citation details, only present when type == file_citation
29+ */
30+ @ JsonProperty ("file_citation" )
31+ FileCitation fileCitation ;
32+
33+ /**
34+ * File path details, only present when type == file_path
35+ */
36+ @ JsonProperty ("file_path" )
37+ FilePath filePath ;
38+
39+ @ JsonProperty ("start_index" )
40+ int startIndex ;
41+
42+ @ JsonProperty ("end_index" )
43+ int endIndex ;
44+ }
Original file line number Diff line number Diff line change 1+ package com .theokanning .openai .messages .content ;
2+
3+ import com .fasterxml .jackson .annotation .JsonProperty ;
4+ import lombok .AllArgsConstructor ;
5+ import lombok .Data ;
6+ import lombok .NoArgsConstructor ;
7+
8+ /**
9+ * A citation within the message that points to a specific quote from a specific File associated with the
10+ * assistant or the message. Generated when the assistant uses the "retrieval" tool to search files.
11+ * <p>
12+ * https://platform.openai.com/docs/api-reference/messages/object
13+ */
14+ @ Data
15+ @ NoArgsConstructor
16+ @ AllArgsConstructor
17+ public class FileCitation {
18+
19+ /**
20+ * The ID of the specific File the citation is from.
21+ */
22+ @ JsonProperty ("file_id" )
23+ String fileId ;
24+
25+ /**
26+ * The specific quote in the file.
27+ */
28+ String quote ;
29+ }
Original file line number Diff line number Diff line change 1+ package com .theokanning .openai .messages .content ;
2+
3+ import com .fasterxml .jackson .annotation .JsonProperty ;
4+ import lombok .AllArgsConstructor ;
5+ import lombok .Data ;
6+ import lombok .NoArgsConstructor ;
7+
8+ /**
9+ * A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file.
10+ * <p>
11+ * https://platform.openai.com/docs/api-reference/messages/object
12+ */
13+ @ Data
14+ @ NoArgsConstructor
15+ @ AllArgsConstructor
16+ public class FilePath {
17+
18+ /**
19+ * The ID of the file that was generated
20+ */
21+ @ JsonProperty ("file_id" )
22+ String fileId ;
23+ }
Original file line number Diff line number Diff line change 1+ package com .theokanning .openai .messages .content ;
2+
3+ import com .fasterxml .jackson .annotation .JsonProperty ;
4+ import lombok .AllArgsConstructor ;
5+ import lombok .Data ;
6+ import lombok .NoArgsConstructor ;
7+
8+ /**
9+ * References an image File int eh content of a message.
10+ * <p>
11+ * /https://platform.openai.com/docs/api-reference/messages/object
12+ */
13+ @ Data
14+ @ NoArgsConstructor
15+ @ AllArgsConstructor
16+ public class ImageFile {
17+
18+ /**
19+ * The File ID of the image in the message content.
20+ */
21+ @ JsonProperty ("file_id" )
22+ String fileId ;
23+ }
Original file line number Diff line number Diff line change 1+ package com .theokanning .openai .messages .content ;
2+
3+ import lombok .AllArgsConstructor ;
4+ import lombok .Data ;
5+ import lombok .NoArgsConstructor ;
6+
7+ import java .util .List ;
8+
9+ /**
10+ * The text content that is part of a message
11+ * <p>
12+ * https://platform.openai.com/docs/api-reference/messages/object
13+ */
14+ @ Data
15+ @ NoArgsConstructor
16+ @ AllArgsConstructor
17+ public class Text {
18+
19+ /**
20+ * The data that makes up the text.
21+ */
22+ String value ;
23+
24+ /**
25+ * Text annotations that show additional details
26+ */
27+ List <Annotation > annotations ;
28+ }
Original file line number Diff line number Diff line change 1818import com .theokanning .openai .finetune .FineTuneEvent ;
1919import com .theokanning .openai .finetune .FineTuneResult ;
2020import com .theokanning .openai .image .ImageResult ;
21+ import com .theokanning .openai .messages .Message ;
2122import com .theokanning .openai .model .Model ;
2223import com .theokanning .openai .moderation .ModerationRequest ;
2324import com .theokanning .openai .moderation .ModerationResult ;
@@ -50,6 +51,7 @@ public class JsonTest {
5051 ImageResult .class ,
5152 TranscriptionResult .class ,
5253 TranslationResult .class ,
54+ Message .class ,
5355 Model .class ,
5456 ModerationRequest .class ,
5557 ModerationResult .class
You can’t perform that action at this time.
0 commit comments