Skip to content

Commit fe3b800

Browse files
committed
change enum to a value class with companion object values
1 parent 4356af7 commit fe3b800

File tree

2 files changed

+37
-39
lines changed

2 files changed

+37
-39
lines changed

openai-core/src/commonMain/kotlin/com.aallam.openai.api/chat/ChatCompletionChunk.kt

+7-6
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ public data class ChatCompletionChunk(
4444
public val usage: Usage? = null,
4545

4646
/**
47-
* Content filtering results for zero or more prompts in the request. In a streaming request,
48-
* results for different prompts may arrive at different times or in different orders.
49-
*/
50-
@SerialName("prompt_filter_results")
51-
val promptFilterResults: List<ContentFilterResultsForPrompt>? = null
5247
* This fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with
5348
* the `seed` request parameter to understand when backend changes have been made that might impact determinism.
5449
*/
55-
5650
@SerialName("system_fingerprint")
5751
public val systemFingerprint: String? = null,
52+
53+
/**
54+
* Content filtering results for zero or more prompts in the request. In a streaming request,
55+
* results for different prompts may arrive at different times or in different orders.
56+
*/
57+
@SerialName("prompt_filter_results")
58+
val promptFilterResults: List<ContentFilterResultsForPrompt>? = null,
5859
)
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,41 @@
11
package com.aallam.openai.azure.api.filtering
22

3-
import kotlinx.serialization.SerialName
43
import kotlinx.serialization.Serializable
54

65
/**
76
* Ratings for the intensity and risk level of harmful content.
87
*/
98
@Serializable
10-
public enum class ContentFilterSeverity(@Serializable public val value: String) {
9+
@JvmInline
10+
public value class ContentFilterSeverity(public val value: String) {
11+
public companion object {
12+
/**
13+
* Content may be related to violence, self-harm, sexual, or hate categories but the terms
14+
* are used in general, journalistic, scientific, medical, and similar professional contexts,
15+
* which are appropriate for most audiences.
16+
*/
17+
public val SAFE: ContentFilterSeverity = ContentFilterSeverity("safe")
1118

12-
/**
13-
* Content may be related to violence, self-harm, sexual, or hate categories but the terms
14-
* are used in general, journalistic, scientific, medical, and similar professional contexts,
15-
* which are appropriate for most audiences.
16-
*/
17-
@SerialName("safe")
18-
SAFE("safe"),
19+
/**
20+
* Content that expresses prejudiced, judgmental, or opinionated views, includes offensive
21+
* use of language, stereotyping, use cases exploring a fictional world (for example, gaming,
22+
* literature) and depictions at low intensity.
23+
*/
24+
public val LOW: ContentFilterSeverity = ContentFilterSeverity("low")
1925

20-
/**
21-
* Content that expresses prejudiced, judgmental, or opinionated views, includes offensive
22-
* use of language, stereotyping, use cases exploring a fictional world (for example, gaming,
23-
* literature) and depictions at low intensity.
24-
*/
25-
@SerialName("low")
26-
LOW("low"),
26+
/**
27+
* Content that uses offensive, insulting, mocking, intimidating, or demeaning language
28+
* towards specific identity groups, includes depictions of seeking and executing harmful
29+
* instructions, fantasies, glorification, promotion of harm at medium intensity.
30+
*/
31+
public val MEDIUM: ContentFilterSeverity = ContentFilterSeverity("medium")
2732

28-
/**
29-
* Content that uses offensive, insulting, mocking, intimidating, or demeaning language
30-
* towards specific identity groups, includes depictions of seeking and executing harmful
31-
* instructions, fantasies, glorification, promotion of harm at medium intensity.
32-
*/
33-
@SerialName("medium")
34-
MEDIUM("medium"),
35-
36-
/**
37-
* Content that displays explicit and severe harmful instructions, actions,
38-
* damage, or abuse; includes endorsement, glorification, or promotion of severe
39-
* harmful acts, extreme or illegal forms of harm, radicalization, or non-consensual
40-
* power exchange or abuse.
41-
*/
42-
@SerialName("high")
43-
HIGH("high")
44-
}
33+
/**
34+
* Content that displays explicit and severe harmful instructions, actions,
35+
* damage, or abuse; includes endorsement, glorification, or promotion of severe
36+
* harmful acts, extreme or illegal forms of harm, radicalization, or non-consensual
37+
* power exchange or abuse.
38+
*/
39+
public val HIGH: ContentFilterSeverity = ContentFilterSeverity("high")
40+
}
41+
}

0 commit comments

Comments
 (0)