|
4 | 4 | import com.fasterxml.jackson.core.JsonToken; |
5 | 5 | import com.fasterxml.jackson.databind.DeserializationContext; |
6 | 6 | import com.fasterxml.jackson.databind.JsonDeserializer; |
| 7 | +import com.theokanning.openai.assistants.message.content.AudioURL; |
7 | 8 | import com.theokanning.openai.assistants.message.content.ImageFile; |
8 | 9 |
|
9 | 10 | import java.io.IOException; |
@@ -51,6 +52,8 @@ MultiMediaContent parseContent(JsonParser jsonParser) throws IOException { |
51 | 52 | content.setImageFile(parseImageFile(jsonParser)); |
52 | 53 | } else if ("input_audio".equals(fieldName)) { |
53 | 54 | content.setInputAudio(parseInputAudio(jsonParser)); |
| 55 | + } else if ("audio_url".equals(fieldName)) { |
| 56 | + content.setAudioUrl(parseAudioUrl(jsonParser)); |
54 | 57 | } |
55 | 58 | } |
56 | 59 | return content; |
@@ -100,4 +103,19 @@ private InputAudio parseInputAudio(JsonParser jsonParser) throws IOException { |
100 | 103 | } |
101 | 104 | return new InputAudio(data, format); |
102 | 105 | } |
| 106 | + |
| 107 | + private AudioURL parseAudioUrl(JsonParser jsonParser) throws IOException { |
| 108 | + String url = null; |
| 109 | + String audioTranscript = null; |
| 110 | + while (jsonParser.nextToken() != JsonToken.END_OBJECT) { |
| 111 | + String fieldName = jsonParser.getCurrentName(); |
| 112 | + jsonParser.nextToken(); |
| 113 | + if ("url".equals(fieldName)) { |
| 114 | + url = jsonParser.getText(); |
| 115 | + } else if ("audio_transcript".equals(fieldName)) { |
| 116 | + audioTranscript = jsonParser.getText(); |
| 117 | + } |
| 118 | + } |
| 119 | + return new AudioURL(url, audioTranscript); |
| 120 | + } |
103 | 121 | } |
0 commit comments