Skip to content

Commit d5d4e30

Browse files
committed
fix kotlin test typos
1 parent 305f371 commit d5d4e30

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/test/kotlin/KotlinTest.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import com.cjcrafter.openai.chat.ChatRequest
66
import com.cjcrafter.openai.chat.ChatResponse
77
import com.cjcrafter.openai.chat.ChatResponseChunk
88
import com.cjcrafter.openai.completions.CompletionRequest
9-
import com.cjcrafter.openai.completions.CompletionResponse
10-
import com.cjcrafter.openai.completions.CompletionResponseChunk
119
import com.cjcrafter.openai.exception.OpenAIError
1210
import io.github.cdimascio.dotenv.Dotenv
1311
import io.github.cdimascio.dotenv.dotenv
@@ -32,9 +30,8 @@ object KotlinTest {
3230
val scanner = Scanner(System.`in`)
3331

3432
// Print out the menu of options
35-
println("""$GREEN
36-
Please select one of the options below by typing a number.
37-
33+
println("""
34+
${GREEN}Please select one of the options below by typing a number.
3835
1. Completion (create, sync)
3936
2. Completion (stream, sync)
4037
3. Completion (create, async)
@@ -76,17 +73,20 @@ object KotlinTest {
7673
val openai = OpenAI(key)
7774
println(RESET + "Generating Response" + PURPLE)
7875
if (stream) {
79-
if (async)
76+
if (async) {
8077
openai.streamCompletionAsync(request, { print(it[0].text) })
81-
else
78+
println("$CYAN !!! Code has finished executing. Wait for async code to complete.$PURPLE")
79+
} else {
8280
openai.streamCompletion(request, { print(it[0].text) })
81+
}
8382
} else {
84-
if (async)
83+
if (async) {
8584
openai.createCompletionAsync(request, { println(it[0].text) })
86-
else
85+
println("$CYAN !!! Code has finished executing. Wait for async code to complete.$PURPLE")
86+
} else {
8787
println(openai.createCompletion(request)[0].text)
88+
}
8889
}
89-
println("$CYAN !!! Code has finished executing. Wait for async code to complete.$RESET")
9090
}
9191

9292
@Throws(OpenAIError::class)
@@ -126,6 +126,7 @@ object KotlinTest {
126126
print(response[0].delta)
127127
if (response[0].isFinished()) messages.add(response[0].message)
128128
})
129+
println("$CYAN !!! Code has finished executing. Wait for async code to complete.$PURPLE")
129130
} else {
130131
openai.streamChatCompletion(request, { response: ChatResponseChunk ->
131132
print(response[0].delta)
@@ -138,13 +139,13 @@ object KotlinTest {
138139
println(response[0].message.content)
139140
messages.add(response[0].message)
140141
})
142+
println("$CYAN !!! Code has finished executing. Wait for async code to complete.$PURPLE")
141143
} else {
142144
val response = openai.createChatCompletion(request)
143145
println(response[0].message.content)
144146
messages.add(response[0].message)
145147
}
146148
}
147-
println("$CYAN !!! Code has finished executing. Wait for async code to complete.")
148149
}
149150
}
150151
}

0 commit comments

Comments
 (0)