File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -253,7 +253,35 @@ const mount = async (
253253 socket . emit ( 'addingTool' ) ;
254254
255255 const loaded = await gptscript . loadTools ( script , true ) ;
256- const newTools = toChatStateTools ( loaded ?. program ?. toolSet ) ;
256+
257+ // We need to filter out credential tools so that we do not give them to the LLM.
258+ // TODO - also filter out context tools maybe?
259+ const toolSet = { } ;
260+ const credentials = new Set ( ) ;
261+ for ( tool of Object . values ( loaded ?. program ?. toolSet ) ) {
262+ if ( tool . credentials ) {
263+ for ( let cred of tool . credentials ) {
264+ for ( let mapping of tool . toolMapping [ cred ] ) {
265+ credentials . add ( mapping . toolID ) ;
266+ }
267+ }
268+ }
269+ if ( tool [ 'exportCredentials' ] ) {
270+ for ( let cred of tool [ 'exportCredentials' ] ) {
271+ for ( let mapping of tool . toolMapping [ cred ] ) {
272+ credentials . add ( mapping . toolID ) ;
273+ }
274+ }
275+ }
276+ }
277+
278+ for ( let [ key , value ] of Object . entries ( loaded ?. program ?. toolSet ) ) {
279+ if ( ! credentials . has ( key ) ) {
280+ toolSet [ key ] = value ;
281+ }
282+ }
283+
284+ const newTools = toChatStateTools ( toolSet ) ;
257285 const currentState = JSON . parse ( state . chatState ) ;
258286 currentState . continuation . state . completion . tools = newTools ;
259287
You can’t perform that action at this time.
0 commit comments