feat (ai/core): Proposal for generate code API with tools #4196
+253
−15
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.
Proposal for generateCode API
Imagine the LLM can write Javascript code with custom logic within the help of limited tools inside a safe eval( )
Usage
Let me show you an example on how to build an AI powered banking app
Define a set of tools
Fun part begins here
This is the output after execution
await result.execute( )
This is the code written by LLM
result.code
This is the JSON schema written by LLM
result.schema
(useful for generative UI)Instead of multi-step toolResults, now LLM can write logic along with tools provided by developer. Also the LLM can't execute malicious code because of a safety simple technique i implemented in this.
Therefor this LLM is restricted to only invoke list of functions we provided to them.
The
generateCode( )
API is a powerful wrapper aroundgenerateText( )