SimpleChat: Move request headers into Me and gMe
Inturn allow Authorization to be sent, if not empty.
This commit is contained in:
parent
f54e000039
commit
dce4e6a64b
1 changed files with 18 additions and 3 deletions
|
@ -164,6 +164,18 @@ class SimpleChat {
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetch_headers(apiEP) {
|
||||||
|
let headers = new Headers();
|
||||||
|
for(let k in gMe.headers) {
|
||||||
|
let v = gMe.headers[k];
|
||||||
|
if ((k == "Authorization") && (v.trim() == "")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
headers[k] = v;
|
||||||
|
}
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add needed fields wrt json object to be sent wrt LLM web services completions endpoint.
|
* Add needed fields wrt json object to be sent wrt LLM web services completions endpoint.
|
||||||
* The needed fields/options are picked from a global object.
|
* The needed fields/options are picked from a global object.
|
||||||
|
@ -559,11 +571,10 @@ class MultiChatUI {
|
||||||
this.elInUser.value = "working...";
|
this.elInUser.value = "working...";
|
||||||
this.elInUser.disabled = true;
|
this.elInUser.disabled = true;
|
||||||
console.debug(`DBUG:SimpleChat:MCUI:${chatId}:HandleUserSubmit:${theUrl}:ReqBody:${theBody}`);
|
console.debug(`DBUG:SimpleChat:MCUI:${chatId}:HandleUserSubmit:${theUrl}:ReqBody:${theBody}`);
|
||||||
|
let theHeaders = chat.fetch_headers(apiEP);
|
||||||
let resp = await fetch(theUrl, {
|
let resp = await fetch(theUrl, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: theHeaders,
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: theBody,
|
body: theBody,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -676,6 +687,10 @@ class Me {
|
||||||
"Last4": 5,
|
"Last4": 5,
|
||||||
};
|
};
|
||||||
this.apiEP = ApiEP.Type.Chat;
|
this.apiEP = ApiEP.Type.Chat;
|
||||||
|
this.headers = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "", // Authorization: Bearer OPENAI_API_KEY
|
||||||
|
}
|
||||||
// Add needed fields wrt json object to be sent wrt LLM web services completions endpoint.
|
// Add needed fields wrt json object to be sent wrt LLM web services completions endpoint.
|
||||||
this.chatRequestOptions = {
|
this.chatRequestOptions = {
|
||||||
"temperature": 0.7,
|
"temperature": 0.7,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue