Skip to content

Commit

Permalink
Merge pull request #27 from sashirestela/26-use-header-annotations-at…
Browse files Browse the repository at this point in the history
…-interface-level

Use header annotations at interface level
  • Loading branch information
sashirestela authored Dec 13, 2023
2 parents a495073 + dd56055 commit 6237aa7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.sashirestela</groupId>
<artifactId>simple-openai</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
<packaging>jar</packaging>

<name>simple-openai</name>
Expand Down Expand Up @@ -52,7 +52,7 @@
<maven.compiler.release>11</maven.compiler.release>
<!-- Dependencies Versions -->
<slf4j.version>[2.0.9,3.0.0)</slf4j.version>
<cleverclient.version>0.10.0</cleverclient.version>
<cleverclient.version>0.11.1</cleverclient.version>
<lombok.version>[1.18.30,2.0.0)</lombok.version>
<jackson.version>[2.15.2,3.0.0)</jackson.version>
<json.schema.version>[4.31.1,5.0.0)</json.schema.version>
Expand Down
31 changes: 2 additions & 29 deletions src/main/java/io/github/sashirestela/openai/OpenAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ interface Moderations {
* Assistants</a>
*/
@Resource("/v1/assistants")
@Header(name = "OpenAI-Beta", value = "assistants=v1")
interface Assistants {

/**
Expand All @@ -587,7 +588,6 @@ interface Assistants {
* @param assistantRequest The assistant request.
* @return the created assistant object
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST
CompletableFuture<Assistant> create(@Body AssistantRequest assistantRequest);

Expand All @@ -597,7 +597,6 @@ interface Assistants {
* @param assistantId The ID of the assistant to retrieve.
* @return The {@link Assistant} object matching the specified ID.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{assistantId}")
CompletableFuture<Assistant> getOne(@Path("assistantId") String assistantId);

Expand All @@ -608,7 +607,6 @@ interface Assistants {
* @param assistantRequest The assistant request.
* @return the modified assistant object
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{assistantId}")
CompletableFuture<Assistant> modify(@Path("assistantId") String assistantId,
@Body AssistantRequest assistantRequest);
Expand All @@ -619,7 +617,6 @@ CompletableFuture<Assistant> modify(@Path("assistantId") String assistantId,
* @param assistantId The ID of the assistant to delete.
* @return the deletion status
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@DELETE("/{assistantId}")
CompletableFuture<OpenAIDeletedResponse> delete(@Path("assistantId") String assistantId);

Expand All @@ -638,7 +635,6 @@ default CompletableFuture<Page<Assistant>> getList() {
* @param page The result page requested.
* @return the list of assistant objects
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET
CompletableFuture<Page<Assistant>> getList(@Query PageRequest page);

Expand All @@ -662,7 +658,6 @@ default CompletableFuture<AssistantFile> createFile(String assistantId, String f
* should use.
* @return the created assistant file object.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{assistantId}/files")
CompletableFuture<AssistantFile> createFile(@Path("assistantId") String assistantId, @Body FilePath file);

Expand All @@ -673,7 +668,6 @@ default CompletableFuture<AssistantFile> createFile(String assistantId, String f
* @param fileId The ID of the file we're getting.
* @return the assistant file object matching the specified ID
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{assistantId}/files/{fileId}")
CompletableFuture<AssistantFile> getFile(@Path("assistantId") String assistantId,
@Path("fileId") String fileId);
Expand All @@ -685,7 +679,6 @@ CompletableFuture<AssistantFile> getFile(@Path("assistantId") String assistantId
* @param fileId The ID of the file to delete.
* @return the deletion status
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@DELETE("/{assistantId}/files/{fileId}")
CompletableFuture<OpenAIDeletedResponse> deleteFile(@Path("assistantId") String assistantId,
@Path("fileId") String fileId);
Expand All @@ -707,7 +700,6 @@ default CompletableFuture<Page<AssistantFile>> getFileList(String assistantId) {
* @param page The requested result page.
* @return the list of assistant file objects.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{assistantId}/files")
CompletableFuture<Page<AssistantFile>> getFileList(@Path("assistantId") String assistantId,
@Query PageRequest page);
Expand All @@ -721,6 +713,7 @@ CompletableFuture<Page<AssistantFile>> getFileList(@Path("assistantId") String a
* Threads</a>
*/
@Resource("/v1/threads")
@Header(name = "OpenAI-Beta", value = "assistants=v1")
interface Threads {

/**
Expand All @@ -738,7 +731,6 @@ default CompletableFuture<Thread> create() {
* @param threadRequest The thread request.
* @return the created thread object
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST
CompletableFuture<Thread> create(@Body ThreadRequest threadRequest);

Expand All @@ -748,7 +740,6 @@ default CompletableFuture<Thread> create() {
* @param threadId The ID of the thread to retrieve.
* @return The {@link Thread} object matching the specified ID.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}")
CompletableFuture<Thread> getOne(@Path("threadId") String threadId);

Expand All @@ -758,7 +749,6 @@ default CompletableFuture<Thread> create() {
* @param threadRequest The thread request.
* @return the created thread object
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{threadId}")
CompletableFuture<Thread> modify(@Path("threadId") String threadId, @Body ThreadRequest threadRequest);

Expand All @@ -768,7 +758,6 @@ default CompletableFuture<Thread> create() {
* @param threadId The ID of the thread to delete.
* @return the thread deletion status
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@DELETE("/{threadId}")
CompletableFuture<OpenAIDeletedResponse> delete(@Path("threadId") String threadId);

Expand All @@ -779,7 +768,6 @@ default CompletableFuture<Thread> create() {
* @param request The requested message to create.
* @return the created message object
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{threadId}/messages")
CompletableFuture<ThreadMessage> createMessage(@Path("threadId") String threadId,
@Body ThreadMessageRequest request);
Expand All @@ -791,7 +779,6 @@ CompletableFuture<ThreadMessage> createMessage(@Path("threadId") String threadId
* @param messageId The ID of the message to retrieve.
* @return The message object matching the specified ID.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}/messages/{messageId}")
CompletableFuture<ThreadMessage> getMessage(@Path("threadId") String threadId,
@Path("messageId") String messageId);
Expand All @@ -804,7 +791,6 @@ CompletableFuture<ThreadMessage> getMessage(@Path("threadId") String threadId,
* @param request The message modification request.
* @return The message object matching the specified ID.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{threadId}/messages/{messageId}")
CompletableFuture<ThreadMessage> modifyMessage(@Path("threadId") String threadId,
@Path("messageId") String messageId, @Body ThreadMessageRequest request);
Expand All @@ -826,7 +812,6 @@ default CompletableFuture<Page<ThreadMessage>> getMessageList(String threadId) {
* @param page The requested result page.
* @return The list of message objects.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}/messages")
CompletableFuture<Page<ThreadMessage>> getMessageList(@Path("threadId") String threadId,
@Query PageRequest page);
Expand All @@ -838,7 +823,6 @@ CompletableFuture<Page<ThreadMessage>> getMessageList(@Path("threadId") String t
* @param messageId The ID of the message to delete.
* @return The thread message deletion status.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{threadId}/messages/{messageId}")
CompletableFuture<OpenAIDeletedResponse> deleteMessage(@Path("threadId") String threadId,
@Path("messageId") String messageId);
Expand All @@ -851,7 +835,6 @@ CompletableFuture<OpenAIDeletedResponse> deleteMessage(@Path("threadId") String
* @param fileId The ID of the file being retrieved.
* @return The message file object.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}/messages/{messageId}/files/{fileId}")
CompletableFuture<ThreadMessageFile> getMessageFile(@Path("threadId") String threadId,
@Path("messageId") String messageId, @Path("fileId") String fileId);
Expand All @@ -875,7 +858,6 @@ default CompletableFuture<Page<ThreadMessageFile>> getMessageFileList(String thr
* @param page The requested result page.
* @return The list of message file objects.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}/messages/{messageId}/files")
CompletableFuture<Page<ThreadMessageFile>> getMessageFileList(@Path("threadId") String threadId,
@Path("messageId") String messageId, @Query PageRequest page);
Expand All @@ -900,7 +882,6 @@ default CompletableFuture<ThreadRun> createRun(String threadId, String assistant
* @param request The requested run.
* @return the queued run object
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{threadId}/runs")
CompletableFuture<ThreadRun> createRun(@Path("threadId") String threadId, @Body ThreadRunRequest request);

Expand All @@ -911,7 +892,6 @@ default CompletableFuture<ThreadRun> createRun(String threadId, String assistant
* @param runId The ID of the run to retrieve.
* @return The run object matching the specified ID.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}/runs/{runId}")
CompletableFuture<ThreadRun> getRun(@Path("threadId") String threadId, @Path("runId") String runId);

Expand All @@ -922,7 +902,6 @@ default CompletableFuture<ThreadRun> createRun(String threadId, String assistant
* @param runId The ID of the run to modify.
* @return The modified run object matching the specified ID.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{threadId}/runs/{runId}")
CompletableFuture<ThreadRun> modifyRun(@Path("threadId") String threadId, @Path("runId") String runId,
@Body ThreadRunRequest request);
Expand All @@ -944,7 +923,6 @@ default CompletableFuture<Page<ThreadRun>> getRunList(String threadId) {
* @param page The requested page of result.
* @return A list of run objects.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}/runs")
CompletableFuture<Page<ThreadRun>> getRunList(@Path("threadId") String threadId, @Query PageRequest page);

Expand Down Expand Up @@ -973,7 +951,6 @@ default CompletableFuture<ThreadRun> submitToolOutputs(String threadId, String r
* @param toolOutputs The tool output submission.
* @return The modified run object matching the specified ID.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{threadId}/runs/{runId}/submit_tool_outputs")
CompletableFuture<ThreadRun> submitToolOutputs(@Path("threadId") String threadId, @Path("runId") String runId,
@Body ToolOutputSubmission toolOutputs);
Expand All @@ -985,7 +962,6 @@ CompletableFuture<ThreadRun> submitToolOutputs(@Path("threadId") String threadId
* @param runId The ID of the run to cancel.
* @return The modified run object matching the specified ID.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/{threadId}/runs/{runId}/cancel")
CompletableFuture<ThreadRun> cancelRun(@Path("threadId") String threadId, @Path("runId") String runId);

Expand All @@ -995,7 +971,6 @@ CompletableFuture<ThreadRun> submitToolOutputs(@Path("threadId") String threadId
* @param request The thread request create and to run.
* @return A created run object.
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@POST("/runs")
CompletableFuture<ThreadRun> createThreadAndRun(@Body ThreadCreateAndRunRequest request);

Expand All @@ -1007,7 +982,6 @@ CompletableFuture<ThreadRun> submitToolOutputs(@Path("threadId") String threadId
* @param stepId The ID of the run step to retrieve.
* @return the list of run step objects
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}/runs/{runId}/steps/{stepId}")
CompletableFuture<ThreadRunStep> getRunStep(@Path("threadId") String threadId, @Path("runId") String runId,
@Path("stepId") String stepId);
Expand All @@ -1031,7 +1005,6 @@ default CompletableFuture<Page<ThreadRunStep>> getRunStepList(String threadId, S
* @param page The requested result page.
* @return the list of run step objects
*/
@Header(name = "OpenAI-Beta", value = "assistants=v1")
@GET("/{threadId}/runs/{runId}/steps")
CompletableFuture<Page<ThreadRunStep>> getRunStepList(@Path("threadId") String threadId,
@Path("runId") String runId, @Query PageRequest page);
Expand Down

0 comments on commit 6237aa7

Please sign in to comment.