From 7fdf6a78e19ad260dfdee07049b40ca86b0dc159 Mon Sep 17 00:00:00 2001 From: fustyles <34397289+fustyles@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:36:11 +0800 Subject: [PATCH] Update openAI.js --- openAI_20221212/openAI.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openAI_20221212/openAI.js b/openAI_20221212/openAI.js index 7326f5583f..1058ab5f34 100644 --- a/openAI_20221212/openAI.js +++ b/openAI_20221212/openAI.js @@ -24,6 +24,7 @@ let openai_response_chat = ""; let openai_response_chat_br = ""; let openai_response_chat_n = ""; let openai_response_chat_message = [{"role": "system", "content": openai_response_role}]; +let openai_vision_chat_message = []; function openai_text_initial(input_token, input_max_tokens) { openai_response_text_key = input_token; @@ -194,6 +195,7 @@ async function openai_chat_request(input_text) { char_message.role = "assistant"; char_message.content = json["choices"][0]["message"]["content"]; openai_response_chat_message.push(char_message); + openai_vision_chat_message.push(char_message); if (typeof openai_chat_response === 'function') openai_chat_response(); } @@ -218,6 +220,7 @@ async function openai_chat_request(input_text) { char_message.role = "user"; char_message.content = input_text; openai_response_chat_message.push(char_message); + openai_vision_chat_message.push(char_message); var data; data = { @@ -380,6 +383,7 @@ async function openai_chat_image_request(input_text, input_url) { char_message.role = "assistant"; char_message.content = json["choices"][0]["message"]["content"]; openai_response_chat_message.push(char_message); + openai_vision_chat_message.push(char_message); if (typeof openai_chat_response === 'function') openai_chat_response(); } @@ -397,13 +401,13 @@ async function openai_chat_image_request(input_text, input_url) { char_message.content.push(user_text); var user_url = {"type":"image_url", "image_url":{"url":input_url}}; char_message.content.push(user_url); - let openai_chat_message = []; - openai_chat_message.push(char_message); + openai_response_chat_message.push(char_message); + openai_vision_chat_message.push(char_message); var data; data = { "model": openai_response_chat_model, - "messages": openai_chat_message + "messages": openai_vision_chat_message }; xhr.send(JSON.stringify(data));