Skip to content

Commit bc33624

Browse files
committed
SimpleChat: Rename to apiRequestOptions from chatRequestOptions
So that it is not wrongly assumed that these request options are used only for chat/completions endpoint. Rather these are used for both the end points, so rename to match semantic better.
1 parent e4aeafc commit bc33624

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

examples/server/public_simplechat/readme.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,15 @@ It is attached to the document object. Some of these can also be updated using t
179179
The histogram/freq based trimming logic is currently tuned for english language wrt its
180180
is-it-a-alpabetic|numeral-char regex match logic.
181181

182-
chatRequestOptions - maintains the list of options/fields to send along with chat request,
182+
apiRequestOptions - maintains the list of options/fields to send along with api request,
183183
irrespective of whether /chat/completions or /completions endpoint.
184184

185185
If you want to add additional options/fields to send to the server/ai-model, and or
186186
modify the existing options value or remove them, for now you can update this global var
187187
using browser's development-tools/console.
188188

189-
For string, numeric and boolean fields in chatRequestOptions, including even those added by a
190-
user at runtime by directly modifying gMe.chatRequestOptions, setting ui entries will be auto
189+
For string, numeric and boolean fields in apiRequestOptions, including even those added by a
190+
user at runtime by directly modifying gMe.apiRequestOptions, setting ui entries will be auto
191191
created.
192192

193193
cache_prompt option supported by example/server is allowed to be controlled by user, so that
@@ -212,10 +212,10 @@ It is attached to the document object. Some of these can also be updated using t
212212
>0 : Send the latest chat history from the latest system prompt, limited to specified cnt.
213213

214214

215-
By using gMe's iRecentUserMsgCnt and chatRequestOptions.max_tokens one can try to control the
216-
implications of loading of the ai-model's context window by chat history, wrt chat response to
217-
some extent in a simple crude way. You may also want to control the context size enabled when
218-
the server loads ai-model, on the server end.
215+
By using gMe's iRecentUserMsgCnt and apiRequestOptions.max_tokens/n_predict one can try to control
216+
the implications of loading of the ai-model's context window by chat history, wrt chat response to
217+
some extent in a simple crude way. You may also want to control the context size enabled when the
218+
server loads ai-model, on the server end.
219219

220220

221221
Sometimes the browser may be stuborn with caching of the file, so your updates to html/css/js
@@ -252,12 +252,12 @@ also be started with a model context size of 1k or more, to be on safe side.
252252
internal n_predict, for now add the same here on the client side, maybe later add max_tokens
253253
to /completions endpoint handling code on server side.
254254

255-
NOTE: One may want to experiment with frequency/presence penalty fields in chatRequestOptions
256-
wrt the set of fields sent to server along with the user query. To check how the model behaves
255+
NOTE: One may want to experiment with frequency/presence penalty fields in apiRequestOptions
256+
wrt the set of fields sent to server along with the user query, to check how the model behaves
257257
wrt repeatations in general in the generated text response.
258258

259259
A end-user can change these behaviour by editing gMe from browser's devel-tool/console or by
260-
using the providing settings ui.
260+
using the provided settings ui (for settings exposed through the ui).
261261

262262

263263
### OpenAi / Equivalent API WebService
@@ -268,7 +268,7 @@ for a minimal chatting experimentation by setting the below.
268268
* the baseUrl in settings ui
269269
* https://api.openai.com/v1 or similar
270270

271-
* Wrt request body - gMe.chatRequestOptions
271+
* Wrt request body - gMe.apiRequestOptions
272272
* model (settings ui)
273273
* any additional fields if required in future
274274

examples/server/public_simplechat/simplechat.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ class SimpleChat {
222222
* @param {Object} obj
223223
*/
224224
request_jsonstr_extend(obj) {
225-
for(let k in gMe.chatRequestOptions) {
226-
obj[k] = gMe.chatRequestOptions[k];
225+
for(let k in gMe.apiRequestOptions) {
226+
obj[k] = gMe.apiRequestOptions[k];
227227
}
228228
if (gMe.bStream) {
229229
obj["stream"] = true;
@@ -740,7 +740,7 @@ class Me {
740740
"Authorization": "", // Authorization: Bearer OPENAI_API_KEY
741741
}
742742
// Add needed fields wrt json object to be sent wrt LLM web services completions endpoint.
743-
this.chatRequestOptions = {
743+
this.apiRequestOptions = {
744744
"model": "gpt-3.5-turbo",
745745
"temperature": 0.7,
746746
"max_tokens": 1024,
@@ -813,40 +813,40 @@ class Me {
813813

814814
}
815815

816-
ui.el_create_append_p(`chatRequestOptions:${JSON.stringify(this.chatRequestOptions, null, " - ")}`, elDiv);
816+
ui.el_create_append_p(`apiRequestOptions:${JSON.stringify(this.apiRequestOptions, null, " - ")}`, elDiv);
817817
ui.el_create_append_p(`headers:${JSON.stringify(this.headers, null, " - ")}`, elDiv);
818818

819819
}
820820

821821
/**
822-
* Auto create ui input elements for fields in ChatRequestOptions
822+
* Auto create ui input elements for fields in apiRequestOptions
823823
* Currently supports text and number field types.
824824
* @param {HTMLDivElement} elDiv
825825
*/
826-
show_settings_chatrequestoptions(elDiv) {
826+
show_settings_apirequestoptions(elDiv) {
827827
let typeDict = {
828828
"string": "text",
829829
"number": "number",
830830
};
831831
let fs = document.createElement("fieldset");
832832
let legend = document.createElement("legend");
833-
legend.innerText = "ChatRequestOptions";
833+
legend.innerText = "ApiRequestOptions";
834834
fs.appendChild(legend);
835835
elDiv.appendChild(fs);
836-
for(const k in this.chatRequestOptions) {
837-
let val = this.chatRequestOptions[k];
836+
for(const k in this.apiRequestOptions) {
837+
let val = this.apiRequestOptions[k];
838838
let type = typeof(val);
839839
if (((type == "string") || (type == "number"))) {
840-
let inp = ui.el_creatediv_input(`Set${k}`, k, typeDict[type], this.chatRequestOptions[k], (val)=>{
840+
let inp = ui.el_creatediv_input(`Set${k}`, k, typeDict[type], this.apiRequestOptions[k], (val)=>{
841841
if (type == "number") {
842842
val = Number(val);
843843
}
844-
this.chatRequestOptions[k] = val;
844+
this.apiRequestOptions[k] = val;
845845
});
846846
fs.appendChild(inp.div);
847847
} else if (type == "boolean") {
848848
let bbtn = ui.el_creatediv_boolbutton(`Set{k}`, k, {true: "true", false: "false"}, val, (userVal)=>{
849-
this.chatRequestOptions[k] = userVal;
849+
this.apiRequestOptions[k] = userVal;
850850
});
851851
fs.appendChild(bbtn.div);
852852
}
@@ -880,7 +880,7 @@ class Me {
880880
});
881881
elDiv.appendChild(bb.div);
882882

883-
this.show_settings_chatrequestoptions(elDiv);
883+
this.show_settings_apirequestoptions(elDiv);
884884

885885
let sel = ui.el_creatediv_select("SetApiEP", "ApiEndPoint", ApiEP.Type, this.apiEP, (val)=>{
886886
this.apiEP = ApiEP.Type[val];

0 commit comments

Comments
 (0)