SimpleChat:JS: Handle difference in response
Try read the assistance response from appropriate field in the response got. Also examples/server seems to return the response in a slightly different field, so try account for that also.
This commit is contained in:
parent
3e5edbacd6
commit
aef32d9cc0
1 changed files with 10 additions and 1 deletions
|
@ -124,7 +124,16 @@ async function handle_submit(inputUser, divChat, apiEP) {
|
||||||
inputUser.disabled = false;
|
inputUser.disabled = false;
|
||||||
let respBody = await resp.json();
|
let respBody = await resp.json();
|
||||||
console.debug("DBUG:HandleSubmit:RespBody:", respBody);
|
console.debug("DBUG:HandleSubmit:RespBody:", respBody);
|
||||||
let assistantMsg = respBody["choices"][0]["message"]["content"];
|
let assistantMsg;
|
||||||
|
if (apiEP == ApiEP.Chat) {
|
||||||
|
assistantMsg = respBody["choices"][0]["message"]["content"];
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
assistantMsg = respBody["choices"][0]["text"];
|
||||||
|
} catch {
|
||||||
|
assistantMsg = respBody["content"];
|
||||||
|
}
|
||||||
|
}
|
||||||
gChat.add(Roles.Assistant, assistantMsg);
|
gChat.add(Roles.Assistant, assistantMsg);
|
||||||
gChat.show(divChat);
|
gChat.show(divChat);
|
||||||
inputUser.scrollIntoView(true);
|
inputUser.scrollIntoView(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue