Skip to content

Commit

Permalink
feat(images-api): implement images api
Browse files Browse the repository at this point in the history
 - https://platform.openai.com/docs/api-reference/images
test for github action
add  fun create(
                prompt: String,
                model: Model? = null,
            )
  • Loading branch information
hanrw committed Feb 12, 2024
1 parent f368104 commit 1fd8d46
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion openai-client/openai-client-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
// alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.kover)
alias(libs.plugins.touchlab.kmmbridge)
// alias(libs.plugins.touchlab.kmmbridge)
// id("module.publication")
`maven-publish`
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.tddworks.openai.api.chat.api

import kotlinx.coroutines.flow.Flow
import kotlinx.serialization.ExperimentalSerializationApi

/**
* Chat API - https://platform.openai.com/docs/api-reference/chat
* Given a list of messages comprising a conversation, the model will return a response.
* Related guide: Chat Completions
*/
@OptIn(ExperimentalSerializationApi::class)
interface Chat {
/**
* Create a chat completion.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tddworks.openai.api.images.api

import com.tddworks.openai.api.chat.api.Model
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -9,7 +10,8 @@ import kotlinx.serialization.Serializable
* @see [ImageCreate](https://platform.openai.com/docs/api-reference/images/create)
*/
@Serializable
class ImageCreate(
@ExperimentalSerializationApi
data class ImageCreate(
/**
* A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3.
*/
Expand Down Expand Up @@ -67,4 +69,19 @@ class ImageCreate(
*/
@SerialName("quality")
val quality: Quality? = null,
)
) {
companion object {
/**
* Create an instance of [ImageCreate].
* @param prompt A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3.
* @param model The model to use for image generation. Defaults to dall-e-2
*/
fun create(
prompt: String,
model: Model? = null,
): ImageCreate = ImageCreate(
prompt = prompt,
model = model
)
}
}

0 comments on commit 1fd8d46

Please sign in to comment.