Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Conversation

@chr-hertel
Copy link
Member

Closes #168

@chr-hertel
Copy link
Member Author

chr-hertel commented Jan 4, 2025

Tests currently failing since i moved tool result conversion into the chain processor, but would that be a way to go for you @OskarStark ?

final class SpecificToolCallSubscriber implement EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            ToolCallExecuted::class => 'handleToolCall',
        ];
    }

    public function handleToolCall(ToolCallExecuted $event): void
    {
        foreach ($event->toolCallResults as $toolCallResult) {
            if ('xyz' === $toolCallResult->toolCall->name) {
                $event->response = new StructuredResponse($toolCallResult->result);
            }
        }
    }
}

See example:
https://github.com/php-llm/llm-chain/blob/f096dba8e5b049ef4fa4363ade2af31c26e86568/examples/toolbox-weather-event.php#L26-L47

@OskarStark
Copy link
Contributor

Uhhhhhhh that looks nice 😍 will have a detailed look when on my Mac 💻👍🏻

Thanks for taking time

@chr-hertel chr-hertel force-pushed the feat-toolcall-event branch from f096dba to 9a5330e Compare January 4, 2025 17:13
Comment on lines 36 to 37
Copy link
Contributor

Choose a reason for hiding this comment

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

The event name is singular and then you iterate over all toolCallResults (plural), that feels weird. Shouldn't we throw an event for every ToolCall which was executed?

Otherwise rename it to ToolCallsExecuted?

Or am I missing sth.?

Copy link
Member Author

Choose a reason for hiding this comment

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

you're right. should be plural

@OskarStark
Copy link
Contributor

I like it 👍 Looks like I can achieve my goals with it 🕺

@OskarStark OskarStark added the enhancement New feature or request label Jan 4, 2025
@chr-hertel chr-hertel force-pushed the feat-toolcall-event branch from 9a5330e to 4413820 Compare January 5, 2025 13:37
@chr-hertel chr-hertel force-pushed the feat-toolcall-event branch from 4413820 to 30e1ff7 Compare January 5, 2025 13:40
@chr-hertel chr-hertel merged commit fc8db39 into main Jan 5, 2025
7 checks passed
@chr-hertel chr-hertel deleted the feat-toolcall-event branch January 5, 2025 14:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let the tool decide if the chain should be called again with the return value

3 participants