TLK-2361 - Tools preamble extension #876
Open
+73
−3
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.
Improving chat responses using preambles
AI Description
This PR introduces a new feature called
USE_TOOLS_PREAMBLE
to enhance the model's tool usage. It involves several changes across multiple files:use_tools_preamble
is added to theToolSettings
class, with a default value ofFalse
.use_tools_preamble
field is added with a value oftrue
.generate_tools_preamble
function is imported frombackend.services.chat
.call_chat
function, which sets thechat_request.preamble
using thegenerate_tools_preamble
function ifchat_request.tools
is not empty and thetools.use_tools_preamble
setting is enabled.generate_tools_preamble
is added, which constructs and returns a preamble string based on the available tools and the providedchat_request
.BaseToolPreambleRegistry
is introduced to store default preamble values for tools.BaseTool
class is updated to automatically set theTOOL_DEFAULT_PREAMBLE
attribute for child classes using theBaseToolPreambleRegistry
.USE_TOOLS_PREAMBLE=True
is added to enable the use of the tools preamble.