stkhann commited on
Commit
dfc9ac8
·
verified ·
1 Parent(s): a91f10f

Upload 6 files

Browse files
Files changed (6) hide show
  1. .gitignore +133 -0
  2. .pre-commit-config.yaml +26 -0
  3. LICENSE +21 -0
  4. README.md +76 -0
  5. dev-requirements.txt +2 -0
  6. setup.py +48 -0
.gitignore ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+ **/models/*.txt
131
+ local/
132
+ *ipynb
133
+ query/
.pre-commit-config.yaml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ default_language_version:
2
+ python: python3
3
+ repos:
4
+ - repo: https://github.com/pre-commit/pre-commit-hooks
5
+ rev: v4.4.0
6
+ hooks:
7
+ - id: trailing-whitespace
8
+ - id: check-yaml
9
+ - id: end-of-file-fixer
10
+ - id: mixed-line-ending
11
+ - id: check-added-large-files
12
+ # - repo: https://github.com/astral-sh/ruff-pre-commit
13
+ # rev: "v0.0.270"
14
+ # hooks:
15
+ # - id: ruff
16
+ # args: [ --fix, --exit-non-zero-on-fix ]
17
+ - repo: https://github.com/psf/black
18
+ rev: "23.3.0"
19
+ hooks:
20
+ - id: black
21
+ language_version: python3
22
+ - repo: https://github.com/PyCQA/isort
23
+ rev: "5.12.0"
24
+ hooks:
25
+ - id: isort
26
+ args: [--profile=black, "--skip=__init__.py", "--filter-files"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 White Laboratory
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [![tests](https://github.com/ur-whitelab/chemcrow-public/actions/workflows/tests.yml/badge.svg)](https://github.com/ur-whitelab/chemcrow-public)
2
+ [![PyPI](https://img.shields.io/pypi/v/chemcrow)](https://img.shields.io/pypi/v/chemcrow)
3
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/chemcrow)](https://img.shields.io/pypi/pyversions/chemcrow)
4
+ [![DOI:10.1101/2020.07.15.204701](https://zenodo.org/badge/DOI/10.48550/arXiv.2304.05376.svg)](https://doi.org/10.48550/arXiv.2304.05376)
5
+ [![DOI](https://zenodo.org/badge/649361700.svg)](https://zenodo.org/doi/10.5281/zenodo.10884638)
6
+
7
+
8
+
9
+
10
+ <picture>
11
+ <source media="(prefers-color-scheme: dark)" srcset="assets/chemcrow_dark_bold.png" width='100%'>
12
+ <source media="(prefers-color-scheme: light)" srcset="assets/chemcrow_light_bold.png" width='100%'>
13
+ <img alt="ChemCrow logo" src="/assets/" width="100%">
14
+ </picture>
15
+
16
+
17
+ <br></br>
18
+
19
+
20
+ ChemCrow is an open source package for the accurate solution of reasoning-intensive chemical tasks.
21
+
22
+ Built with Langchain, it uses a collection of chemical tools including RDKit, paper-qa, as well as some relevant databases in chemistry, like Pubchem and chem-space.
23
+
24
+ ## 🤗 Try it out in [HuggingFace](https://huggingface.co/spaces/doncamilom/ChemCrow)!
25
+
26
+ [![ChemCrow Demo](assets/hf-demo.png)](https://huggingface.co/spaces/doncamilom/ChemCrow)
27
+
28
+
29
+ ## ⚠️ Note
30
+
31
+ This package does not contain all the tools described in the [ChemCrow paper](https://arxiv.org/abs/2304.05376) because
32
+ of API usage restrictions. This repo will not give the same results as that paper.
33
+
34
+ All the experiments have been released under [ChemCrow runs](https://github.com/ur-whitelab/chemcrow-runs).
35
+
36
+
37
+ ## 👩‍💻 Installation
38
+
39
+ ```
40
+ pip install chemcrow
41
+ ```
42
+
43
+ ## 🔥 Usage
44
+ First set up your API keys in your environment.
45
+ ```
46
+ export OPENAI_API_KEY=your-openai-api-key
47
+ ```
48
+
49
+ You can optionally use Serp API:
50
+
51
+ ```
52
+ export SERP_API_KEY=your-serpapi-api-key
53
+ ```
54
+
55
+ In a Python session:
56
+ ```python
57
+ from chemcrow.agents import ChemCrow
58
+
59
+ chem_model = ChemCrow(model="gpt-4-0613", temp=0.1, streaming=False)
60
+ chem_model.run("What is the molecular weight of tylenol?")
61
+ ```
62
+
63
+ ## ✅ Citation
64
+ Bran, Andres M., et al. "ChemCrow: Augmenting large-language models with chemistry tools." arXiv preprint arXiv:2304.05376 (2023).
65
+
66
+ ```bibtex
67
+ @article{bran2023chemcrow,
68
+ title={ChemCrow: Augmenting large-language models with chemistry tools},
69
+ author={Andres M Bran and Sam Cox and Oliver Schilter and Carlo Baldassari and Andrew D White and Philippe Schwaller},
70
+ year={2023},
71
+ eprint={2304.05376},
72
+ archivePrefix={arXiv},
73
+ primaryClass={physics.chem-ph},
74
+ publisher={arXiv}
75
+ }
76
+ ```
dev-requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ pre-commit
2
+ python-dotenv
setup.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import find_packages, setup
2
+
3
+ exec(open("chemcrow/version.py").read())
4
+
5
+ with open("README.md", "r", encoding="utf-8") as fh:
6
+ long_description = fh.read()
7
+
8
+ setup(
9
+ name="chemcrow",
10
+ python_requires=">=3.9, <3.12", # this temporarily fixes molbloom install, which breaks with 3.12
11
+ version=__version__,
12
+ description="Accurate solution of reasoning-intensive chemical tasks, powered by LLMs.",
13
+ author="Andres M Bran, Sam Cox, Andrew White, Philippe Schwaller",
14
+ author_email="andrew.white@rochester.edu",
15
+ url="https://github.com/ur-whitelab/chemcrow-public",
16
+ license="MIT",
17
+ packages=find_packages(),
18
+ package_data={"chemcrow": ["data/chem_wep_smi.csv"]},
19
+ install_requires=[
20
+ "ipython",
21
+ "python-dotenv",
22
+ "rdkit",
23
+ "synspace",
24
+ "openai==0.27.8",
25
+ "molbloom",
26
+ "paper-qa==1.1.1",
27
+ "google-search-results",
28
+ "langchain>=0.0.234,<=0.0.275",
29
+ "langchain_core==0.0.1",
30
+ "nest_asyncio",
31
+ "tiktoken",
32
+ "rmrkl",
33
+ #"paper-scraper@git+https://github.com/blackadad/paper-scraper.git",
34
+ "streamlit",
35
+ "rxn4chemistry",
36
+ "duckduckgo-search",
37
+ "wikipedia",
38
+ ],
39
+ test_suite="tests",
40
+ long_description=long_description,
41
+ long_description_content_type="text/markdown",
42
+ classifiers=[
43
+ "Programming Language :: Python :: 3.10",
44
+ "Programming Language :: Python :: 3.11",
45
+ "License :: OSI Approved :: MIT License",
46
+ "Operating System :: OS Independent",
47
+ ],
48
+ )