Skip to content

Commit

Permalink
Update openAI.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fustyles authored Dec 24, 2024
1 parent 8ebd278 commit 7fdf6a7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions openAI_20221212/openAI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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 = {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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));
Expand Down

0 comments on commit 7fdf6a7

Please sign in to comment.