You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
println("$CYAN !!! Code has finished executing. Wait for async code to complete.$PURPLE")
83
+
} else {
84
+
println(openai.createCompletion(request)[0].text)
89
85
}
90
86
}
87
+
}
91
88
92
-
@Throws(OpenAIError::class)
93
-
fundoChat(stream:Boolean, async:Boolean) {
94
-
val scan =Scanner(System.`in`)
89
+
@Throws(OpenAIError::class)
90
+
fundoChat(stream:Boolean, async:Boolean) {
91
+
val scan =Scanner(System.`in`)
95
92
96
-
// This is the prompt that the bot will refer back to for every message.
97
-
val prompt ="You are a customer support chat-bot. Write brief summaries of the user's questions so that agents can easily find the answer in a database.".toSystemMessage()
93
+
// This is the prompt that the bot will refer back to for every message.
94
+
val prompt ="You are a customer support chat-bot. Write brief summaries of the user's questions so that agents can easily find the answer in a database.".toSystemMessage()
98
95
99
-
// Use a mutable (modifiable) list! Always! You should be reusing the
100
-
// ChatRequest variable, so in order for a conversation to continue
101
-
// you need to be able to modify the list.
102
-
val messages:MutableList<ChatMessage> =ArrayList(listOf(prompt))
96
+
// Use a mutable (modifiable) list! Always! You should be reusing the
97
+
// ChatRequest variable, so in order for a conversation to continue
98
+
// you need to be able to modify the list.
99
+
val messages:MutableList<ChatMessage> =ArrayList(listOf(prompt))
103
100
104
-
// ChatRequest is the request we send to OpenAI API. You can modify the
105
-
// model, temperature, maxTokens, etc. This should be saved, so you can
106
-
// reuse it for a conversation.
107
-
val request =ChatRequest(model="gpt-3.5-turbo", messages=messages)
101
+
// ChatRequest is the request we send to OpenAI API. You can modify the
102
+
// model, temperature, maxTokens, etc. This should be saved, so you can
103
+
// reuse it for a conversation.
104
+
val request =ChatRequest(model="gpt-3.5-turbo", messages=messages)
108
105
109
-
// Loads the API key from the .env file in the root directory.
110
-
val key = dotenv()["OPENAI_TOKEN"]
111
-
val openai =OpenAI(key)
106
+
// Loads the API key from the .env file in the root directory.
107
+
val key = dotenv()["OPENAI_TOKEN"]
108
+
val openai =OpenAI(key)
112
109
113
-
// The conversation lasts until the user quits the program
114
-
while (true) {
110
+
// The conversation lasts until the user quits the program
111
+
while (true) {
115
112
116
-
// Prompt the user to enter a response
117
-
println("\n${YELLOW}Enter text below:\n")
118
-
val input = scan.nextLine()
113
+
// Prompt the user to enter a response
114
+
println("\n${YELLOW}Enter text below:\n")
115
+
val input = scan.nextLine()
119
116
120
-
// Add the newest user message to the conversation
0 commit comments