kensho-kfinance 3.1.1__tar.gz → 3.2.1__tar.gz
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.1.1/kensho_kfinance.egg-info → kensho_kfinance-3.2.1}/PKG-INFO +1 -1
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1/kensho_kfinance.egg-info}/PKG-INFO +1 -1
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/CHANGELOG.md +6 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/fetch.py +18 -1
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/meta_classes.py +55 -0
- {kensho_kfinance-3.1.1/kfinance/models → kensho_kfinance-3.2.1/kfinance/client}/permission_models.py +1 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/tests/test_fetch.py +77 -1
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/companies/company_models.py +22 -0
- kensho_kfinance-3.2.1/kfinance/domains/companies/company_tools.py +198 -0
- kensho_kfinance-3.2.1/kfinance/domains/companies/tests/test_company_tools.py +125 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/all_tools.py +9 -1
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/version.py +3 -16
- kensho_kfinance-3.1.1/kfinance/domains/companies/company_tools.py +0 -70
- kensho_kfinance-3.1.1/kfinance/domains/companies/tests/test_company_tools.py +0 -33
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/.coveragerc +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/.github/workflows/ci-lint.yml +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/.github/workflows/ci-test.yml +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/.github/workflows/python-publish.yml +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/.gitignore +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/.readthedocs.yaml +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/AUTHORS.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/CODE_OF_CONDUCT.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/CONTRIBUTING.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/LICENSE +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/README.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/docs/build_tool_calling_documentation.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/docs/conf.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/docs/index.rst +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/docs/kfinance.rst +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/docs/requirements.txt +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/docs/templates/apidoc/package.rst_t +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/docs/templates/apidoc/toc.rst_t +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/docs/tool_calling.rst +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/example_notebooks/basic_usage.ipynb +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/example_notebooks/tool_calling/langchain/anthropic_langchain_tool_calling.ipynb +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/example_notebooks/tool_calling/langchain/google_gemini_langchain_tool_calling.ipynb +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/example_notebooks/tool_calling/langchain/openai_langchain_tool_calling.ipynb +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/example_notebooks/tool_calling/non-langchain/anthropic_tool_calling.ipynb +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/example_notebooks/tool_calling/non-langchain/google_gemini_tool_calling.ipynb +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/example_notebooks/tool_calling/non-langchain/openai_langchain_tool_calling.ipynb +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/images/colab_logo_32px.png +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/justfile +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kensho_kfinance.egg-info/SOURCES.txt +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kensho_kfinance.egg-info/dependency_links.txt +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kensho_kfinance.egg-info/requires.txt +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kensho_kfinance.egg-info/top_level.txt +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/README.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/batch_request_handling.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/industry_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/kfinance.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/models/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/models/currency_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/models/date_and_period_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/models/decimal_with_unit.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/models/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/models/tests/test_decimal_with_unit.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/server_thread.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/tests/test_batch_requests.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/tests/test_client.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/tests/test_group_objects.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/client/tests/test_objects.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/conftest.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/README.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/business_relationships/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/business_relationships/business_relationship_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/business_relationships/business_relationship_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/business_relationships/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/business_relationships/tests/test_business_relationship_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/capitalizations/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/capitalizations/capitalization_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/capitalizations/capitalization_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/capitalizations/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/capitalizations/tests/test_capitalization_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/capitalizations/tests/test_capitalization_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/companies/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/companies/company_identifiers.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/companies/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/competitors/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/competitors/competitor_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/competitors/competitor_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/competitors/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/competitors/tests/test_competitor_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/cusip_and_isin/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/cusip_and_isin/cusip_and_isin_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/cusip_and_isin/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/cusip_and_isin/tests/test_cusip_and_isin_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/earnings/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/earnings/earning_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/earnings/earning_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/earnings/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/earnings/tests/test_earnings_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/line_items/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/line_items/line_item_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/line_items/line_item_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/line_items/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/line_items/tests/test_line_item_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/mergers_and_acquisitions/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/mergers_and_acquisitions/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/mergers_and_acquisitions/tests/test_merger_and_acquisition_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/prices/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/prices/price_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/prices/price_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/prices/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/prices/tests/test_price_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/prices/tests/test_price_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/segments/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/segments/segment_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/segments/segment_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/segments/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/segments/tests/test_segment_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/statements/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/statements/statement_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/statements/statement_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/statements/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/statements/tests/test_statement_tools.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/README.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/local_mcp/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/local_mcp/local_mcp.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tests/test_example_notebook.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/README.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/prompts.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/static_tools/README.md +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/static_tools/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/static_tools/get_latest.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/static_tools/get_n_quarters_ago.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/static_tools/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/static_tools/tests/test_get_lastest.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/static_tools/tests/test_get_n_quarters_ago.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/tests/__init__.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/tests/test_tool_calling_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/tool_calling_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/mcp.py +0 -0
- {kensho_kfinance-3.1.1/kfinance/client → kensho_kfinance-3.2.1/kfinance/models}/permission_models.py +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/py.typed +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/pyproject.toml +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/scripts/copyright_line_check.sh +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/scripts/lint.sh +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/scripts/test.sh +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/setup.cfg +0 -0
- {kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kensho-kfinance
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.1
|
|
4
4
|
Summary: Python CLI for kFinance
|
|
5
5
|
Author-email: Luke Brown <luke.brown@kensho.com>, Michelle Keoy <michelle.keoy@kensho.com>, Keith Page <keith.page@kensho.com>, Matthew Rosen <matthew.rosen@kensho.com>, Nick Roshdieh <nick.roshdieh@kensho.com>
|
|
6
6
|
Project-URL: source, https://github.com/kensho-technologies/kfinance
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kensho-kfinance
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.1
|
|
4
4
|
Summary: Python CLI for kFinance
|
|
5
5
|
Author-email: Luke Brown <luke.brown@kensho.com>, Michelle Keoy <michelle.keoy@kensho.com>, Keith Page <keith.page@kensho.com>, Matthew Rosen <matthew.rosen@kensho.com>, Nick Roshdieh <nick.roshdieh@kensho.com>
|
|
6
6
|
Project-URL: source, https://github.com/kensho-technologies/kfinance
|
|
@@ -17,7 +17,12 @@ from kfinance.domains.business_relationships.business_relationship_models import
|
|
|
17
17
|
RelationshipResponse,
|
|
18
18
|
)
|
|
19
19
|
from kfinance.domains.capitalizations.capitalization_models import Capitalizations
|
|
20
|
-
from kfinance.domains.companies.company_models import
|
|
20
|
+
from kfinance.domains.companies.company_models import (
|
|
21
|
+
CompanyDescriptions,
|
|
22
|
+
CompanyOtherNames,
|
|
23
|
+
IdentificationTriple,
|
|
24
|
+
UnifiedIdTripleResponse,
|
|
25
|
+
)
|
|
21
26
|
from kfinance.domains.competitors.competitor_models import CompetitorResponse, CompetitorSource
|
|
22
27
|
from kfinance.domains.earnings.earning_models import EarningsCallResp
|
|
23
28
|
from kfinance.domains.line_items.line_item_models import LineItemResponse
|
|
@@ -602,6 +607,18 @@ class KFinanceApiClient:
|
|
|
602
607
|
url = f"{self.url_base}transcript/{key_dev_id}"
|
|
603
608
|
return self.fetch(url)
|
|
604
609
|
|
|
610
|
+
def fetch_company_descriptions(self, company_id: int) -> CompanyDescriptions:
|
|
611
|
+
"""Get the short description (summary) and long description for a company"""
|
|
612
|
+
url = f"{self.url_base}info/{company_id}/descriptions"
|
|
613
|
+
result = self.fetch(url)
|
|
614
|
+
return CompanyDescriptions.model_validate(result)
|
|
615
|
+
|
|
616
|
+
def fetch_company_other_names(self, company_id: int) -> CompanyOtherNames:
|
|
617
|
+
"""Get the alternate, historical, and native names for a company"""
|
|
618
|
+
url = f"{self.url_base}info/{company_id}/names"
|
|
619
|
+
result = self.fetch(url)
|
|
620
|
+
return CompanyOtherNames.model_validate(result)
|
|
621
|
+
|
|
605
622
|
def fetch_competitors(
|
|
606
623
|
self, company_id: int, competitor_source: CompetitorSource
|
|
607
624
|
) -> CompetitorResponse:
|
|
@@ -13,6 +13,11 @@ from kfinance.domains.business_relationships.business_relationship_models import
|
|
|
13
13
|
BusinessRelationshipType,
|
|
14
14
|
)
|
|
15
15
|
from kfinance.domains.capitalizations.capitalization_models import Capitalization
|
|
16
|
+
from kfinance.domains.companies.company_models import (
|
|
17
|
+
CompanyDescriptions,
|
|
18
|
+
CompanyOtherNames,
|
|
19
|
+
NativeName,
|
|
20
|
+
)
|
|
16
21
|
from kfinance.domains.competitors.competitor_models import CompetitorSource
|
|
17
22
|
from kfinance.domains.line_items.line_item_models import LINE_ITEMS
|
|
18
23
|
from kfinance.domains.segments.segment_models import SegmentType
|
|
@@ -27,6 +32,11 @@ logger = logging.getLogger(__name__)
|
|
|
27
32
|
class CompanyFunctionsMetaClass:
|
|
28
33
|
kfinance_api_client: KFinanceApiClient
|
|
29
34
|
|
|
35
|
+
def __init__(self) -> None:
|
|
36
|
+
"""Initialize the CompanyFunctionsMetaClass object"""
|
|
37
|
+
self._company_descriptions: CompanyDescriptions | None = None
|
|
38
|
+
self._company_other_names: CompanyOtherNames | None = None
|
|
39
|
+
|
|
30
40
|
@property
|
|
31
41
|
@abstractmethod
|
|
32
42
|
def company_id(self) -> Any:
|
|
@@ -415,6 +425,51 @@ class CompanyFunctionsMetaClass:
|
|
|
415
425
|
end_quarter=end_quarter,
|
|
416
426
|
)
|
|
417
427
|
|
|
428
|
+
@property
|
|
429
|
+
def summary(self) -> str:
|
|
430
|
+
"""Lazily fetch and return a company's summary"""
|
|
431
|
+
if not self._company_descriptions:
|
|
432
|
+
self._company_descriptions = self.kfinance_api_client.fetch_company_descriptions(
|
|
433
|
+
company_id=self.company_id
|
|
434
|
+
)
|
|
435
|
+
return self._company_descriptions.summary
|
|
436
|
+
|
|
437
|
+
@property
|
|
438
|
+
def description(self) -> str:
|
|
439
|
+
"""Lazily fetch and return a company's description"""
|
|
440
|
+
if not self._company_descriptions:
|
|
441
|
+
self._company_descriptions = self.kfinance_api_client.fetch_company_descriptions(
|
|
442
|
+
company_id=self.company_id
|
|
443
|
+
)
|
|
444
|
+
return self._company_descriptions.description
|
|
445
|
+
|
|
446
|
+
@property
|
|
447
|
+
def alternate_names(self) -> list[str]:
|
|
448
|
+
"""Lazily fetch and return a company's alternate names"""
|
|
449
|
+
if not self._company_other_names:
|
|
450
|
+
self._company_other_names = self.kfinance_api_client.fetch_company_other_names(
|
|
451
|
+
company_id=self.company_id
|
|
452
|
+
)
|
|
453
|
+
return self._company_other_names.alternate_names
|
|
454
|
+
|
|
455
|
+
@property
|
|
456
|
+
def historical_names(self) -> list[str]:
|
|
457
|
+
"""Lazily fetch and return a company's historical names"""
|
|
458
|
+
if not self._company_other_names:
|
|
459
|
+
self._company_other_names = self.kfinance_api_client.fetch_company_other_names(
|
|
460
|
+
company_id=self.company_id
|
|
461
|
+
)
|
|
462
|
+
return self._company_other_names.historical_names
|
|
463
|
+
|
|
464
|
+
@property
|
|
465
|
+
def native_names(self) -> list[NativeName]:
|
|
466
|
+
"""Lazily fetch and return a company's native names"""
|
|
467
|
+
if not self._company_other_names:
|
|
468
|
+
self._company_other_names = self.kfinance_api_client.fetch_company_other_names(
|
|
469
|
+
company_id=self.company_id
|
|
470
|
+
)
|
|
471
|
+
return self._company_other_names.native_names
|
|
472
|
+
|
|
418
473
|
def competitors(
|
|
419
474
|
self, competitor_source: CompetitorSource = CompetitorSource.all
|
|
420
475
|
) -> "Companies":
|
|
@@ -13,7 +13,11 @@ from kfinance.domains.business_relationships.business_relationship_models import
|
|
|
13
13
|
BusinessRelationshipType,
|
|
14
14
|
RelationshipResponse,
|
|
15
15
|
)
|
|
16
|
-
from kfinance.domains.companies.company_models import
|
|
16
|
+
from kfinance.domains.companies.company_models import (
|
|
17
|
+
CompanyDescriptions,
|
|
18
|
+
CompanyIdAndName,
|
|
19
|
+
CompanyOtherNames,
|
|
20
|
+
)
|
|
17
21
|
|
|
18
22
|
|
|
19
23
|
def build_mock_api_client() -> KFinanceApiClient:
|
|
@@ -383,3 +387,75 @@ class TestFetchCompaniesFromBusinessRelationship:
|
|
|
383
387
|
company_id=SPGI_COMPANY_ID, relationship_type=BusinessRelationshipType.supplier
|
|
384
388
|
)
|
|
385
389
|
assert resp == expected_result
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
class TestFetchCompanyDescriptions:
|
|
393
|
+
def test_fetch_company_descriptions(self, requests_mock: Mocker, mock_client: Client) -> None:
|
|
394
|
+
"""
|
|
395
|
+
GIVEN a request to fetch company descriptions
|
|
396
|
+
WHEN the api returns a response
|
|
397
|
+
THEN the response can successfully be parsed into a CompanyDescriptions object.
|
|
398
|
+
"""
|
|
399
|
+
|
|
400
|
+
# Truncated from actual http response
|
|
401
|
+
http_resp = {
|
|
402
|
+
"summary": "S&P Global Inc., together... [summary]",
|
|
403
|
+
"description": "S&P Global Inc. (S&P Global), together... [description]",
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
expected_result = CompanyDescriptions(
|
|
407
|
+
summary="S&P Global Inc., together... [summary]",
|
|
408
|
+
description="S&P Global Inc. (S&P Global), together... [description]",
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
requests_mock.get(
|
|
412
|
+
url=f"{mock_client.kfinance_api_client.url_base}info/{SPGI_COMPANY_ID}/descriptions",
|
|
413
|
+
json=http_resp,
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
resp = mock_client.kfinance_api_client.fetch_company_descriptions(
|
|
417
|
+
company_id=SPGI_COMPANY_ID
|
|
418
|
+
)
|
|
419
|
+
assert resp == expected_result
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
class TestFetchCompanyOtherNames:
|
|
423
|
+
def test_fetch_company_other_names(self, requests_mock: Mocker, mock_client: Client) -> None:
|
|
424
|
+
"""
|
|
425
|
+
GIVEN a request to fetch a company's other names (alternate, historical, and native)
|
|
426
|
+
WHEN the api returns a response
|
|
427
|
+
THEN the response can be successfully parsed into a CompanyOtherNames object
|
|
428
|
+
"""
|
|
429
|
+
alternate_names = ["S&P Global", "S&P Global, Inc.", "S&P"]
|
|
430
|
+
historical_names = [
|
|
431
|
+
"McGraw-Hill Publishing Company, Inc.",
|
|
432
|
+
"McGraw-Hill Book Company",
|
|
433
|
+
"McGraw Hill Financial, Inc.",
|
|
434
|
+
"The McGraw-Hill Companies, Inc.",
|
|
435
|
+
]
|
|
436
|
+
native_names = [
|
|
437
|
+
{"name": "KLab Venture Partners 株式会社", "language": "Japanese"},
|
|
438
|
+
{"name": "株式会社ANOBAKA", "language": "Japanese"},
|
|
439
|
+
{"name": "株式会社KVP", "language": "Japanese"},
|
|
440
|
+
]
|
|
441
|
+
|
|
442
|
+
http_resp = {
|
|
443
|
+
"alternate_names": alternate_names,
|
|
444
|
+
"historical_names": historical_names,
|
|
445
|
+
"native_names": native_names,
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
expected_resp = CompanyOtherNames(
|
|
449
|
+
alternate_names=alternate_names,
|
|
450
|
+
historical_names=historical_names,
|
|
451
|
+
native_names=native_names,
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
requests_mock.get(
|
|
455
|
+
url=f"{mock_client.kfinance_api_client.url_base}info/{SPGI_COMPANY_ID}/names",
|
|
456
|
+
json=http_resp,
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
resp = mock_client.kfinance_api_client.fetch_company_other_names(company_id=SPGI_COMPANY_ID)
|
|
460
|
+
|
|
461
|
+
assert resp == expected_resp
|
{kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/domains/companies/company_models.py
RENAMED
|
@@ -118,3 +118,25 @@ class UnifiedIdTripleResponse(BaseModel):
|
|
|
118
118
|
f"{identifier} is a private company without a trading_item_id."
|
|
119
119
|
)
|
|
120
120
|
self.identifiers_to_id_triples.pop(identifier)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class CompanyDescriptions(BaseModel):
|
|
124
|
+
"""A company summary and description"""
|
|
125
|
+
|
|
126
|
+
summary: str
|
|
127
|
+
description: str
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class NativeName(BaseModel):
|
|
131
|
+
"""A company's native name's name and language"""
|
|
132
|
+
|
|
133
|
+
name: str
|
|
134
|
+
language: str
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class CompanyOtherNames(BaseModel):
|
|
138
|
+
"""A company's alternate, historical, and native names"""
|
|
139
|
+
|
|
140
|
+
alternate_names: list[str]
|
|
141
|
+
historical_names: list[str]
|
|
142
|
+
native_names: list[NativeName]
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
from textwrap import dedent
|
|
2
|
+
from typing import Type
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
from kfinance.client.batch_request_handling import Task, process_tasks_in_thread_pool_executor
|
|
7
|
+
from kfinance.client.permission_models import Permission
|
|
8
|
+
from kfinance.domains.companies.company_models import CompanyDescriptions, CompanyOtherNames
|
|
9
|
+
from kfinance.integrations.tool_calling.tool_calling_models import (
|
|
10
|
+
KfinanceTool,
|
|
11
|
+
ToolArgsWithIdentifiers,
|
|
12
|
+
ToolRespWithErrors,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GetInfoFromIdentifiersResp(ToolRespWithErrors):
|
|
17
|
+
results: dict[str, dict]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GetInfoFromIdentifiers(KfinanceTool):
|
|
21
|
+
name: str = "get_info_from_identifiers"
|
|
22
|
+
description: str = dedent("""
|
|
23
|
+
Get the information associated with a list of identifiers. Info includes company name, status, type, simple industry, number of employees (if available), founding date, webpage, HQ address, HQ city, HQ zip code, HQ state, HQ country, and HQ country iso code.
|
|
24
|
+
|
|
25
|
+
- When possible, pass multiple identifiers in a single call rather than making multiple calls.
|
|
26
|
+
""").strip()
|
|
27
|
+
args_schema: Type[BaseModel] = ToolArgsWithIdentifiers
|
|
28
|
+
accepted_permissions: set[Permission] | None = None
|
|
29
|
+
|
|
30
|
+
def _run(self, identifiers: list[str]) -> dict:
|
|
31
|
+
"""Sample response:
|
|
32
|
+
|
|
33
|
+
{ "results": {
|
|
34
|
+
"SPGI": {
|
|
35
|
+
"name": "S&P Global Inc.",
|
|
36
|
+
"status": "Operating",
|
|
37
|
+
"type": "Public Company",
|
|
38
|
+
"simple_industry": "Capital Markets",
|
|
39
|
+
"number_of_employees": "42350.0000",
|
|
40
|
+
"founding_date": "1860-01-01",
|
|
41
|
+
"webpage": "www.spglobal.com",
|
|
42
|
+
"address": "55 Water Street",
|
|
43
|
+
"city": "New York",
|
|
44
|
+
"zip_code": "10041-0001",
|
|
45
|
+
"state": "New York",
|
|
46
|
+
"country": "United States",
|
|
47
|
+
"iso_country": "USA"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"errors": [['No identification triple found for the provided identifier: NON-EXISTENT of type: ticker']
|
|
51
|
+
}
|
|
52
|
+
"""
|
|
53
|
+
api_client = self.kfinance_client.kfinance_api_client
|
|
54
|
+
id_triple_resp = api_client.unified_fetch_id_triples(identifiers=identifiers)
|
|
55
|
+
|
|
56
|
+
tasks = [
|
|
57
|
+
Task(
|
|
58
|
+
func=api_client.fetch_info,
|
|
59
|
+
kwargs=dict(company_id=id_triple.company_id),
|
|
60
|
+
result_key=identifier,
|
|
61
|
+
)
|
|
62
|
+
for identifier, id_triple in id_triple_resp.identifiers_to_id_triples.items()
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
info_responses: dict[str, dict] = process_tasks_in_thread_pool_executor(
|
|
66
|
+
api_client=api_client, tasks=tasks
|
|
67
|
+
)
|
|
68
|
+
resp_model = GetInfoFromIdentifiersResp(
|
|
69
|
+
results=info_responses, errors=list(id_triple_resp.errors.values())
|
|
70
|
+
)
|
|
71
|
+
return resp_model.model_dump(mode="json")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class GetCompanyOtherNamesFromIdentifiersResp(ToolRespWithErrors):
|
|
75
|
+
results: dict[str, CompanyOtherNames]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class GetCompanyOtherNamesFromIdentifiers(KfinanceTool):
|
|
79
|
+
name: str = "get_company_other_names_from_identifiers"
|
|
80
|
+
description: str = dedent("""
|
|
81
|
+
Given a list of identifiers, fetch the alternate, historical, and native names associated with each identifier. Alternate names are additional names a company might go by (for example, Hewlett-Packard Company also goes by the name HP). Historical names are previous names for the company if it has changed over time. Native names are primary non-Latin character native names for global companies, including languages such as Arabic, Russian, Greek, Japanese, etc. This also includes limited history on native name changes.
|
|
82
|
+
|
|
83
|
+
- When possible, pass multiple identifiers in a single call rather than making multiple calls.
|
|
84
|
+
""").strip()
|
|
85
|
+
args_schema: Type[BaseModel] = ToolArgsWithIdentifiers
|
|
86
|
+
accepted_permissions: set[Permission] | None = {Permission.CompanyIntelligencePermission}
|
|
87
|
+
|
|
88
|
+
def _run(
|
|
89
|
+
self,
|
|
90
|
+
identifiers: list[str],
|
|
91
|
+
) -> dict:
|
|
92
|
+
api_client = self.kfinance_client.kfinance_api_client
|
|
93
|
+
id_triple_resp = api_client.unified_fetch_id_triples(identifiers=identifiers)
|
|
94
|
+
tasks = [
|
|
95
|
+
Task(
|
|
96
|
+
func=api_client.fetch_company_other_names,
|
|
97
|
+
kwargs=dict(company_id=id_triple.company_id),
|
|
98
|
+
result_key=identifier,
|
|
99
|
+
)
|
|
100
|
+
for identifier, id_triple in id_triple_resp.identifiers_to_id_triples.items()
|
|
101
|
+
]
|
|
102
|
+
info_responses: dict[str, CompanyOtherNames] = process_tasks_in_thread_pool_executor(
|
|
103
|
+
api_client=api_client, tasks=tasks
|
|
104
|
+
)
|
|
105
|
+
resp_model = GetCompanyOtherNamesFromIdentifiersResp(
|
|
106
|
+
results=info_responses, errors=list(id_triple_resp.errors.values())
|
|
107
|
+
)
|
|
108
|
+
return resp_model.model_dump(mode="json")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class GetCompanySummaryFromIdentifiersResp(ToolRespWithErrors):
|
|
112
|
+
results: dict[str, str]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class GetCompanySummaryFromIdentifiers(KfinanceTool):
|
|
116
|
+
name: str = "get_company_summary_from_identifiers"
|
|
117
|
+
description: str = dedent("""
|
|
118
|
+
Get one paragraph summary/short descriptions of companies, including information about the company's primary business, products and services offered and their applications, business segment details, client/customer groups served, geographic markets served, distribution channels, strategic alliances/partnerships, founded/incorporated year, latest former name, and headquarters and additional offices."
|
|
119
|
+
|
|
120
|
+
- When possible, pass multiple identifiers in a single call rather than making multiple calls.
|
|
121
|
+
""").strip()
|
|
122
|
+
args_schema: Type[BaseModel] = ToolArgsWithIdentifiers
|
|
123
|
+
accepted_permissions: set[Permission] | None = {Permission.CompanyIntelligencePermission}
|
|
124
|
+
|
|
125
|
+
def _run(
|
|
126
|
+
self,
|
|
127
|
+
identifiers: list[str],
|
|
128
|
+
) -> dict:
|
|
129
|
+
api_client = self.kfinance_client.kfinance_api_client
|
|
130
|
+
id_triple_resp = api_client.unified_fetch_id_triples(identifiers=identifiers)
|
|
131
|
+
|
|
132
|
+
tasks = [
|
|
133
|
+
Task(
|
|
134
|
+
func=api_client.fetch_company_descriptions,
|
|
135
|
+
kwargs=dict(company_id=id_triple.company_id),
|
|
136
|
+
result_key=identifier,
|
|
137
|
+
)
|
|
138
|
+
for identifier, id_triple in id_triple_resp.identifiers_to_id_triples.items()
|
|
139
|
+
]
|
|
140
|
+
company_description_responses: dict[str, CompanyDescriptions] = (
|
|
141
|
+
process_tasks_in_thread_pool_executor(api_client=api_client, tasks=tasks)
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# Extract only the summary field
|
|
145
|
+
summary_results = {
|
|
146
|
+
identifier: descriptions.summary
|
|
147
|
+
for identifier, descriptions in company_description_responses.items()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
resp_model = GetCompanySummaryFromIdentifiersResp(
|
|
151
|
+
results=summary_results, errors=list(id_triple_resp.errors.values())
|
|
152
|
+
)
|
|
153
|
+
return resp_model.model_dump(mode="json")
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class GetCompanyDescriptionFromIdentifiersResp(ToolRespWithErrors):
|
|
157
|
+
results: dict[str, str]
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class GetCompanyDescriptionFromIdentifiers(KfinanceTool):
|
|
161
|
+
name: str = "get_company_description_from_identifiers"
|
|
162
|
+
description: str = dedent("""
|
|
163
|
+
Get detailed descriptions of companies, broken down into sections, which may include information about the company's Primary business, Segments (including Products and Services for each), Competition, Significant events, and History. Within the text, four spaces represent a new paragraph. Note that the description is divided into sections with headers, where each section has a new paragraph (four spaces) before and after the section header.
|
|
164
|
+
|
|
165
|
+
- When possible, pass multiple identifiers in a single call rather than making multiple calls.
|
|
166
|
+
""").strip()
|
|
167
|
+
args_schema: Type[BaseModel] = ToolArgsWithIdentifiers
|
|
168
|
+
accepted_permissions: set[Permission] | None = {Permission.CompanyIntelligencePermission}
|
|
169
|
+
|
|
170
|
+
def _run(
|
|
171
|
+
self,
|
|
172
|
+
identifiers: list[str],
|
|
173
|
+
) -> dict:
|
|
174
|
+
api_client = self.kfinance_client.kfinance_api_client
|
|
175
|
+
id_triple_resp = api_client.unified_fetch_id_triples(identifiers=identifiers)
|
|
176
|
+
|
|
177
|
+
tasks = [
|
|
178
|
+
Task(
|
|
179
|
+
func=api_client.fetch_company_descriptions,
|
|
180
|
+
kwargs=dict(company_id=id_triple.company_id),
|
|
181
|
+
result_key=identifier,
|
|
182
|
+
)
|
|
183
|
+
for identifier, id_triple in id_triple_resp.identifiers_to_id_triples.items()
|
|
184
|
+
]
|
|
185
|
+
company_description_responses: dict[str, CompanyDescriptions] = (
|
|
186
|
+
process_tasks_in_thread_pool_executor(api_client=api_client, tasks=tasks)
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
# Extract only the description field
|
|
190
|
+
description_results = {
|
|
191
|
+
identifier: descriptions.description
|
|
192
|
+
for identifier, descriptions in company_description_responses.items()
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
resp_model = GetCompanyDescriptionFromIdentifiersResp(
|
|
196
|
+
results=description_results, errors=list(id_triple_resp.errors.values())
|
|
197
|
+
)
|
|
198
|
+
return resp_model.model_dump(mode="json")
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
from requests_mock import Mocker
|
|
2
|
+
|
|
3
|
+
from kfinance.client.kfinance import Client
|
|
4
|
+
from kfinance.conftest import SPGI_COMPANY_ID
|
|
5
|
+
from kfinance.domains.companies.company_tools import (
|
|
6
|
+
GetCompanyDescriptionFromIdentifiers,
|
|
7
|
+
GetCompanyOtherNamesFromIdentifiers,
|
|
8
|
+
GetCompanySummaryFromIdentifiers,
|
|
9
|
+
GetInfoFromIdentifiers,
|
|
10
|
+
)
|
|
11
|
+
from kfinance.integrations.tool_calling.tool_calling_models import ToolArgsWithIdentifiers
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TestGetInfoFromIdentifiers:
|
|
15
|
+
def test_get_info_from_identifiers(self, mock_client: Client, requests_mock: Mocker):
|
|
16
|
+
"""
|
|
17
|
+
GIVEN the GetInfoFromIdentifiers tool
|
|
18
|
+
WHEN request info for SPGI and a non-existent company
|
|
19
|
+
THEN we get back info for SPGI and an error for the non-existent company
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
info_resp = {"name": "S&P Global Inc.", "status": "Operating"}
|
|
23
|
+
expected_response = {
|
|
24
|
+
"results": {"SPGI": info_resp},
|
|
25
|
+
"errors": [
|
|
26
|
+
"No identification triple found for the provided identifier: NON-EXISTENT of type: ticker"
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
requests_mock.get(
|
|
30
|
+
url=f"https://kfinance.kensho.com/api/v1/info/{SPGI_COMPANY_ID}",
|
|
31
|
+
json=info_resp,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
tool = GetInfoFromIdentifiers(kfinance_client=mock_client)
|
|
35
|
+
resp = tool.run(
|
|
36
|
+
ToolArgsWithIdentifiers(identifiers=["SPGI", "non-existent"]).model_dump(mode="json")
|
|
37
|
+
)
|
|
38
|
+
assert resp == expected_response
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class TestGetCompanyDescriptions:
|
|
42
|
+
description = "S&P Global Inc. (S&P Global), together... [description]"
|
|
43
|
+
summary = "S&P Global Inc., together... [summary]"
|
|
44
|
+
descriptions_data = {
|
|
45
|
+
"summary": summary,
|
|
46
|
+
"description": description,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
def test_get_company_summary_from_identifier(self, mock_client: Client, requests_mock: Mocker):
|
|
50
|
+
"""
|
|
51
|
+
GIVEN the GetCompanySummaryFromIdentifier tool
|
|
52
|
+
WHEN we request the company summary (short description) for SPGI
|
|
53
|
+
THEN we get back SPGI company's summary (short description)
|
|
54
|
+
"""
|
|
55
|
+
requests_mock.get(
|
|
56
|
+
url=f"https://kfinance.kensho.com/api/v1/info/{SPGI_COMPANY_ID}/descriptions",
|
|
57
|
+
# truncated from the original API response
|
|
58
|
+
json=self.descriptions_data,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
tool = GetCompanySummaryFromIdentifiers(kfinance_client=mock_client)
|
|
62
|
+
args = ToolArgsWithIdentifiers(identifiers=["SPGI"])
|
|
63
|
+
response = tool.run(args.model_dump(mode="json"))
|
|
64
|
+
expected_response = {"results": {"SPGI": self.summary}}
|
|
65
|
+
assert response == expected_response
|
|
66
|
+
|
|
67
|
+
def test_get_company_description_from_identifier(
|
|
68
|
+
self, mock_client: Client, requests_mock: Mocker
|
|
69
|
+
):
|
|
70
|
+
"""
|
|
71
|
+
GIVEN the GetCompanyDescriptionFromIdentifier tool
|
|
72
|
+
WHEN we request the company description for SPGI
|
|
73
|
+
THEN we get back SPGI company's description
|
|
74
|
+
"""
|
|
75
|
+
requests_mock.get(
|
|
76
|
+
url=f"https://kfinance.kensho.com/api/v1/info/{SPGI_COMPANY_ID}/descriptions",
|
|
77
|
+
# truncated from the original API response
|
|
78
|
+
json=self.descriptions_data,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
tool = GetCompanyDescriptionFromIdentifiers(kfinance_client=mock_client)
|
|
82
|
+
args = ToolArgsWithIdentifiers(identifiers=["SPGI"])
|
|
83
|
+
response = tool.run(args.model_dump(mode="json"))
|
|
84
|
+
expected_response = {"results": {"SPGI": self.description}}
|
|
85
|
+
assert response == expected_response
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class TestGetCompanyOtherNames:
|
|
89
|
+
alternate_names = ["S&P Global", "S&P Global, Inc.", "S&P"]
|
|
90
|
+
historical_names = [
|
|
91
|
+
"McGraw-Hill Publishing Company, Inc.",
|
|
92
|
+
"McGraw-Hill Book Company",
|
|
93
|
+
"McGraw Hill Financial, Inc.",
|
|
94
|
+
"The McGraw-Hill Companies, Inc.",
|
|
95
|
+
]
|
|
96
|
+
native_names = [
|
|
97
|
+
{"name": "KLab Venture Partners 株式会社", "language": "Japanese"},
|
|
98
|
+
{"name": "株式会社ANOBAKA", "language": "Japanese"},
|
|
99
|
+
{"name": "株式会社KVP", "language": "Japanese"},
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
company_other_names_info = {
|
|
103
|
+
"alternate_names": alternate_names,
|
|
104
|
+
"historical_names": historical_names,
|
|
105
|
+
"native_names": native_names,
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
def test_get_company_other_names_from_identifier(
|
|
109
|
+
self, mock_client: Client, requests_mock: Mocker
|
|
110
|
+
):
|
|
111
|
+
"""
|
|
112
|
+
GIVEN the GetCompanyOtherNamesFromIdentifier tool
|
|
113
|
+
WHEN we request the other names for SPGI
|
|
114
|
+
THEN we get back SPGI's other names
|
|
115
|
+
"""
|
|
116
|
+
requests_mock.get(
|
|
117
|
+
url=f"https://kfinance.kensho.com/api/v1/info/{SPGI_COMPANY_ID}/names",
|
|
118
|
+
json=self.company_other_names_info,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
tool = GetCompanyOtherNamesFromIdentifiers(kfinance_client=mock_client)
|
|
122
|
+
args = ToolArgsWithIdentifiers(identifiers=["SPGI"])
|
|
123
|
+
response = tool.run(args.model_dump(mode="json"))
|
|
124
|
+
expected_response = {"results": {"SPGI": self.company_other_names_info}}
|
|
125
|
+
assert response == expected_response
|
{kensho_kfinance-3.1.1 → kensho_kfinance-3.2.1}/kfinance/integrations/tool_calling/all_tools.py
RENAMED
|
@@ -2,7 +2,12 @@ from kfinance.domains.business_relationships.business_relationship_tools import
|
|
|
2
2
|
GetBusinessRelationshipFromIdentifiers,
|
|
3
3
|
)
|
|
4
4
|
from kfinance.domains.capitalizations.capitalization_tools import GetCapitalizationFromIdentifiers
|
|
5
|
-
from kfinance.domains.companies.company_tools import
|
|
5
|
+
from kfinance.domains.companies.company_tools import (
|
|
6
|
+
GetCompanyDescriptionFromIdentifiers,
|
|
7
|
+
GetCompanyOtherNamesFromIdentifiers,
|
|
8
|
+
GetCompanySummaryFromIdentifiers,
|
|
9
|
+
GetInfoFromIdentifiers,
|
|
10
|
+
)
|
|
6
11
|
from kfinance.domains.competitors.competitor_tools import GetCompetitorsFromIdentifiers
|
|
7
12
|
from kfinance.domains.cusip_and_isin.cusip_and_isin_tools import (
|
|
8
13
|
GetCusipFromIdentifiers,
|
|
@@ -34,6 +39,9 @@ ALL_TOOLS: list[type[KfinanceTool]] = [
|
|
|
34
39
|
GetCapitalizationFromIdentifiers,
|
|
35
40
|
# Companies
|
|
36
41
|
GetInfoFromIdentifiers,
|
|
42
|
+
GetCompanyOtherNamesFromIdentifiers,
|
|
43
|
+
GetCompanySummaryFromIdentifiers,
|
|
44
|
+
GetCompanyDescriptionFromIdentifiers,
|
|
37
45
|
# Competitors
|
|
38
46
|
GetCompetitorsFromIdentifiers,
|
|
39
47
|
# Cusip and Isin
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
3
|
|
|
4
|
-
__all__ = [
|
|
5
|
-
"__version__",
|
|
6
|
-
"__version_tuple__",
|
|
7
|
-
"version",
|
|
8
|
-
"version_tuple",
|
|
9
|
-
"__commit_id__",
|
|
10
|
-
"commit_id",
|
|
11
|
-
]
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
12
5
|
|
|
13
6
|
TYPE_CHECKING = False
|
|
14
7
|
if TYPE_CHECKING:
|
|
@@ -16,19 +9,13 @@ if TYPE_CHECKING:
|
|
|
16
9
|
from typing import Union
|
|
17
10
|
|
|
18
11
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
-
COMMIT_ID = Union[str, None]
|
|
20
12
|
else:
|
|
21
13
|
VERSION_TUPLE = object
|
|
22
|
-
COMMIT_ID = object
|
|
23
14
|
|
|
24
15
|
version: str
|
|
25
16
|
__version__: str
|
|
26
17
|
__version_tuple__: VERSION_TUPLE
|
|
27
18
|
version_tuple: VERSION_TUPLE
|
|
28
|
-
commit_id: COMMIT_ID
|
|
29
|
-
__commit_id__: COMMIT_ID
|
|
30
19
|
|
|
31
|
-
__version__ = version = '3.
|
|
32
|
-
__version_tuple__ = version_tuple = (3,
|
|
33
|
-
|
|
34
|
-
__commit_id__ = commit_id = 'g8208e6a64'
|
|
20
|
+
__version__ = version = '3.2.1'
|
|
21
|
+
__version_tuple__ = version_tuple = (3, 2, 1)
|