Skip to content

Commit bd3c204

Browse files
authored
Merge branch 'main' into 388-chat-completition-response-format
2 parents fdf57ad + 650d76b commit bd3c204

34 files changed

+899
-91
lines changed

api/src/main/java/com/theokanning/openai/assistants/ListAssistant.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

api/src/main/java/com/theokanning/openai/assistants/ListAssistantQueryRequest.java

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.theokanning.openai.common;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
/**
9+
* @description:
10+
* @author: vacuity
11+
* @create: 2023-11-16 22:27
12+
**/
13+
14+
15+
@Data
16+
@Builder
17+
@NoArgsConstructor
18+
@AllArgsConstructor
19+
public class LastError {
20+
21+
private String code;
22+
23+
private String message;
24+
}

api/src/main/java/com/theokanning/openai/messages/Message.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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.

api/src/main/java/com/theokanning/openai/messages/MessageContent.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package 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;
36
import 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
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

0 commit comments

Comments
 (0)