Skip to content

Commit 0fe5f32

Browse files
authored
Merge pull request #219 from Grt1228/1.1.3
v1.1.13 assistant相关api开发
2 parents a501376 + 2265236 commit 0fe5f32

File tree

15 files changed

+1001
-9
lines changed

15 files changed

+1001
-9
lines changed

src/main/java/com/unfbx/chatgpt/OpenAiApi.java

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.unfbx.chatgpt;
22

33
import com.unfbx.chatgpt.entity.Tts.TextToSpeech;
4+
import com.unfbx.chatgpt.entity.assistant.*;
45
import com.unfbx.chatgpt.entity.billing.BillingUsage;
56
import com.unfbx.chatgpt.entity.billing.CreditGrantsResponse;
67
import com.unfbx.chatgpt.entity.billing.Subscription;
@@ -32,6 +33,9 @@
3233
import com.unfbx.chatgpt.entity.models.ModelResponse;
3334
import com.unfbx.chatgpt.entity.moderations.Moderation;
3435
import com.unfbx.chatgpt.entity.moderations.ModerationResponse;
36+
import com.unfbx.chatgpt.entity.thread.ModifyThread;
37+
import com.unfbx.chatgpt.entity.thread.Thread;
38+
import com.unfbx.chatgpt.entity.thread.ThreadResponse;
3539
import com.unfbx.chatgpt.entity.whisper.WhisperResponse;
3640
import io.reactivex.Single;
3741
import okhttp3.MultipartBody;
@@ -422,4 +426,160 @@ Single<WhisperResponse> speechToTextTranslations(@Part MultipartBody.Part file,
422426
@GET("v1/fine_tuning/jobs/{fine_tuning_job_id}/events")
423427
Single<FineTuneJobListResponse<FineTuneJobEvent>> fineTuneJobEvents(@Path("fine_tuning_job_id") String fineTuneJobId, @Query("after") String after, @Query("limit") Integer limit);
424428

429+
430+
/**
431+
* 创建助手
432+
*
433+
* @param assistant 创建助手参数
434+
* @return 助手信息
435+
* @since 1.1.3
436+
*/
437+
@POST("v1/assistants")
438+
@Headers("OpenAI-Beta: assistants=v1")
439+
Single<AssistantResponse> assistant(@Body Assistant assistant);
440+
441+
442+
/**
443+
* 获取助手详细信息
444+
*
445+
* @param assistantId 助手id
446+
* @return 助手信息
447+
* @since 1.1.3
448+
*/
449+
@GET("v1/assistants/{assistant_id}")
450+
@Headers("OpenAI-Beta: assistants=v1")
451+
Single<AssistantResponse> retrieveAssistant(@Path("assistant_id") String assistantId);
452+
453+
/**
454+
* 修改助手信息
455+
*
456+
* @param assistantId 助手id
457+
* @param assistant 修改助手参数
458+
* @return 助手信息
459+
* @since 1.1.3
460+
*/
461+
@POST("v1/assistants/{assistant_id}")
462+
@Headers("OpenAI-Beta: assistants=v1")
463+
Single<AssistantResponse> modifyAssistant(@Path("assistant_id") String assistantId, @Body Assistant assistant);
464+
465+
/**
466+
* 删除助手
467+
*
468+
* @param assistantId 助手id
469+
* @return 删除状态
470+
* @since 1.1.3
471+
*/
472+
@DELETE("v1/assistants/{assistant_id}")
473+
@Headers("OpenAI-Beta: assistants=v1")
474+
Single<DeleteResponse> deleteAssistant(@Path("assistant_id") String assistantId);
475+
476+
477+
/**
478+
* 助手列表
479+
*
480+
* @param limit 每次查询数量 默认值:20
481+
* @param order 排序类型
482+
* @param before 分页参数,之前的id,默认值:null
483+
* @param after 分页参数,之后的id,默认值:null
484+
* @return AssistantListResponse #AssistantResponse
485+
* @since 1.1.3
486+
*/
487+
@GET("v1/assistants")
488+
@Headers("OpenAI-Beta: assistants=v1")
489+
Single<AssistantListResponse<AssistantResponse>> assistants(@Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after);
490+
491+
/**
492+
* 创建助手文件
493+
*
494+
* @param assistantId 助手id
495+
* @param assistantFile 文件信息
496+
* @return 返回信息AssistantResponse
497+
*/
498+
@POST("v1/assistants/{assistant_id}/files")
499+
@Headers("OpenAI-Beta: assistants=v1")
500+
Single<AssistantFileResponse> assistantFile(@Path("assistant_id") String assistantId, @Body AssistantFile assistantFile);
501+
502+
/**
503+
* 检索助手文件
504+
*
505+
* @param assistantId 助手id
506+
* @param fileId 文件id
507+
* @return 助手文件信息
508+
*/
509+
@GET("v1/assistants/{assistant_id}/files/{file_id}")
510+
@Headers("OpenAI-Beta: assistants=v1")
511+
Single<AssistantFileResponse> retrieveAssistantFile(@Path("assistant_id") String assistantId, @Path("file_id") String fileId);
512+
513+
/**
514+
* 删除助手文件
515+
*
516+
* @param assistantId 助手id
517+
* @param fileId 文件id
518+
* @return 删除状态
519+
*/
520+
@DELETE("v1/assistants/{assistant_id}/files/{file_id}")
521+
@Headers("OpenAI-Beta: assistants=v1")
522+
Single<DeleteResponse> deleteAssistantFile(@Path("assistant_id") String assistantId, @Path("file_id") String fileId);
523+
524+
/**
525+
* 助手文件列表
526+
*
527+
* @param assistantId 助手id
528+
* @param limit 一页数据大小
529+
* @param order 排序类型
530+
* @param before 分页参数,之前的id,默认值:null
531+
* @param after 分页参数,之后的id,默认值:null
532+
* @return 助手文件列表
533+
*/
534+
@GET("v1/assistants/{assistant_id}/files")
535+
@Headers("OpenAI-Beta: assistants=v1")
536+
Single<AssistantListResponse<AssistantFileResponse>> assistantFiles(@Path("assistant_id") String assistantId,
537+
@Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after);
538+
539+
540+
/**
541+
* 创建线程
542+
*
543+
* @param thread 创建线程参数
544+
* @return 线程信息
545+
* @since 1.1.3
546+
*/
547+
@POST("v1/threads")
548+
@Headers("OpenAI-Beta: assistants=v1")
549+
Single<ThreadResponse> thread(@Body Thread thread);
550+
551+
552+
/**
553+
* 获取线程详细信息
554+
*
555+
* @param threadId 线程id
556+
* @return 线程信息
557+
* @since 1.1.3
558+
*/
559+
@GET("v1/threads/{thread_id}")
560+
@Headers("OpenAI-Beta: assistants=v1")
561+
Single<ThreadResponse> retrieveThread(@Path("thread_id") String threadId);
562+
563+
/**
564+
* 修改线程信息
565+
*
566+
* @param threadId 线程id
567+
* @param thread 线程信息
568+
* @return 线程信息
569+
* @since 1.1.3
570+
*/
571+
@POST("v1/threads/{thread_id}")
572+
@Headers("OpenAI-Beta: assistants=v1")
573+
Single<ThreadResponse> modifyThread(@Path("thread_id") String threadId, @Body ModifyThread thread);
574+
575+
/**
576+
* 删除线程
577+
*
578+
* @param threadId 线程id
579+
* @return 删除状态
580+
* @since 1.1.3
581+
*/
582+
@DELETE("v1/threads/{thread_id}")
583+
@Headers("OpenAI-Beta: assistants=v1")
584+
Single<DeleteResponse> deleteThread(@Path("thread_id") String threadId);
425585
}

0 commit comments

Comments
 (0)