langchain
langchain copied to clipboard
community: set default `output_token_limit` value for `PowerBIToolkit` to fix validation error
Description:
This PR sets a default value of output_token_limit = 4000
for the PowerBIToolkit
to fix the unintentionally validation error.
Problem:
When attempting to run a code snippet from Langchain's PowerBI toolkit documentation to interact with a PowerBIDataset
, the following error occurs:
pydantic.v1.error_wrappers.ValidationError: 1 validation error for QueryPowerBITool
output_token_limit
none is not an allowed value (type=type_error.none.not_allowed)
Root Cause:
The issue arises because when creating a QueryPowerBITool
, the output_token_limit
parameter is unintentionally set to None
, which is the current default for PowerBIToolkit
. However, QueryPowerBITool
expects a default value of 4000
for output_token_limit
. This unintended override causes the error.
https://github.com/langchain-ai/langchain/blob/17659ca2cdc418436edf2f8c7f50e800dbbf31ca/libs/community/langchain_community/agent_toolkits/powerbi/toolkit.py#L63 https://github.com/langchain-ai/langchain/blob/17659ca2cdc418436edf2f8c7f50e800dbbf31ca/libs/community/langchain_community/agent_toolkits/powerbi/toolkit.py#L72-L79 https://github.com/langchain-ai/langchain/blob/17659ca2cdc418436edf2f8c7f50e800dbbf31ca/libs/community/langchain_community/tools/powerbi/tool.py#L39
Solution:
To resolve this, the default value of output_token_limit
is now explicitly set to 4000
in PowerBIToolkit
to prevent the accidental assignment of None
.