nlr-elm 0.0.35__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.
Files changed (82) hide show
  1. nlr_elm-0.0.35/LICENSE.txt +28 -0
  2. nlr_elm-0.0.35/PKG-INFO +156 -0
  3. nlr_elm-0.0.35/README.rst +61 -0
  4. nlr_elm-0.0.35/elm/__init__.py +27 -0
  5. nlr_elm-0.0.35/elm/base.py +584 -0
  6. nlr_elm-0.0.35/elm/chunk.py +265 -0
  7. nlr_elm-0.0.35/elm/cli.py +53 -0
  8. nlr_elm-0.0.35/elm/embed.py +166 -0
  9. nlr_elm-0.0.35/elm/exceptions.py +18 -0
  10. nlr_elm-0.0.35/elm/ords/__init__.py +1 -0
  11. nlr_elm-0.0.35/elm/ords/download.py +153 -0
  12. nlr_elm-0.0.35/elm/ords/extraction/__init__.py +8 -0
  13. nlr_elm-0.0.35/elm/ords/extraction/apply.py +310 -0
  14. nlr_elm-0.0.35/elm/ords/extraction/date.py +108 -0
  15. nlr_elm-0.0.35/elm/ords/extraction/features.py +97 -0
  16. nlr_elm-0.0.35/elm/ords/extraction/graphs.py +484 -0
  17. nlr_elm-0.0.35/elm/ords/extraction/ngrams.py +91 -0
  18. nlr_elm-0.0.35/elm/ords/extraction/ordinance.py +368 -0
  19. nlr_elm-0.0.35/elm/ords/extraction/parse.py +343 -0
  20. nlr_elm-0.0.35/elm/ords/extraction/tree.py +153 -0
  21. nlr_elm-0.0.35/elm/ords/llm/__init__.py +3 -0
  22. nlr_elm-0.0.35/elm/ords/llm/calling.py +202 -0
  23. nlr_elm-0.0.35/elm/ords/process.py +704 -0
  24. nlr_elm-0.0.35/elm/ords/services/__init__.py +1 -0
  25. nlr_elm-0.0.35/elm/ords/services/base.py +142 -0
  26. nlr_elm-0.0.35/elm/ords/services/cpu.py +142 -0
  27. nlr_elm-0.0.35/elm/ords/services/openai.py +186 -0
  28. nlr_elm-0.0.35/elm/ords/services/provider.py +186 -0
  29. nlr_elm-0.0.35/elm/ords/services/queues.py +55 -0
  30. nlr_elm-0.0.35/elm/ords/services/threaded.py +295 -0
  31. nlr_elm-0.0.35/elm/ords/services/usage.py +170 -0
  32. nlr_elm-0.0.35/elm/ords/utilities/__init__.py +21 -0
  33. nlr_elm-0.0.35/elm/ords/utilities/counties.py +132 -0
  34. nlr_elm-0.0.35/elm/ords/utilities/exceptions.py +30 -0
  35. nlr_elm-0.0.35/elm/ords/utilities/location.py +72 -0
  36. nlr_elm-0.0.35/elm/ords/utilities/parsing.py +73 -0
  37. nlr_elm-0.0.35/elm/ords/utilities/queued_logging.py +271 -0
  38. nlr_elm-0.0.35/elm/ords/validation/__init__.py +1 -0
  39. nlr_elm-0.0.35/elm/ords/validation/content.py +204 -0
  40. nlr_elm-0.0.35/elm/ords/validation/location.py +295 -0
  41. nlr_elm-0.0.35/elm/pdf.py +370 -0
  42. nlr_elm-0.0.35/elm/summary.py +183 -0
  43. nlr_elm-0.0.35/elm/tree.py +240 -0
  44. nlr_elm-0.0.35/elm/utilities/__init__.py +3 -0
  45. nlr_elm-0.0.35/elm/utilities/parse.py +516 -0
  46. nlr_elm-0.0.35/elm/utilities/retry.py +186 -0
  47. nlr_elm-0.0.35/elm/utilities/try_import.py +32 -0
  48. nlr_elm-0.0.35/elm/utilities/validation.py +35 -0
  49. nlr_elm-0.0.35/elm/version.py +5 -0
  50. nlr_elm-0.0.35/elm/web/__init__.py +3 -0
  51. nlr_elm-0.0.35/elm/web/document.py +338 -0
  52. nlr_elm-0.0.35/elm/web/file_loader.py +502 -0
  53. nlr_elm-0.0.35/elm/web/html_pw.py +103 -0
  54. nlr_elm-0.0.35/elm/web/osti.py +399 -0
  55. nlr_elm-0.0.35/elm/web/rhub.py +897 -0
  56. nlr_elm-0.0.35/elm/web/search/__init__.py +3 -0
  57. nlr_elm-0.0.35/elm/web/search/base.py +327 -0
  58. nlr_elm-0.0.35/elm/web/search/bing.py +41 -0
  59. nlr_elm-0.0.35/elm/web/search/duckduckgo.py +112 -0
  60. nlr_elm-0.0.35/elm/web/search/dux.py +83 -0
  61. nlr_elm-0.0.35/elm/web/search/google.py +317 -0
  62. nlr_elm-0.0.35/elm/web/search/run.py +455 -0
  63. nlr_elm-0.0.35/elm/web/search/tavily.py +150 -0
  64. nlr_elm-0.0.35/elm/web/search/yahoo.py +43 -0
  65. nlr_elm-0.0.35/elm/web/utilities.py +427 -0
  66. nlr_elm-0.0.35/elm/web/website_crawl.py +591 -0
  67. nlr_elm-0.0.35/elm/wizard.py +755 -0
  68. nlr_elm-0.0.35/nlr_elm.egg-info/PKG-INFO +156 -0
  69. nlr_elm-0.0.35/nlr_elm.egg-info/SOURCES.txt +80 -0
  70. nlr_elm-0.0.35/nlr_elm.egg-info/dependency_links.txt +1 -0
  71. nlr_elm-0.0.35/nlr_elm.egg-info/entry_points.txt +2 -0
  72. nlr_elm-0.0.35/nlr_elm.egg-info/not-zip-safe +1 -0
  73. nlr_elm-0.0.35/nlr_elm.egg-info/requires.txt +65 -0
  74. nlr_elm-0.0.35/nlr_elm.egg-info/top_level.txt +1 -0
  75. nlr_elm-0.0.35/setup.cfg +4 -0
  76. nlr_elm-0.0.35/setup.py +55 -0
  77. nlr_elm-0.0.35/tests/test_chunks.py +53 -0
  78. nlr_elm-0.0.35/tests/test_embed.py +48 -0
  79. nlr_elm-0.0.35/tests/test_pdf.py +51 -0
  80. nlr_elm-0.0.35/tests/test_tree.py +58 -0
  81. nlr_elm-0.0.35/tests/test_wizard.py +125 -0
  82. nlr_elm-0.0.35/tests/test_wizard_postgres.py +168 -0
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Alliance for Sustainable Energy LLC, All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: nlr_elm
3
+ Version: 0.0.35
4
+ Summary: Energy Language Model
5
+ Home-page: https://github.com/NatLabRockies/elm
6
+ Author: Grant Buster
7
+ Author-email: grant.buster@nlr.gov
8
+ License: BSD 3-Clause
9
+ Keywords: elm
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: BSD License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Requires-Python: >=3.9
18
+ License-File: LICENSE.txt
19
+ Requires-Dist: openai>=1.1.0
20
+ Requires-Dist: aiohttp
21
+ Requires-Dist: beautifulsoup4
22
+ Requires-Dist: camoufox
23
+ Requires-Dist: click
24
+ Requires-Dist: crawl4ai
25
+ Requires-Dist: ddgs
26
+ Requires-Dist: fake_useragent>=2.0.3
27
+ Requires-Dist: google-api-python-client
28
+ Requires-Dist: google-search-results
29
+ Requires-Dist: html2text
30
+ Requires-Dist: httpx
31
+ Requires-Dist: langchain-text-splitters
32
+ Requires-Dist: lxml
33
+ Requires-Dist: matplotlib
34
+ Requires-Dist: networkx
35
+ Requires-Dist: nlr-rex
36
+ Requires-Dist: nltk
37
+ Requires-Dist: numpy
38
+ Requires-Dist: pandas
39
+ Requires-Dist: tf-playwright-stealth
40
+ Requires-Dist: PyPDF2
41
+ Requires-Dist: python-slugify
42
+ Requires-Dist: rebrowser-playwright
43
+ Requires-Dist: scipy
44
+ Requires-Dist: scrapling
45
+ Requires-Dist: tabulate
46
+ Requires-Dist: tavily-python
47
+ Requires-Dist: tiktoken
48
+ Provides-Extra: dev
49
+ Requires-Dist: openai>=1.1.0; extra == "dev"
50
+ Requires-Dist: aiohttp; extra == "dev"
51
+ Requires-Dist: beautifulsoup4; extra == "dev"
52
+ Requires-Dist: camoufox; extra == "dev"
53
+ Requires-Dist: click; extra == "dev"
54
+ Requires-Dist: crawl4ai; extra == "dev"
55
+ Requires-Dist: ddgs; extra == "dev"
56
+ Requires-Dist: fake_useragent>=2.0.3; extra == "dev"
57
+ Requires-Dist: google-api-python-client; extra == "dev"
58
+ Requires-Dist: google-search-results; extra == "dev"
59
+ Requires-Dist: html2text; extra == "dev"
60
+ Requires-Dist: httpx; extra == "dev"
61
+ Requires-Dist: langchain-text-splitters; extra == "dev"
62
+ Requires-Dist: lxml; extra == "dev"
63
+ Requires-Dist: matplotlib; extra == "dev"
64
+ Requires-Dist: networkx; extra == "dev"
65
+ Requires-Dist: nlr-rex; extra == "dev"
66
+ Requires-Dist: nltk; extra == "dev"
67
+ Requires-Dist: numpy; extra == "dev"
68
+ Requires-Dist: pandas; extra == "dev"
69
+ Requires-Dist: tf-playwright-stealth; extra == "dev"
70
+ Requires-Dist: PyPDF2; extra == "dev"
71
+ Requires-Dist: python-slugify; extra == "dev"
72
+ Requires-Dist: rebrowser-playwright; extra == "dev"
73
+ Requires-Dist: scipy; extra == "dev"
74
+ Requires-Dist: scrapling; extra == "dev"
75
+ Requires-Dist: tabulate; extra == "dev"
76
+ Requires-Dist: tavily-python; extra == "dev"
77
+ Requires-Dist: tiktoken; extra == "dev"
78
+ Requires-Dist: pytest>=5.2; extra == "dev"
79
+ Requires-Dist: pytest-mock; extra == "dev"
80
+ Requires-Dist: pytest-asyncio; extra == "dev"
81
+ Requires-Dist: pytest-cov; extra == "dev"
82
+ Requires-Dist: flaky>=3.8.1; extra == "dev"
83
+ Dynamic: author
84
+ Dynamic: author-email
85
+ Dynamic: classifier
86
+ Dynamic: description
87
+ Dynamic: home-page
88
+ Dynamic: keywords
89
+ Dynamic: license
90
+ Dynamic: license-file
91
+ Dynamic: provides-extra
92
+ Dynamic: requires-dist
93
+ Dynamic: requires-python
94
+ Dynamic: summary
95
+
96
+ ***************************
97
+ Energy Language Model (ELM)
98
+ ***************************
99
+
100
+ .. image:: https://github.com/NatLabRockies/elm/workflows/Documentation/badge.svg
101
+ :target: https://natlabrockies.github.io/elm/
102
+
103
+ .. image:: https://github.com/NatLabRockies/elm/workflows/pytests/badge.svg
104
+ :target: https://github.com/NatLabRockies/elm/actions?query=workflow%3A%22pytests%22
105
+
106
+ .. image:: https://github.com/NatLabRockies/elm/workflows/Lint%20Code%20Base/badge.svg
107
+ :target: https://github.com/NatLabRockies/elm/actions?query=workflow%3A%22Lint+Code+Base%22
108
+
109
+ .. image:: https://img.shields.io/pypi/pyversions/NLR-elm.svg
110
+ :target: https://pypi.org/project/NLR-elm/
111
+
112
+ .. image:: https://badge.fury.io/py/NLR-elm.svg
113
+ :target: https://badge.fury.io/py/NLR-elm
114
+
115
+ .. image:: https://zenodo.org/badge/690793778.svg
116
+ :target: https://zenodo.org/doi/10.5281/zenodo.10070538
117
+
118
+ The Energy Language Model (ELM) software provides interfaces to apply Large Language Models (LLMs) like ChatGPT and GPT-4 to energy research. For example, you might be interested in:
119
+
120
+ - `Converting PDFs into a text database <https://natlabrockies.github.io/elm/_autosummary/elm.pdf.PDFtoTXT.html#elm.pdf.PDFtoTXT>`_
121
+ - `Chunking text documents and embedding into a vector database <https://nrenatlabrockiesl.github.io/elm/_autosummary/elm.embed.ChunkAndEmbed.html#elm.embed.ChunkAndEmbed>`_
122
+ - `Performing recursive document summarization <https://natlabrockies.github.io/elm/_autosummary/elm.summary.Summary.html#elm.summary.Summary>`_
123
+ - `Building an automated data extraction workflow using decision trees <https://natlabrockies.github.io/elm/_autosummary/elm.tree.DecisionTree.html#elm.tree.DecisionTree>`_
124
+ - `Building a chatbot app that interfaces with reports from OSTI <https://github.com/NatLabRockies/elm/tree/main/examples/energy_wizard>`_
125
+
126
+ Installing ELM
127
+ ==============
128
+
129
+ .. inclusion-install
130
+
131
+ NOTE: If you are installing ELM to run ordinance scraping and extraction,
132
+ see the `ordinance-specific installation instructions <https://github.com/NatLabRockies/elm/blob/main/elm/ords/README.md>`_.
133
+
134
+ Option #1 (basic usage):
135
+
136
+ #. ``pip install NLR-elm``
137
+
138
+ Option #2 (developer install):
139
+
140
+ #. from home dir, ``git clone git@github.com:NatLabRockies/elm.git``
141
+ #. Create ``elm`` environment and install package
142
+ a) Create a conda env: ``conda create -n elm``
143
+ b) Run the command: ``conda activate elm``
144
+ c) ``cd`` into the repo cloned in 1.
145
+ d) Prior to running ``pip`` below, make sure the branch is correct (install
146
+ from main!)
147
+ e) Install ``elm`` and its dependencies by running:
148
+ ``pip install .`` (or ``pip install -e .`` if running a dev branch
149
+ or working on the source code)
150
+
151
+ .. inclusion-acknowledgements
152
+
153
+ Acknowledgments
154
+ ===============
155
+
156
+ This work was authored by the National Laboratory of the Rockies, operated by Alliance for Energy Innovation, LLC, for the U.S. Department of Energy (DOE) under Contract No. DE-AC36-08GO28308. Funding provided by the DOE Wind Energy Technologies Office (WETO), the DOE Solar Energy Technologies Office (SETO), and internal research funds at the National Laboratory of the Rockies. The views expressed in the article do not necessarily represent the views of the DOE or the U.S. Government. The U.S. Government retains and the publisher, by accepting the article for publication, acknowledges that the U.S. Government retains a nonexclusive, paid-up, irrevocable, worldwide license to publish or reproduce the published form of this work, or allow others to do so, for U.S. Government purposes.
@@ -0,0 +1,61 @@
1
+ ***************************
2
+ Energy Language Model (ELM)
3
+ ***************************
4
+
5
+ .. image:: https://github.com/NatLabRockies/elm/workflows/Documentation/badge.svg
6
+ :target: https://natlabrockies.github.io/elm/
7
+
8
+ .. image:: https://github.com/NatLabRockies/elm/workflows/pytests/badge.svg
9
+ :target: https://github.com/NatLabRockies/elm/actions?query=workflow%3A%22pytests%22
10
+
11
+ .. image:: https://github.com/NatLabRockies/elm/workflows/Lint%20Code%20Base/badge.svg
12
+ :target: https://github.com/NatLabRockies/elm/actions?query=workflow%3A%22Lint+Code+Base%22
13
+
14
+ .. image:: https://img.shields.io/pypi/pyversions/NLR-elm.svg
15
+ :target: https://pypi.org/project/NLR-elm/
16
+
17
+ .. image:: https://badge.fury.io/py/NLR-elm.svg
18
+ :target: https://badge.fury.io/py/NLR-elm
19
+
20
+ .. image:: https://zenodo.org/badge/690793778.svg
21
+ :target: https://zenodo.org/doi/10.5281/zenodo.10070538
22
+
23
+ The Energy Language Model (ELM) software provides interfaces to apply Large Language Models (LLMs) like ChatGPT and GPT-4 to energy research. For example, you might be interested in:
24
+
25
+ - `Converting PDFs into a text database <https://natlabrockies.github.io/elm/_autosummary/elm.pdf.PDFtoTXT.html#elm.pdf.PDFtoTXT>`_
26
+ - `Chunking text documents and embedding into a vector database <https://nrenatlabrockiesl.github.io/elm/_autosummary/elm.embed.ChunkAndEmbed.html#elm.embed.ChunkAndEmbed>`_
27
+ - `Performing recursive document summarization <https://natlabrockies.github.io/elm/_autosummary/elm.summary.Summary.html#elm.summary.Summary>`_
28
+ - `Building an automated data extraction workflow using decision trees <https://natlabrockies.github.io/elm/_autosummary/elm.tree.DecisionTree.html#elm.tree.DecisionTree>`_
29
+ - `Building a chatbot app that interfaces with reports from OSTI <https://github.com/NatLabRockies/elm/tree/main/examples/energy_wizard>`_
30
+
31
+ Installing ELM
32
+ ==============
33
+
34
+ .. inclusion-install
35
+
36
+ NOTE: If you are installing ELM to run ordinance scraping and extraction,
37
+ see the `ordinance-specific installation instructions <https://github.com/NatLabRockies/elm/blob/main/elm/ords/README.md>`_.
38
+
39
+ Option #1 (basic usage):
40
+
41
+ #. ``pip install NLR-elm``
42
+
43
+ Option #2 (developer install):
44
+
45
+ #. from home dir, ``git clone git@github.com:NatLabRockies/elm.git``
46
+ #. Create ``elm`` environment and install package
47
+ a) Create a conda env: ``conda create -n elm``
48
+ b) Run the command: ``conda activate elm``
49
+ c) ``cd`` into the repo cloned in 1.
50
+ d) Prior to running ``pip`` below, make sure the branch is correct (install
51
+ from main!)
52
+ e) Install ``elm`` and its dependencies by running:
53
+ ``pip install .`` (or ``pip install -e .`` if running a dev branch
54
+ or working on the source code)
55
+
56
+ .. inclusion-acknowledgements
57
+
58
+ Acknowledgments
59
+ ===============
60
+
61
+ This work was authored by the National Laboratory of the Rockies, operated by Alliance for Energy Innovation, LLC, for the U.S. Department of Energy (DOE) under Contract No. DE-AC36-08GO28308. Funding provided by the DOE Wind Energy Technologies Office (WETO), the DOE Solar Energy Technologies Office (SETO), and internal research funds at the National Laboratory of the Rockies. The views expressed in the article do not necessarily represent the views of the DOE or the U.S. Government. The U.S. Government retains and the publisher, by accepting the article for publication, acknowledges that the U.S. Government retains a nonexclusive, paid-up, irrevocable, worldwide license to publish or reproduce the published form of this work, or allow others to do so, for U.S. Government purposes.
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Energy Language Model
4
+ """
5
+
6
+ import os
7
+ import logging
8
+ from functools import partial, partialmethod
9
+ from elm.base import ApiBase
10
+ from elm.chunk import Chunker
11
+ from elm.embed import ChunkAndEmbed
12
+ from elm.pdf import PDFtoTXT
13
+ from elm.summary import Summary
14
+ from elm.tree import DecisionTree
15
+ from elm.wizard import EnergyWizard
16
+ from elm.web.osti import OstiRecord, OstiList
17
+
18
+ __author__ = """Grant Buster"""
19
+ __email__ = "Grant.Buster@nlr.gov"
20
+
21
+ ELM_DIR = os.path.dirname(os.path.realpath(__file__))
22
+ TEST_DATA_DIR = os.path.join(os.path.dirname(ELM_DIR), 'tests', 'data')
23
+
24
+ logging.TRACE = 5
25
+ logging.addLevelName(logging.TRACE, 'TRACE')
26
+ logging.Logger.trace = partialmethod(logging.Logger.log, logging.TRACE)
27
+ logging.trace = partial(logging.log, logging.TRACE)