[KYUUBI #4810] [CHAT] Request and use a sginle choice for chat completion
### _Why are the changes needed?_ - explicitly set `n` to 1 in ChatGPT chat completion request (default to 1, https://platform.openai.com/docs/api-reference/chat/create#chat/create-n) - use the only one choice of the chat completion response ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request Closes #4810 from bowenliang123/chat-onechoice. Closes #4810 f221de4e8 [bowenliang] one message Authored-by: bowenliang <bowenliang@apache.org> Signed-off-by: bowenliang <bowenliang@apache.org>
This commit is contained in:
parent
7225f338f6
commit
e112e381ff
@ -83,9 +83,10 @@ class ChatGPTProvider(conf: KyuubiConf) extends ChatProvider {
|
||||
.model(conf.get(KyuubiConf.ENGINE_CHAT_GPT_MODEL))
|
||||
.messages(messages.asScala.toList.asJava)
|
||||
.user(sessionUser.orNull)
|
||||
.n(1)
|
||||
.build()
|
||||
val responseText = openAiService.createChatCompletion(completionRequest).getChoices.asScala
|
||||
.map(c => c.getMessage.getContent).mkString
|
||||
val responseText = openAiService.createChatCompletion(completionRequest)
|
||||
.getChoices.get(0).getMessage.getContent
|
||||
responseText
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user