Skip to content

Commit

Permalink
refact: deprecate createCompletion in favor of completion
Browse files Browse the repository at this point in the history
  • Loading branch information
aallam committed Mar 9, 2021
1 parent 2f487a1 commit 4deb5a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public interface OpenAI {
*/
public suspend fun engine(engineId: EngineId): Engine

/**
* This is the main endpoint of the API. Returns the predicted completion for the given prompt,
* and can also return the probabilities of alternative tokens at each position if requested.
*/
@Deprecated(message = "renamed to `completion`", replaceWith = ReplaceWith("completion(engineId, request)"))
public suspend fun createCompletion(engineId: EngineId, request: CompletionRequest? = null): TextCompletion

/**
* This is the main endpoint of the API. Returns the predicted completion for the given prompt,
* and can also return the probabilities of alternative tokens at each position if requested.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ internal class OpenAIApi(config: OpenAIConfig) : OpenAI {
return httpClient.get(path = "/v1/engines/$engineId")
}

override suspend fun createCompletion(engineId: EngineId, request: CompletionRequest?): TextCompletion {
return completion(engineId, request)
}

override suspend fun completion(engineId: EngineId, request: CompletionRequest?): TextCompletion {
val body = if (request?.stream == true) request.copy(stream = false) else request
return httpClient.post(path = "/v1/engines/$engineId/completions", body = body ?: EmptyContent)
Expand Down

0 comments on commit 4deb5a5

Please sign in to comment.