Skip to content

Conversation

@atdrendel
Copy link
Contributor

  • Support Python-formatted tool calls from LFM2-8B-A1B
  • Expose Python.parseFunctionCall
  • Add tools parameter to LLM.init() and convenience factory methods

Copilot AI review requested due to automatic review settings October 21, 2025 17:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for Python-formatted tool calls from the LFM2-8B-A1B model by introducing a custom response parser that handles Python-style function call syntax. The implementation includes a new Python.parseFunctionCall method for parsing tool invocations and exposes a tools parameter across all LLM factory methods.

Key changes:

  • Implemented Python-style function call parser with comprehensive test coverage
  • Added LFM2-specific response parser with streaming tool call support
  • Extended all LLM factory methods to accept a tools parameter

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/SHLLMTests/PythonTests.swift Comprehensive tests for Python function call parsing covering edge cases like quotes, escapes, and incremental parsing
Tests/SHLLMTests/Models/LFM2-8B-A1BTests.swift Integration tests validating LFM2 tool calling with weather, stock, and news tools
Tests/SHLLMTests/Models/GPTOSS-20BTests.swift Removed assertion checking for "alex" in response
Tests/SHLLMTests/LFM2ParserTests.swift Unit tests for LFM2 response parser handling tool call tokens and streaming
Tests/SHLLMTests/Helpers.swift Enhanced web search tool description
Sources/SHLLM/SHLLM.swift Exported ToolSpec typealias
Sources/SHLLM/ResponseParser.swift Implemented LFM2 response parser with Python-style tool call handling
Sources/SHLLM/Python.swift Core Python function call parser implementation
Sources/SHLLM/LLM.swift Added tools parameter to all factory methods and updated initialization logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@atdrendel atdrendel merged commit 3e10cf5 into main Oct 22, 2025
1 check passed
@atdrendel atdrendel deleted the parse-lfm-tool-call branch October 22, 2025 01:08
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