feat: WatsonXChatGenerator - support Tools and use the StreamingChunk fields#2902
Conversation
anakin87
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
I think that a little more adaptation work will be needed, especially in handling tool calls.
I suggest taking inspiration from #2078 and #2108 (but keeping in mind that each provider has its own particularities and code can be very different).
Also, I'd like to see a test with real chunks coming from WatsonX (similar test for Google GenAI).
Okay, I'll convert it to a draft for now and work on it a bit more to add support for tool calls as well as more tests. I'll let you know when it's ready. |
|
Hi @anakin87, this PR should now be ready to be reviewed. I have added a bunch of tests for tool calling (mirroring the Google Gen AI integration) as well as a test that converts real chunks I got from making requests to Watsonx.ai. |
anakin87
left a comment
There was a problem hiding this comment.
Thank you!
Left two initial comments
anakin87
left a comment
There was a problem hiding this comment.
Tests are not running on PRs from forks but when I run hatch run test:integration locally, I get 4 tests failing:
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_toolset - assert '{\n "city": "Paris"\n}' == {'city': 'Paris'}
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_tools_streaming - assert '{\n "city": "Paris"\n}' == {'city': 'Paris'}
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_mixed_tools - AssertionError: Expected 2 tool calls, got 1
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_async_with_tools - assert '{\n "city": "Paris"\n}' == {'city': 'Paris'}
Could you please investigate?
Thanks for spotting this, I was running my local tests using an IBM EU cloud account so had changed the endpoint as well as the model as less models are supported on the EU cloud when running the tests. I have now updated the tool call parsing to better handle output from the default model. |
WatsonXChatGenerator to use the StreamingChunk fieldsWatsonXChatGenerator - support Tools and use the StreamingChunk fields
Related Issues
WatsonXChatGeneratorto use theStreamingChunkfields #2217 & feat: Update our ChatGenerators in integrations to use the new StreamingChunk fields #2070Proposed Changes:
feat: Update
WatsonXChatGeneratorto use theStreamingChunkindexandfinish_reasonfields.How did you test it?
Updated existing tests.
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.