Skip to content

Commit ebe35a0

Browse files
shenenqingszl97
authored andcommitted
feat: retrieve file url
1 parent 549ed6e commit ebe35a0

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.theokanning.openai.file;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
6+
/**
7+
* A file URL response from OpenAI
8+
*/
9+
@Data
10+
public class FileUrl {
11+
12+
/**
13+
* The URL to access the file.
14+
*/
15+
String url;
16+
17+
/**
18+
* The expiration time of the URL in epoch seconds.
19+
*/
20+
@JsonProperty("expires_at")
21+
Long expiresAt;
22+
}

client/src/main/java/com/theokanning/openai/client/OpenAiApi.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.theokanning.openai.embedding.EmbeddingRequest;
3434
import com.theokanning.openai.embedding.EmbeddingResult;
3535
import com.theokanning.openai.file.File;
36+
import com.theokanning.openai.file.FileUrl;
3637
import com.theokanning.openai.fine_tuning.FineTuningEvent;
3738
import com.theokanning.openai.fine_tuning.FineTuningJob;
3839
import com.theokanning.openai.fine_tuning.FineTuningJobCheckpoint;
@@ -114,6 +115,9 @@ public interface OpenAiApi {
114115
@GET("files/{file_id}/dom-tree/content")
115116
Single<ResponseBody> retrieveDomTreeContent(@Path("file_id") String fileId);
116117

118+
@GET("files/{file_id}/url")
119+
Single<FileUrl> retrieveFileUrl(@Path("file_id") String fileId);
120+
117121
@POST("fine_tuning/jobs")
118122
Single<FineTuningJob> createFineTuningJob(@Body FineTuningJobRequest request);
119123

service/src/main/java/com/theokanning/openai/service/OpenAiService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import com.theokanning.openai.embedding.EmbeddingRequest;
6060
import com.theokanning.openai.embedding.EmbeddingResult;
6161
import com.theokanning.openai.file.File;
62+
import com.theokanning.openai.file.FileUrl;
6263
import com.theokanning.openai.fine_tuning.FineTuningEvent;
6364
import com.theokanning.openai.fine_tuning.FineTuningJob;
6465
import com.theokanning.openai.fine_tuning.FineTuningJobCheckpoint;
@@ -301,6 +302,10 @@ public ResponseBody retrieveDomTreeContent(String fileId) {
301302
return execute(api.retrieveDomTreeContent(fileId));
302303
}
303304

305+
public FileUrl retrieveFileUrl(String fileId) {
306+
return execute(api.retrieveFileUrl(fileId));
307+
}
308+
304309
public FineTuningJob createFineTuningJob(FineTuningJobRequest request) {
305310
return execute(api.createFineTuningJob(request));
306311
}

0 commit comments

Comments
 (0)