julep icon indicating copy to clipboard operation
julep copied to clipboard

feat: Add system tool calls to the chat endpoint

Open whiterabbit1983 opened this issue 9 months ago • 5 comments
trafficstars

User description

Closes #1285


EntelligenceAI PR Summary

The recent update introduces a new utility function, eval_tool_calls, in tools.py to enhance the evaluation of tool calls within chat sessions. The chat function in chat.py has been updated to utilize this utility, replacing direct calls to litellm.acompletion. This change aims to improve code modularity and streamline the integration of tool responses in chat sessions.


PR Type

Enhancement, Tests


Description

  • Introduced tool_calls_evaluator to streamline tool call handling in chat sessions.

  • Added a new utility function call_tool for executing system tool calls.

  • Implemented extensive unit tests for tool_calls_evaluator and call_tool.

  • Enhanced modularity and maintainability of the chat endpoint.


Changes walkthrough 📝

Relevant files
Enhancement
chat.py
Refactor chat endpoint to use tool evaluator                         

agents-api/agents_api/routers/sessions/chat.py

  • Integrated tool_calls_evaluator into the chat function.
  • Replaced direct litellm.acompletion calls with evaluated tool calls.
  • Enhanced modularity by delegating tool call handling.
  • +7/-1     
    tools.py
    Introduce tool call evaluation utilities                                 

    agents-api/agents_api/routers/utils/tools.py

  • Added tool_calls_evaluator decorator for tool call evaluation.
  • Implemented call_tool function to handle system tool calls.
  • Defined _system_tool_handlers mapping for tool-specific logic.
  • Added utility functions for search request creation and tool handling.
  • +268/-0 
    Tests
    test_tool_calls_evaluator.py
    Add unit tests for tool evaluation utilities                         

    agents-api/tests/test_tool_calls_evaluator.py

  • Added unit tests for call_tool covering various tool operations.
  • Tested tool_calls_evaluator for correct tool call handling.
  • Included edge cases like unknown tools and non-matching tool types.
  • Verified iterative tool call evaluation until completion.
  • +524/-0 

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.

  • [!IMPORTANT] Refactor chat endpoint to use tool_calls_evaluator for tool call handling, enhancing modularity and adding extensive tests.

    • Behavior:
      • Refactor chat() in chat.py to use tool_calls_evaluator for handling tool calls, replacing direct litellm.acompletion calls.
      • Introduce call_tool in tools.py for executing system tool calls.
    • Utilities:
      • Add tool_calls_evaluator decorator in tools.py for tool call evaluation.
      • Define _system_tool_handlers mapping in tools.py for tool-specific logic.
    • Tests:
      • Add test_tool_calls_evaluator.py with unit tests for tool_calls_evaluator and call_tool.
      • Cover various tool operations and edge cases like unknown tools.
    • Misc:
      • Add utility functions for search request creation in tools.py.

    This description was created by Ellipsis for ebd3769ebebdd0d2aa05af0eba020399b93c0e25. It will automatically update as commits are pushed.

    whiterabbit1983 avatar Feb 20 '25 14:02 whiterabbit1983