-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(server): Add tool call support to WebUI (LLama Server) #13501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
samolego
wants to merge
26
commits into
ggml-org:master
Choose a base branch
from
samolego:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+982
−113
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
acd4767
feat(server): add basic js tool call support
samolego 6236918
code abstraction for tool calling
samolego e84e819
minor changes, renames
samolego f6b1386
add tool call fields
samolego f2175cb
fix: Use structured `tool_calls` for tool handling
samolego 4698b66
fix: forward tool call info back to api
samolego 69e7119
provide tool call response in a dropdown
samolego 75fd25e
Fix UI updates after tool call chains
samolego ae32a9a
move js evaluation to sandboxed iframe, remove debug logs
samolego 00d911d
merge assistant messages on tool use
samolego d99808f
feat: populate settings tool calling section
samolego 0b34d53
feat: add stream response setting
samolego 0480054
fix: revert base url
samolego 7fa0043
Merge remote-tracking branch 'upstream/master' into feat/tool-calling
samolego b128ca5
fix: readd missing comments
samolego c203815
fix: more cleanup
samolego cf110f9
minor changes
samolego 4e7da1b
Delete deno.lock
samolego 031e673
Update tools/server/webui/package.json
samolego c9ec6fa
fix: remove unused type, do not add tool calls in user messages
samolego 3f76cac
feat: support streaming tool calls
samolego c98baef
bugfixes for streaming calls
samolego 22a951b
fix demo conversation import
samolego 798946e
fix: make chained message regeneratable
samolego 92f8bb0
updates to config and available tools map
samolego 5c898ec
better handling of logged variables in js repl
samolego File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>JS Sandbox</title> | ||
<script> | ||
// Capture console.log output within the iframe | ||
const iframeConsole = { | ||
_buffer: [], | ||
log: function (...args) { | ||
this._buffer.push(args.map(JSON.stringify).join(' ')); | ||
}, | ||
getOutput: function () { | ||
const output = this._buffer.join('\n'); | ||
this._buffer = []; | ||
return output; | ||
}, | ||
clear: function () { | ||
this._buffer = []; | ||
}, | ||
}; | ||
// Redirect the iframe's console.log | ||
console.log = iframeConsole.log.bind(iframeConsole); | ||
|
||
window.addEventListener('message', (event) => { | ||
if (!event.data || !event.source || !event.source.postMessage) { | ||
return; | ||
} | ||
|
||
if (event.data.command === 'executeCode') { | ||
const { code, call_id } = event.data; | ||
let result = ''; | ||
let error = null; | ||
iframeConsole.clear(); | ||
|
||
try { | ||
result = eval(code); | ||
if (result !== undefined && result !== null) { | ||
try { | ||
result = JSON.stringify(result, null, 2); | ||
} catch (e) { | ||
result = String(result); | ||
} | ||
} else { | ||
result = ''; | ||
} | ||
} catch (e) { | ||
error = e.message || String(e); | ||
} | ||
|
||
const consoleOutput = iframeConsole.getOutput(); | ||
const finalOutput = consoleOutput | ||
? consoleOutput + (result && consoleOutput ? '\n' : '') + result | ||
: result; | ||
|
||
event.source.postMessage( | ||
{ | ||
call_id: call_id, | ||
output: finalOutput, | ||
error: error, | ||
}, | ||
event.origin === 'null' ? '*' : event.origin | ||
); | ||
} | ||
}); | ||
|
||
if (window.parent && window.parent !== window) { | ||
window.parent.postMessage( | ||
{ command: 'iframeReady', call_id: 'initial_ready' }, | ||
'*' | ||
); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<p>JavaScript Execution Sandbox</p> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.