kensho-kfinance 3.2.4__py3-none-any.whl → 3.2.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kensho-kfinance might be problematic. Click here for more details.
- {kensho_kfinance-3.2.4.dist-info → kensho_kfinance-3.2.6.dist-info}/METADATA +1 -1
- {kensho_kfinance-3.2.4.dist-info → kensho_kfinance-3.2.6.dist-info}/RECORD +43 -43
- kfinance/CHANGELOG.md +6 -0
- kfinance/client/fetch.py +7 -5
- kfinance/client/kfinance.py +38 -39
- kfinance/client/models/date_and_period_models.py +8 -7
- kfinance/client/tests/test_fetch.py +3 -1
- kfinance/client/tests/test_objects.py +38 -95
- kfinance/domains/business_relationships/business_relationship_tools.py +4 -4
- kfinance/domains/business_relationships/tests/test_business_relationship_tools.py +18 -16
- kfinance/domains/capitalizations/capitalization_models.py +3 -3
- kfinance/domains/capitalizations/capitalization_tools.py +7 -5
- kfinance/domains/capitalizations/tests/test_capitalization_tools.py +46 -36
- kfinance/domains/companies/company_tools.py +8 -12
- kfinance/domains/companies/tests/test_company_tools.py +21 -9
- kfinance/domains/competitors/competitor_tools.py +2 -3
- kfinance/domains/competitors/tests/test_competitor_tools.py +22 -19
- kfinance/domains/cusip_and_isin/cusip_and_isin_tools.py +4 -6
- kfinance/domains/cusip_and_isin/tests/test_cusip_and_isin_tools.py +13 -8
- kfinance/domains/earnings/earning_tools.py +12 -9
- kfinance/domains/earnings/tests/test_earnings_tools.py +52 -43
- kfinance/domains/line_items/line_item_models.py +121 -0
- kfinance/domains/line_items/line_item_tools.py +2 -3
- kfinance/domains/line_items/tests/test_line_item_tools.py +20 -23
- kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_models.py +46 -2
- kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_tools.py +13 -68
- kfinance/domains/mergers_and_acquisitions/tests/test_merger_and_acquisition_tools.py +61 -59
- kfinance/domains/prices/price_tools.py +4 -7
- kfinance/domains/prices/tests/test_price_tools.py +47 -39
- kfinance/domains/segments/segment_tools.py +2 -3
- kfinance/domains/segments/tests/test_segment_tools.py +16 -11
- kfinance/domains/statements/statement_tools.py +2 -3
- kfinance/domains/statements/tests/test_statement_tools.py +40 -35
- kfinance/integrations/tool_calling/static_tools/get_n_quarters_ago.py +5 -0
- kfinance/integrations/tool_calling/static_tools/tests/test_get_lastest.py +13 -10
- kfinance/integrations/tool_calling/static_tools/tests/test_get_n_quarters_ago.py +2 -1
- kfinance/integrations/tool_calling/tests/test_tool_calling_models.py +8 -2
- kfinance/integrations/tool_calling/tool_calling_models.py +11 -5
- kfinance/version.py +2 -2
- {kensho_kfinance-3.2.4.dist-info → kensho_kfinance-3.2.6.dist-info}/WHEEL +0 -0
- {kensho_kfinance-3.2.4.dist-info → kensho_kfinance-3.2.6.dist-info}/licenses/AUTHORS.md +0 -0
- {kensho_kfinance-3.2.4.dist-info → kensho_kfinance-3.2.6.dist-info}/licenses/LICENSE +0 -0
- {kensho_kfinance-3.2.4.dist-info → kensho_kfinance-3.2.6.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import abc
|
|
1
2
|
from typing import Annotated, Any, Callable, Dict, Literal, Type
|
|
2
3
|
|
|
3
4
|
from langchain_core.tools import BaseTool
|
|
@@ -22,7 +23,7 @@ class KfinanceTool(BaseTool):
|
|
|
22
23
|
|
|
23
24
|
model_config = ConfigDict(extra="forbid")
|
|
24
25
|
|
|
25
|
-
def run_without_langchain(self, *args: Any, **kwargs: Any) ->
|
|
26
|
+
def run_without_langchain(self, *args: Any, **kwargs: Any) -> dict:
|
|
26
27
|
"""Execute a Kfinance tool without langchain.
|
|
27
28
|
|
|
28
29
|
Langchain converts json input params into the pydantic args_schema, which means that
|
|
@@ -38,7 +39,8 @@ class KfinanceTool(BaseTool):
|
|
|
38
39
|
# This behavior matches the langchain handling. See
|
|
39
40
|
# https://github.com/langchain-ai/langchain/blob/ca39680d2ab0d786bc035930778a5787e7bb5e01/libs/core/langchain_core/tools/base.py#L595-L597
|
|
40
41
|
args_dict = {k: v for k, v in args_dict.items() if k in kwargs}
|
|
41
|
-
|
|
42
|
+
result_model = self._run(**args_dict)
|
|
43
|
+
return result_model.model_dump(mode="json", exclude_none=True)
|
|
42
44
|
|
|
43
45
|
def run_with_grounding(self, *args: Any, **kwargs: Any) -> Any:
|
|
44
46
|
"""Execute a Kfinance tool with grounding support.
|
|
@@ -47,7 +49,10 @@ class KfinanceTool(BaseTool):
|
|
|
47
49
|
support, for returning the endpoint urls along with the data as citation info for the LRA Data Agent.
|
|
48
50
|
"""
|
|
49
51
|
with self.kfinance_client.kfinance_api_client.endpoint_tracker() as endpoint_tracker_queue:
|
|
50
|
-
|
|
52
|
+
args_model = self.args_schema.model_validate(kwargs)
|
|
53
|
+
args_dict = args_model.model_dump()
|
|
54
|
+
args_dict = {k: v for k, v in args_dict.items() if k in kwargs}
|
|
55
|
+
result_model = self._run(**args_dict)
|
|
51
56
|
|
|
52
57
|
# After completion of tool data fetching and within the endpoint_tracker context manager scope, dequeue the endpoint_tracker_queue
|
|
53
58
|
endpoint_urls = []
|
|
@@ -55,11 +60,12 @@ class KfinanceTool(BaseTool):
|
|
|
55
60
|
endpoint_urls.append(endpoint_tracker_queue.get())
|
|
56
61
|
|
|
57
62
|
return {
|
|
58
|
-
"data":
|
|
63
|
+
"data": result_model,
|
|
59
64
|
"endpoint_urls": endpoint_urls,
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
@abc.abstractmethod
|
|
68
|
+
def _run(self, *args: Any, **kwargs: Any) -> BaseModel:
|
|
63
69
|
"""The code to execute the tool.
|
|
64
70
|
|
|
65
71
|
Where feasible and useful, tools should use batch processing to parallelize
|
kfinance/version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '3.2.
|
|
32
|
-
__version_tuple__ = version_tuple = (3, 2,
|
|
31
|
+
__version__ = version = '3.2.6'
|
|
32
|
+
__version_tuple__ = version_tuple = (3, 2, 6)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|