Skip to content

Commit d237c3c

Browse files
docs: add some missing javadocs (#78)
1 parent 0d87b0a commit d237c3c

16 files changed

+320
-19
lines changed

openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ private constructor(
421421
override fun toString() = "Audio{id=$id, additionalProperties=$additionalProperties}"
422422
}
423423

424+
/**
425+
* The contents of the assistant message. Required unless `tool_calls` or `function_call` is
426+
* specified.
427+
*/
424428
@JsonDeserialize(using = Content.Deserializer::class)
425429
@JsonSerialize(using = Content.Serializer::class)
426430
class Content
@@ -447,8 +451,12 @@ private constructor(
447451

448452
fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null
449453

454+
/** The contents of the assistant message. */
450455
fun asTextContent(): String = textContent.getOrThrow("textContent")
451-
456+
/**
457+
* An array of content parts with a defined type. Can be one or more of type `text`, or
458+
* exactly one of type `refusal`.
459+
*/
452460
fun asArrayOfContentParts(): List<ChatCompletionRequestAssistantMessageContentPart> =
453461
arrayOfContentParts.getOrThrow("arrayOfContentParts")
454462

@@ -491,8 +499,13 @@ private constructor(
491499

492500
companion object {
493501

502+
/** The contents of the assistant message. */
494503
@JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent)
495504

505+
/**
506+
* An array of content parts with a defined type. Can be one or more of type `text`, or
507+
* exactly one of type `refusal`.
508+
*/
496509
@JvmStatic
497510
fun ofArrayOfContentParts(
498511
arrayOfContentParts: List<ChatCompletionRequestAssistantMessageContentPart>
@@ -549,6 +562,7 @@ private constructor(
549562
}
550563
}
551564

565+
/** Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */
552566
@JsonDeserialize(
553567
using = ChatCompletionRequestAssistantMessageContentPart.Deserializer::class
554568
)
@@ -576,6 +590,9 @@ private constructor(
576590
fun isChatCompletionContentPartRefusal(): Boolean =
577591
chatCompletionContentPartRefusal != null
578592

593+
/**
594+
* Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
595+
*/
579596
fun asChatCompletionContentPartText(): ChatCompletionContentPartText =
580597
chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText")
581598

@@ -638,6 +655,10 @@ private constructor(
638655

639656
companion object {
640657

658+
/**
659+
* Learn about
660+
* [text inputs](https://platform.openai.com/docs/guides/text-generation).
661+
*/
641662
@JvmStatic
642663
fun ofChatCompletionContentPartText(
643664
chatCompletionContentPartText: ChatCompletionContentPartText

openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionContentPart.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import java.util.Objects
1818
import java.util.Optional
1919
import kotlin.jvm.optionals.getOrNull
2020

21+
/** Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */
2122
@JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class)
2223
@JsonSerialize(using = ChatCompletionContentPart.Serializer::class)
2324
class ChatCompletionContentPart
@@ -47,12 +48,13 @@ private constructor(
4748
fun isChatCompletionContentPartInputAudio(): Boolean =
4849
chatCompletionContentPartInputAudio != null
4950

51+
/** Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */
5052
fun asChatCompletionContentPartText(): ChatCompletionContentPartText =
5153
chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText")
52-
54+
/** Learn about [image inputs](https://platform.openai.com/docs/guides/vision). */
5355
fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage =
5456
chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage")
55-
57+
/** Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). */
5658
fun asChatCompletionContentPartInputAudio(): ChatCompletionContentPartInputAudio =
5759
chatCompletionContentPartInputAudio.getOrThrow("chatCompletionContentPartInputAudio")
5860

@@ -112,11 +114,13 @@ private constructor(
112114

113115
companion object {
114116

117+
/** Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */
115118
@JvmStatic
116119
fun ofChatCompletionContentPartText(
117120
chatCompletionContentPartText: ChatCompletionContentPartText
118121
) = ChatCompletionContentPart(chatCompletionContentPartText = chatCompletionContentPartText)
119122

123+
/** Learn about [image inputs](https://platform.openai.com/docs/guides/vision). */
120124
@JvmStatic
121125
fun ofChatCompletionContentPartImage(
122126
chatCompletionContentPartImage: ChatCompletionContentPartImage
@@ -125,6 +129,7 @@ private constructor(
125129
chatCompletionContentPartImage = chatCompletionContentPartImage
126130
)
127131

132+
/** Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). */
128133
@JvmStatic
129134
fun ofChatCompletionContentPartInputAudio(
130135
chatCompletionContentPartInputAudio: ChatCompletionContentPartInputAudio

openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,21 @@ constructor(
16501650
)
16511651
}
16521652

1653+
/**
1654+
* Deprecated in favor of `tool_choice`.
1655+
*
1656+
* Controls which (if any) function is called by the model.
1657+
*
1658+
* `none` means the model will not call a function and instead generates a message.
1659+
*
1660+
* `auto` means the model can pick between generating a message or calling a function.
1661+
*
1662+
* Specifying a particular function via `{"name": "my_function"}` forces the model to call that
1663+
* function.
1664+
*
1665+
* `none` is the default when no functions are present. `auto` is the default if functions are
1666+
* present.
1667+
*/
16531668
@JsonDeserialize(using = FunctionCall.Deserializer::class)
16541669
@JsonSerialize(using = FunctionCall.Serializer::class)
16551670
class FunctionCall
@@ -1675,8 +1690,15 @@ constructor(
16751690

16761691
fun isFunctionCallOption(): Boolean = functionCallOption != null
16771692

1693+
/**
1694+
* `none` means the model will not call a function and instead generates a message. `auto`
1695+
* means the model can pick between generating a message or calling a function.
1696+
*/
16781697
fun asBehavior(): Behavior = behavior.getOrThrow("behavior")
1679-
1698+
/**
1699+
* Specifying a particular function via `{"name": "my_function"}` forces the model to call
1700+
* that function.
1701+
*/
16801702
fun asFunctionCallOption(): ChatCompletionFunctionCallOption =
16811703
functionCallOption.getOrThrow("functionCallOption")
16821704

@@ -1710,8 +1732,16 @@ constructor(
17101732

17111733
companion object {
17121734

1735+
/**
1736+
* `none` means the model will not call a function and instead generates a message.
1737+
* `auto` means the model can pick between generating a message or calling a function.
1738+
*/
17131739
@JvmStatic fun ofBehavior(behavior: Behavior) = FunctionCall(behavior = behavior)
17141740

1741+
/**
1742+
* Specifying a particular function via `{"name": "my_function"}` forces the model to
1743+
* call that function.
1744+
*/
17151745
@JvmStatic
17161746
fun ofFunctionCallOption(functionCallOption: ChatCompletionFunctionCallOption) =
17171747
FunctionCall(functionCallOption = functionCallOption)
@@ -2095,6 +2125,23 @@ constructor(
20952125
override fun toString() = "Metadata{additionalProperties=$additionalProperties}"
20962126
}
20972127

2128+
/**
2129+
* An object specifying the format that the model must output.
2130+
*
2131+
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which
2132+
* ensures the model will match your supplied JSON schema. Learn more in the
2133+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
2134+
*
2135+
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model
2136+
* generates is valid JSON.
2137+
*
2138+
* **Important:** when using JSON mode, you **must** also instruct the model to produce JSON
2139+
* yourself via a system or user message. Without this, the model may generate an unending
2140+
* stream of whitespace until the generation reaches the token limit, resulting in a
2141+
* long-running and seemingly "stuck" request. Also note that the message content may be
2142+
* partially cut off if `finish_reason="length"`, which indicates the generation exceeded
2143+
* `max_tokens` or the conversation exceeded the max context length.
2144+
*/
20982145
@JsonDeserialize(using = ResponseFormat.Deserializer::class)
20992146
@JsonSerialize(using = ResponseFormat.Serializer::class)
21002147
class ResponseFormat
@@ -2289,6 +2336,7 @@ constructor(
22892336
override fun toString() = value.toString()
22902337
}
22912338

2339+
/** Up to 4 sequences where the API will stop generating further tokens. */
22922340
@JsonDeserialize(using = Stop.Deserializer::class)
22932341
@JsonSerialize(using = Stop.Serializer::class)
22942342
class Stop

openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionDeveloperMessageParam.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ private constructor(
160160
)
161161
}
162162

163+
/** The contents of the developer message. */
163164
@JsonDeserialize(using = Content.Deserializer::class)
164165
@JsonSerialize(using = Content.Serializer::class)
165166
class Content
@@ -184,8 +185,12 @@ private constructor(
184185

185186
fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null
186187

188+
/** The contents of the developer message. */
187189
fun asTextContent(): String = textContent.getOrThrow("textContent")
188-
190+
/**
191+
* An array of content parts with a defined type. For developer messages, only type `text`
192+
* is supported.
193+
*/
189194
fun asArrayOfContentParts(): List<ChatCompletionContentPartText> =
190195
arrayOfContentParts.getOrThrow("arrayOfContentParts")
191196

@@ -229,8 +234,13 @@ private constructor(
229234

230235
companion object {
231236

237+
/** The contents of the developer message. */
232238
@JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent)
233239

240+
/**
241+
* An array of content parts with a defined type. For developer messages, only type
242+
* `text` is supported.
243+
*/
234244
@JvmStatic
235245
fun ofArrayOfContentParts(arrayOfContentParts: List<ChatCompletionContentPartText>) =
236246
Content(arrayOfContentParts = arrayOfContentParts)

openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessageParam.kt

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import java.util.Objects
1818
import java.util.Optional
1919
import kotlin.jvm.optionals.getOrNull
2020

21+
/**
22+
* Developer-provided instructions that the model should follow, regardless of messages sent by the
23+
* user. With o1 models and newer, `developer` messages replace the previous `system` messages.
24+
*/
2125
@JsonDeserialize(using = ChatCompletionMessageParam.Deserializer::class)
2226
@JsonSerialize(using = ChatCompletionMessageParam.Serializer::class)
2327
class ChatCompletionMessageParam
@@ -73,15 +77,23 @@ private constructor(
7377

7478
fun isChatCompletionFunctionMessageParam(): Boolean = chatCompletionFunctionMessageParam != null
7579

80+
/**
81+
* Developer-provided instructions that the model should follow, regardless of messages sent by
82+
* the user. With o1 models and newer, `developer` messages replace the previous `system`
83+
* messages.
84+
*/
7685
fun asChatCompletionDeveloperMessageParam(): ChatCompletionDeveloperMessageParam =
7786
chatCompletionDeveloperMessageParam.getOrThrow("chatCompletionDeveloperMessageParam")
78-
87+
/**
88+
* Developer-provided instructions that the model should follow, regardless of messages sent by
89+
* the user. With o1 models and newer, use `developer` messages for this purpose instead.
90+
*/
7991
fun asChatCompletionSystemMessageParam(): ChatCompletionSystemMessageParam =
8092
chatCompletionSystemMessageParam.getOrThrow("chatCompletionSystemMessageParam")
81-
93+
/** Messages sent by an end user, containing prompts or additional context information. */
8294
fun asChatCompletionUserMessageParam(): ChatCompletionUserMessageParam =
8395
chatCompletionUserMessageParam.getOrThrow("chatCompletionUserMessageParam")
84-
96+
/** Messages sent by the model in response to user messages. */
8597
fun asChatCompletionAssistantMessageParam(): ChatCompletionAssistantMessageParam =
8698
chatCompletionAssistantMessageParam.getOrThrow("chatCompletionAssistantMessageParam")
8799

@@ -167,6 +179,11 @@ private constructor(
167179

168180
companion object {
169181

182+
/**
183+
* Developer-provided instructions that the model should follow, regardless of messages sent
184+
* by the user. With o1 models and newer, `developer` messages replace the previous `system`
185+
* messages.
186+
*/
170187
@JvmStatic
171188
fun ofChatCompletionDeveloperMessageParam(
172189
chatCompletionDeveloperMessageParam: ChatCompletionDeveloperMessageParam
@@ -175,6 +192,10 @@ private constructor(
175192
chatCompletionDeveloperMessageParam = chatCompletionDeveloperMessageParam
176193
)
177194

195+
/**
196+
* Developer-provided instructions that the model should follow, regardless of messages sent
197+
* by the user. With o1 models and newer, use `developer` messages for this purpose instead.
198+
*/
178199
@JvmStatic
179200
fun ofChatCompletionSystemMessageParam(
180201
chatCompletionSystemMessageParam: ChatCompletionSystemMessageParam
@@ -183,6 +204,7 @@ private constructor(
183204
chatCompletionSystemMessageParam = chatCompletionSystemMessageParam
184205
)
185206

207+
/** Messages sent by an end user, containing prompts or additional context information. */
186208
@JvmStatic
187209
fun ofChatCompletionUserMessageParam(
188210
chatCompletionUserMessageParam: ChatCompletionUserMessageParam
@@ -191,6 +213,7 @@ private constructor(
191213
chatCompletionUserMessageParam = chatCompletionUserMessageParam
192214
)
193215

216+
/** Messages sent by the model in response to user messages. */
194217
@JvmStatic
195218
fun ofChatCompletionAssistantMessageParam(
196219
chatCompletionAssistantMessageParam: ChatCompletionAssistantMessageParam

openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionPredictionContent.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ private constructor(
153153
)
154154
}
155155

156+
/**
157+
* The content that should be matched when generating a model response. If generated tokens
158+
* would match this content, the entire model response can be returned much more quickly.
159+
*/
156160
@JsonDeserialize(using = Content.Deserializer::class)
157161
@JsonSerialize(using = Content.Serializer::class)
158162
class Content
@@ -181,8 +185,16 @@ private constructor(
181185

182186
fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null
183187

188+
/**
189+
* The content used for a Predicted Output. This is often the text of a file you are
190+
* regenerating with minor changes.
191+
*/
184192
fun asTextContent(): String = textContent.getOrThrow("textContent")
185-
193+
/**
194+
* An array of content parts with a defined type. Supported options differ based on the
195+
* [model](https://platform.openai.com/docs/models) being used to generate the response. Can
196+
* contain text inputs.
197+
*/
186198
fun asArrayOfContentParts(): List<ChatCompletionContentPartText> =
187199
arrayOfContentParts.getOrThrow("arrayOfContentParts")
188200

@@ -226,8 +238,17 @@ private constructor(
226238

227239
companion object {
228240

241+
/**
242+
* The content used for a Predicted Output. This is often the text of a file you are
243+
* regenerating with minor changes.
244+
*/
229245
@JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent)
230246

247+
/**
248+
* An array of content parts with a defined type. Supported options differ based on the
249+
* [model](https://platform.openai.com/docs/models) being used to generate the response.
250+
* Can contain text inputs.
251+
*/
231252
@JvmStatic
232253
fun ofArrayOfContentParts(arrayOfContentParts: List<ChatCompletionContentPartText>) =
233254
Content(arrayOfContentParts = arrayOfContentParts)

openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionSystemMessageParam.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private constructor(
159159
)
160160
}
161161

162+
/** The contents of the system message. */
162163
@JsonDeserialize(using = Content.Deserializer::class)
163164
@JsonSerialize(using = Content.Serializer::class)
164165
class Content
@@ -183,8 +184,12 @@ private constructor(
183184

184185
fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null
185186

187+
/** The contents of the system message. */
186188
fun asTextContent(): String = textContent.getOrThrow("textContent")
187-
189+
/**
190+
* An array of content parts with a defined type. For system messages, only type `text` is
191+
* supported.
192+
*/
188193
fun asArrayOfContentParts(): List<ChatCompletionContentPartText> =
189194
arrayOfContentParts.getOrThrow("arrayOfContentParts")
190195

@@ -228,8 +233,13 @@ private constructor(
228233

229234
companion object {
230235

236+
/** The contents of the system message. */
231237
@JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent)
232238

239+
/**
240+
* An array of content parts with a defined type. For system messages, only type `text`
241+
* is supported.
242+
*/
233243
@JvmStatic
234244
fun ofArrayOfContentParts(arrayOfContentParts: List<ChatCompletionContentPartText>) =
235245
Content(arrayOfContentParts = arrayOfContentParts)

0 commit comments

Comments
 (0)