Skip to content
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

TLK-2361 - Tools preamble extension #876

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

EugeneLightsOn
Copy link
Collaborator

@EugeneLightsOn EugeneLightsOn commented Dec 11, 2024

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:

  • src/backend/config/settings.py:
    • A new field use_tools_preamble is added to the ToolSettings class, with a default value of False.
  • src/backend/config/configuration.template.yaml:
    • The use_tools_preamble field is added with a value of true.
  • src/backend/chat/custom/custom.py:
    • The generate_tools_preamble function is imported from backend.services.chat.
    • A new conditional block is added to the call_chat function, which sets the chat_request.preamble using the generate_tools_preamble function if chat_request.tools is not empty and the tools.use_tools_preamble setting is enabled.
  • src/backend/services/chat.py:
    • A new function generate_tools_preamble is added, which constructs and returns a preamble string based on the available tools and the provided chat_request.
  • src/backend/tools/base.py:
    • A new class BaseToolPreambleRegistry is introduced to store default preamble values for tools.
    • The class provides methods to set and retrieve default preambles for tool classes.
    • The BaseTool class is updated to automatically set the TOOL_DEFAULT_PREAMBLE attribute for child classes using the BaseToolPreambleRegistry.
  • .env-template:
    • A new line USE_TOOLS_PREAMBLE=True is added to enable the use of the tools preamble.

@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 12 lines in your changes missing coverage. Please review.

Project coverage is 77.91%. Comparing base (839f258) to head (51412a5).

Files with missing lines Patch % Lines
src/backend/services/chat.py 9.09% 10 Missing ⚠️
src/backend/chat/custom/custom.py 75.00% 1 Missing ⚠️
src/backend/tools/base.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #876      +/-   ##
==========================================
- Coverage   77.97%   77.91%   -0.06%     
==========================================
  Files         259      259              
  Lines       11123    11150      +27     
==========================================
+ Hits         8673     8688      +15     
- Misses       2450     2462      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants