Package com.hw.openai.service
Interface OpenAiService
public interface OpenAiService
Service interface for interacting with the OpenAI API.
- Author:
- HamaWhite
-
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.Single<ChatCompletionResp>
createChatCompletion
(ChatCompletion chatCompletion) Creates a response for the given chat conversation.io.reactivex.Single<ChatCompletionResp>
createChatCompletion
(String deploymentId, String apiVersion, ChatCompletion chatCompletion) Creates a model response for the given chat conversation, using azure openai.io.reactivex.Single<CompletionResp>
createCompletion
(Completion completion) Creates a completion for the provided prompt and parameters.io.reactivex.Single<CompletionResp>
createCompletion
(String deploymentId, String apiVersion, Completion completion) Creates a completion for the provided prompt and parameters, using azure openai.io.reactivex.Single<EmbeddingResp>
createEmbedding
(Embedding embedding) Creates an embedding vector representing the input text.io.reactivex.Single<EmbeddingResp>
createEmbedding
(String deploymentId, String apiVersion, Embedding embedding) Creates an embedding vector representing the input text, using azure openai.io.reactivex.Single<ImageResp>
createImage
(CreateImageReq request) Creates an image given a prompt.io.reactivex.Single<ModelResp>
Lists the currently available models, and provides basic information about each one such as the owner and availability.io.reactivex.Single<Model>
retrieveModel
(String model) Retrieves a model instance, providing basic information about the model such as the owner and permissions.retrofit2.Call<okhttp3.ResponseBody>
streamChatCompletion
(ChatCompletion chatCompletion) Creates a stream response for the given chat conversation.retrofit2.Call<okhttp3.ResponseBody>
streamCompletion
(Completion completion) Creates a stream completion for the provided prompt and parameters.
-
Method Details
-
listModels
Lists the currently available models, and provides basic information about each one such as the owner and availability.- Returns:
- a Single emitting the response containing the list of available models
-
retrieveModel
Retrieves a model instance, providing basic information about the model such as the owner and permissions.- Parameters:
model
- the ID of the model to use for this request- Returns:
- a Single emitting the response containing the retrieved model
-
createCompletion
@POST("completions") io.reactivex.Single<CompletionResp> createCompletion(@Body Completion completion) Creates a completion for the provided prompt and parameters.- Parameters:
completion
- the completion request object containing the prompt and parameters- Returns:
- a Single emitting the response containing the completion result
-
createCompletion
@POST("{deploymentId}/completions") io.reactivex.Single<CompletionResp> createCompletion(@Path("deploymentId") String deploymentId, @Query("api-version") String apiVersion, @Body Completion completion) Creates a completion for the provided prompt and parameters, using azure openai.- Parameters:
deploymentId
- The deploymentId for azure openai url.apiVersion
- The apiVersion for azure openai url parameter 'api-version'.completion
- the completion request object containing the prompt and parameters- Returns:
- a Single emitting the response containing the completion result
-
streamCompletion
@Streaming @POST("completions") retrofit2.Call<okhttp3.ResponseBody> streamCompletion(@Body Completion completion) Creates a stream completion for the provided prompt and parameters.- Parameters:
completion
- the completion request object containing the prompt and parameters- Returns:
- a Single emitting the response containing the completion result
-
createChatCompletion
@POST("chat/completions") io.reactivex.Single<ChatCompletionResp> createChatCompletion(@Body ChatCompletion chatCompletion) Creates a response for the given chat conversation.- Parameters:
chatCompletion
- the chat completion request object containing the chat conversation- Returns:
- a Single emitting the response containing the chat completion result
-
createChatCompletion
@POST("{deploymentId}/chat/completions") io.reactivex.Single<ChatCompletionResp> createChatCompletion(@Path("deploymentId") String deploymentId, @Query("api-version") String apiVersion, @Body ChatCompletion chatCompletion) Creates a model response for the given chat conversation, using azure openai.- Parameters:
deploymentId
- The deploymentId for azure openai url.apiVersion
- The apiVersion for azure openai url parameter 'api-version'.chatCompletion
- the chat completion request object containing the chat conversation- Returns:
- a Single emitting the response containing the chat completion result
-
streamChatCompletion
@Streaming @POST("chat/completions") retrofit2.Call<okhttp3.ResponseBody> streamChatCompletion(@Body ChatCompletion chatCompletion) Creates a stream response for the given chat conversation.- Parameters:
chatCompletion
- the chat completion request object- Returns:
- a
Call
representing the streaming response
-
createEmbedding
Creates an embedding vector representing the input text.- Parameters:
embedding
- The Embedding object containing the input text.- Returns:
- A Single object that emits an EmbeddingResp, representing the response containing the embedding vector.
-
createEmbedding
@POST("{deploymentId}/embeddings") io.reactivex.Single<EmbeddingResp> createEmbedding(@Path("deploymentId") String deploymentId, @Query("api-version") String apiVersion, @Body Embedding embedding) Creates an embedding vector representing the input text, using azure openai.- Parameters:
deploymentId
- The deploymentId for azure openai url.apiVersion
- The apiVersion for azure openai url parameter 'api-version'.embedding
- The Embedding object containing the input text.- Returns:
- A Single object that emits an EmbeddingResp, representing the response containing the embedding vector.
-
createImage
@POST("images/generations") io.reactivex.Single<ImageResp> createImage(@Body CreateImageReq request) Creates an image given a prompt.- Parameters:
request
- the create image request- Returns:
- A Single emitting the response containing the generated image.
-