SimpleChatTC:Cleanup: Move bTools and toolFetchProxyUrl into tools
Also update the readme wrt same and related
This commit is contained in:
parent
303af1800e
commit
3e490cefc5
|
|
@ -74,10 +74,15 @@ remember to
|
||||||
|
|
||||||
* pass --jinja to llama-server to enable tool calling support from the server ai engine end.
|
* pass --jinja to llama-server to enable tool calling support from the server ai engine end.
|
||||||
|
|
||||||
* enable bTools in the settings page of the client side gui.
|
* set tools.enabled to true in the settings page of the client side gui.
|
||||||
|
|
||||||
* use a GenAi/LLM model which supports tool calling.
|
* use a GenAi/LLM model which supports tool calling.
|
||||||
|
|
||||||
|
* if fetch web url / page tool call is needed, remember to run the bundled local.tools/simpleproxy.py helper
|
||||||
|
|
||||||
|
* remember that this is a relatively dumb proxy logic along with optional stripping of scripts/styles/headers/footers/...,
|
||||||
|
Be careful if trying to fetch web pages, and use it only with known safe sites.
|
||||||
|
|
||||||
### using the front end
|
### using the front end
|
||||||
|
|
||||||
Open this simple web front end from your local browser
|
Open this simple web front end from your local browser
|
||||||
|
|
@ -184,10 +189,14 @@ It is attached to the document object. Some of these can also be updated using t
|
||||||
inturn the machine goes into power saving mode or so, the platform may stop network connection,
|
inturn the machine goes into power saving mode or so, the platform may stop network connection,
|
||||||
leading to exception.
|
leading to exception.
|
||||||
|
|
||||||
bTools - control whether tool calling is enabled or not
|
tools - contains controls related to tool calling
|
||||||
|
|
||||||
|
enabled - control whether tool calling is enabled or not
|
||||||
|
|
||||||
remember to enable this only for GenAi/LLM models which support tool/function calling.
|
remember to enable this only for GenAi/LLM models which support tool/function calling.
|
||||||
|
|
||||||
|
fetchProxyUrl - specify the address for the running instance of bundled local.tools/simpleproxy.py
|
||||||
|
|
||||||
the builtin tools' meta data is sent to the ai model in the requests sent to it.
|
the builtin tools' meta data is sent to the ai model in the requests sent to it.
|
||||||
|
|
||||||
inturn if the ai model requests a tool call to be made, the same will be done and the response
|
inturn if the ai model requests a tool call to be made, the same will be done and the response
|
||||||
|
|
@ -351,7 +360,7 @@ browser js runtime environment. Depending on the path specified wrt the proxy se
|
||||||
(and not urlraw), it additionally tries to convert html content into equivalent text to some extent
|
(and not urlraw), it additionally tries to convert html content into equivalent text to some extent
|
||||||
in a simple minded manner by dropping head block as well as all scripts/styles/footers/headers/nav.
|
in a simple minded manner by dropping head block as well as all scripts/styles/footers/headers/nav.
|
||||||
May add support for white list of allowed sites to access or so.
|
May add support for white list of allowed sites to access or so.
|
||||||
* the logic does a simple check to see if the bundled simpleproxy is running at specified proxyUrl
|
* the logic does a simple check to see if the bundled simpleproxy is running at specified fetchProxyUrl
|
||||||
before enabling fetch web related tool calls.
|
before enabling fetch web related tool calls.
|
||||||
* The bundled simple proxy can be found at
|
* The bundled simple proxy can be found at
|
||||||
* tools/server/public_simplechat/local.tools/simpleproxy.py
|
* tools/server/public_simplechat/local.tools/simpleproxy.py
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,7 @@ class SimpleChat {
|
||||||
if (gMe.bStream) {
|
if (gMe.bStream) {
|
||||||
obj["stream"] = true;
|
obj["stream"] = true;
|
||||||
}
|
}
|
||||||
if (gMe.bTools) {
|
if (gMe.tools.enabled) {
|
||||||
obj["tools"] = tools.meta();
|
obj["tools"] = tools.meta();
|
||||||
}
|
}
|
||||||
return JSON.stringify(obj);
|
return JSON.stringify(obj);
|
||||||
|
|
@ -1016,7 +1016,10 @@ class Me {
|
||||||
this.defaultChatIds = [ "Default", "Other" ];
|
this.defaultChatIds = [ "Default", "Other" ];
|
||||||
this.multiChat = new MultiChatUI();
|
this.multiChat = new MultiChatUI();
|
||||||
this.bStream = true;
|
this.bStream = true;
|
||||||
this.bTools = false;
|
this.tools = {
|
||||||
|
enabled: false,
|
||||||
|
fetchProxyUrl: "http://127.0.0.1:3128"
|
||||||
|
};
|
||||||
this.bCompletionFreshChatAlways = true;
|
this.bCompletionFreshChatAlways = true;
|
||||||
this.bCompletionInsertStandardRolePrefix = false;
|
this.bCompletionInsertStandardRolePrefix = false;
|
||||||
this.bTrimGarbage = true;
|
this.bTrimGarbage = true;
|
||||||
|
|
@ -1049,7 +1052,6 @@ class Me {
|
||||||
//"frequency_penalty": 1.2,
|
//"frequency_penalty": 1.2,
|
||||||
//"presence_penalty": 1.2,
|
//"presence_penalty": 1.2,
|
||||||
};
|
};
|
||||||
this.toolFetchProxyUrl = "http://127.0.0.1:3128"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1090,9 +1092,9 @@ class Me {
|
||||||
* @param {boolean} bAll
|
* @param {boolean} bAll
|
||||||
*/
|
*/
|
||||||
show_info(elDiv, bAll=false) {
|
show_info(elDiv, bAll=false) {
|
||||||
let props = ["baseURL", "modelInfo","headers", "bStream", "bTools", "apiRequestOptions", "apiEP", "iRecentUserMsgCnt", "toolFetchProxyUrl", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"];
|
let props = ["baseURL", "modelInfo","headers", "bStream", "tools", "apiRequestOptions", "apiEP", "iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"];
|
||||||
if (!bAll) {
|
if (!bAll) {
|
||||||
props = [ "baseURL", "modelInfo", "headers", "bStream", "bTools", "apiRequestOptions", "apiEP", "iRecentUserMsgCnt" ];
|
props = [ "baseURL", "modelInfo", "headers", "bStream", "tools", "apiRequestOptions", "apiEP", "iRecentUserMsgCnt" ];
|
||||||
}
|
}
|
||||||
fetch(`${this.baseURL}/props`).then(resp=>resp.json()).then(json=>{
|
fetch(`${this.baseURL}/props`).then(resp=>resp.json()).then(json=>{
|
||||||
this.modelInfo = {
|
this.modelInfo = {
|
||||||
|
|
@ -1108,7 +1110,7 @@ class Me {
|
||||||
* @param {HTMLDivElement} elDiv
|
* @param {HTMLDivElement} elDiv
|
||||||
*/
|
*/
|
||||||
show_settings(elDiv) {
|
show_settings(elDiv) {
|
||||||
ui.ui_show_obj_props_edit(elDiv, this, ["baseURL", "headers", "bStream", "bTools", "apiRequestOptions", "TRAPME-apiEP", "TRAPME-iRecentUserMsgCnt", "toolFetchProxyUrl", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"], "Settings", (prop, elProp)=>{
|
ui.ui_show_obj_props_edit(elDiv, this, ["baseURL", "headers", "bStream", "tools", "apiRequestOptions", "TRAPME-apiEP", "TRAPME-iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"], "Settings", (prop, elProp)=>{
|
||||||
if (prop == "headers:Authorization") {
|
if (prop == "headers:Authorization") {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
elProp.placeholder = "Bearer OPENAI_API_KEY";
|
elProp.placeholder = "Bearer OPENAI_API_KEY";
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ let fetchweburlraw_meta = {
|
||||||
function fetchweburlraw_run(toolcallid, toolname, obj) {
|
function fetchweburlraw_run(toolcallid, toolname, obj) {
|
||||||
if (gToolsWorker.onmessage != null) {
|
if (gToolsWorker.onmessage != null) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let newUrl = `${document['gMe'].toolFetchProxyUrl}/urlraw?url=${encodeURIComponent(obj.url)}`
|
let newUrl = `${document['gMe'].tools.fetchProxyUrl}/urlraw?url=${encodeURIComponent(obj.url)}`
|
||||||
fetch(newUrl).then(resp => {
|
fetch(newUrl).then(resp => {
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
throw new Error(`${resp.status}:${resp.statusText}`);
|
throw new Error(`${resp.status}:${resp.statusText}`);
|
||||||
|
|
@ -138,7 +138,7 @@ function fetchweburlraw_run(toolcallid, toolname, obj) {
|
||||||
*/
|
*/
|
||||||
async function fetchweburlraw_setup(tcs) {
|
async function fetchweburlraw_setup(tcs) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let got = await fetch(`${document["gMe"].toolFetchProxyUrl}/aum?url=jambudweepe.multiverse.987654321123456789`).then(resp=>{
|
let got = await fetch(`${document["gMe"].tools.fetchProxyUrl}/aum?url=jambudweepe.multiverse.987654321123456789`).then(resp=>{
|
||||||
if (resp.statusText != 'bharatavarshe') {
|
if (resp.statusText != 'bharatavarshe') {
|
||||||
console.log("WARN:ToolJS:FetchWebUrlRaw:Dont forget to run the bundled local.tools/simpleproxy.py to enable me")
|
console.log("WARN:ToolJS:FetchWebUrlRaw:Dont forget to run the bundled local.tools/simpleproxy.py to enable me")
|
||||||
return
|
return
|
||||||
|
|
@ -190,7 +190,7 @@ let fetchweburltext_meta = {
|
||||||
function fetchweburltext_run(toolcallid, toolname, obj) {
|
function fetchweburltext_run(toolcallid, toolname, obj) {
|
||||||
if (gToolsWorker.onmessage != null) {
|
if (gToolsWorker.onmessage != null) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let newUrl = `${document['gMe'].toolFetchProxyUrl}/urltext?url=${encodeURIComponent(obj.url)}`
|
let newUrl = `${document['gMe'].tools.fetchProxyUrl}/urltext?url=${encodeURIComponent(obj.url)}`
|
||||||
fetch(newUrl).then(resp => {
|
fetch(newUrl).then(resp => {
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
throw new Error(`${resp.status}:${resp.statusText}`);
|
throw new Error(`${resp.status}:${resp.statusText}`);
|
||||||
|
|
@ -212,7 +212,7 @@ function fetchweburltext_run(toolcallid, toolname, obj) {
|
||||||
*/
|
*/
|
||||||
async function fetchweburltext_setup(tcs) {
|
async function fetchweburltext_setup(tcs) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let got = await fetch(`${document["gMe"].toolFetchProxyUrl}/aum?url=jambudweepe.akashaganga.multiverse.987654321123456789`).then(resp=>{
|
let got = await fetch(`${document["gMe"].tools.fetchProxyUrl}/aum?url=jambudweepe.akashaganga.multiverse.987654321123456789`).then(resp=>{
|
||||||
if (resp.statusText != 'bharatavarshe') {
|
if (resp.statusText != 'bharatavarshe') {
|
||||||
console.log("WARN:ToolJS:FetchWebUrlText:Dont forget to run the bundled local.tools/simpleproxy.py to enable me")
|
console.log("WARN:ToolJS:FetchWebUrlText:Dont forget to run the bundled local.tools/simpleproxy.py to enable me")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue