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.
|
||||
|
||||
* 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.
|
||||
|
||||
* 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
|
||||
|
||||
Open this simple web front end from your local browser
|
||||
|
|
@ -184,9 +189,13 @@ 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,
|
||||
leading to exception.
|
||||
|
||||
bTools - control whether tool calling is enabled or not
|
||||
tools - contains controls related to tool calling
|
||||
|
||||
remember to enable this only for GenAi/LLM models which support tool/function calling.
|
||||
enabled - control whether tool calling is enabled or not
|
||||
|
||||
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.
|
||||
|
||||
|
|
@ -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
|
||||
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.
|
||||
* 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.
|
||||
* The bundled simple proxy can be found at
|
||||
* tools/server/public_simplechat/local.tools/simpleproxy.py
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ class SimpleChat {
|
|||
if (gMe.bStream) {
|
||||
obj["stream"] = true;
|
||||
}
|
||||
if (gMe.bTools) {
|
||||
if (gMe.tools.enabled) {
|
||||
obj["tools"] = tools.meta();
|
||||
}
|
||||
return JSON.stringify(obj);
|
||||
|
|
@ -1016,7 +1016,10 @@ class Me {
|
|||
this.defaultChatIds = [ "Default", "Other" ];
|
||||
this.multiChat = new MultiChatUI();
|
||||
this.bStream = true;
|
||||
this.bTools = false;
|
||||
this.tools = {
|
||||
enabled: false,
|
||||
fetchProxyUrl: "http://127.0.0.1:3128"
|
||||
};
|
||||
this.bCompletionFreshChatAlways = true;
|
||||
this.bCompletionInsertStandardRolePrefix = false;
|
||||
this.bTrimGarbage = true;
|
||||
|
|
@ -1049,7 +1052,6 @@ class Me {
|
|||
//"frequency_penalty": 1.2,
|
||||
//"presence_penalty": 1.2,
|
||||
};
|
||||
this.toolFetchProxyUrl = "http://127.0.0.1:3128"
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1090,9 +1092,9 @@ class Me {
|
|||
* @param {boolean} bAll
|
||||
*/
|
||||
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) {
|
||||
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=>{
|
||||
this.modelInfo = {
|
||||
|
|
@ -1108,7 +1110,7 @@ class Me {
|
|||
* @param {HTMLDivElement} 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") {
|
||||
// @ts-ignore
|
||||
elProp.placeholder = "Bearer OPENAI_API_KEY";
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ let fetchweburlraw_meta = {
|
|||
function fetchweburlraw_run(toolcallid, toolname, obj) {
|
||||
if (gToolsWorker.onmessage != null) {
|
||||
// @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 => {
|
||||
if (!resp.ok) {
|
||||
throw new Error(`${resp.status}:${resp.statusText}`);
|
||||
|
|
@ -138,7 +138,7 @@ function fetchweburlraw_run(toolcallid, toolname, obj) {
|
|||
*/
|
||||
async function fetchweburlraw_setup(tcs) {
|
||||
// @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') {
|
||||
console.log("WARN:ToolJS:FetchWebUrlRaw:Dont forget to run the bundled local.tools/simpleproxy.py to enable me")
|
||||
return
|
||||
|
|
@ -190,7 +190,7 @@ let fetchweburltext_meta = {
|
|||
function fetchweburltext_run(toolcallid, toolname, obj) {
|
||||
if (gToolsWorker.onmessage != null) {
|
||||
// @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 => {
|
||||
if (!resp.ok) {
|
||||
throw new Error(`${resp.status}:${resp.statusText}`);
|
||||
|
|
@ -212,7 +212,7 @@ function fetchweburltext_run(toolcallid, toolname, obj) {
|
|||
*/
|
||||
async function fetchweburltext_setup(tcs) {
|
||||
// @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') {
|
||||
console.log("WARN:ToolJS:FetchWebUrlText:Dont forget to run the bundled local.tools/simpleproxy.py to enable me")
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue