Skip to content

Commit 9cd976a

Browse files
mskarlinjamesbraza
andauthored
Agentic workflows, locally indexed search, and CLI (#309)
* add agentic workflow module and cli * update pyproject.toml and split google into its own import * remove unused import * update default search chain * Update __init__.py * Update search.py * move reqs into pyproject.toml, addressing PR comments * rename search_chain to openai_get_search_query * remove get_llm_name * move table_formatter to helpers.py * Update paperqa/agents/main.py Co-authored-by: James Braza <[email protected]> * Update paperqa/agents/main.py Co-authored-by: James Braza <[email protected]> * Update paperqa/agents/main.py Co-authored-by: James Braza <[email protected]> * Update paperqa/agents/docs.py Co-authored-by: James Braza <[email protected]> * Update paperqa/types.py Co-authored-by: James Braza <[email protected]> * rename compute_cost to compute_total_model_token_cost * remove stream_answer * rename to stub_manifest, and use Path for all paths * Update paperqa/llms.py Co-authored-by: James Braza <[email protected]> * move SKIP_AGENT_TESTS = False * nix _ = assignments * add test comments * types in conftest.py * split libs into llms * link openai chat timeout to query.timeout * Update paperqa/agents/__init__.py Co-authored-by: James Braza <[email protected]> * logging revamp and renaming * Update tests/test_cli.py Co-authored-by: James Braza <[email protected]> * Update tests/test_cli.py Co-authored-by: James Braza <[email protected]> * move vertex import to func call, add docstring to SupportsPickle * docstring * remove _ = * remove bool return type from set * update gitignore * add config attribute to baase LLMModel class * replace get_current_settings -> get_settings * replace get_current_settings -> get_settings * PR simplifications * remove all stream_* functions * avoid modifying the root logger * re-organize logger import location * move hashlib into utils * refactor strip_answer into Answer object * label circular imports * ensure absolute paths are used in index name * limit select to be used only when DOI is not present in crossref * Update paperqa/agents/search.py Co-authored-by: James Braza <[email protected]> * Update paperqa/agents/search.py Co-authored-by: James Braza <[email protected]> * Update paperqa/agents/search.py Co-authored-by: James Braza <[email protected]> * Update paperqa/agents/search.py Co-authored-by: James Braza <[email protected]> * Update paperqa/agents/models.py Co-authored-by: James Braza <[email protected]> * reconfigure logging to not prevent propagation * remove newlines in the current year * use required fields as a subset * replace . with Path.cwd() --------- Co-authored-by: James Braza <[email protected]>
1 parent eced4f3 commit 9cd976a

26 files changed

+3777
-73
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
python-version: 3.11
1818
cache: pip
19-
- run: pip install .[dev]
19+
- run: pip install .[agents,google,dev,llms]
2020
- name: Build a binary wheel and a source tarball
2121
run: |
2222
python -m build --sdist --wheel --outdir dist/ .

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
cache: pip
23-
- run: pip install .[dev]
23+
- run: pip install .[agents,google,dev,llms]
2424
- name: Check pre-commit
2525
run: pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
2626
- name: Run Test

.gitignore

Lines changed: 171 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,138 @@
1+
# Swap
2+
[._]*.s[a-v][a-z]
3+
!*.svg # comment out if you don't need vector files
4+
[._]*.sw[a-p]
5+
[._]s[a-rt-v][a-z]
6+
[._]ss[a-gi-z]
7+
[._]sw[a-p]
8+
9+
# Session
10+
Session.vim
11+
Sessionx.vim
12+
13+
# Temporary
14+
.netrwhist
15+
*~
16+
# Auto-generated tag files
17+
tags
18+
# Persistent undo
19+
[._]*.un~
20+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
21+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
22+
23+
# User-specific stuff
24+
.idea/**/workspace.xml
25+
.idea/**/tasks.xml
26+
.idea/**/usage.statistics.xml
27+
.idea/**/dictionaries
28+
.idea/**/shelf
29+
30+
# AWS User-specific
31+
.idea/**/aws.xml
32+
33+
# Generated files
34+
.idea/**/contentModel.xml
35+
36+
# Sensitive or high-churn files
37+
.idea/**/dataSources/
38+
.idea/**/dataSources.ids
39+
.idea/**/dataSources.local.xml
40+
.idea/**/sqlDataSources.xml
41+
.idea/**/dynamic.xml
42+
.idea/**/uiDesigner.xml
43+
.idea/**/dbnavigator.xml
44+
45+
# Gradle
46+
.idea/**/gradle.xml
47+
.idea/**/libraries
48+
49+
# Gradle and Maven with auto-import
50+
# When using Gradle or Maven with auto-import, you should exclude module files,
51+
# since they will be recreated, and may cause churn. Uncomment if using
52+
# auto-import.
53+
# .idea/artifacts
54+
# .idea/compiler.xml
55+
# .idea/jarRepositories.xml
56+
# .idea/modules.xml
57+
# .idea/*.iml
58+
# .idea/modules
59+
# *.iml
60+
# *.ipr
61+
62+
# CMake
63+
cmake-build-*/
64+
65+
# Mongo Explorer plugin
66+
.idea/**/mongoSettings.xml
67+
68+
# File-based project format
69+
*.iws
70+
71+
# IntelliJ
72+
out/
73+
74+
# mpeltonen/sbt-idea plugin
75+
.idea_modules/
76+
77+
# JIRA plugin
78+
atlassian-ide-plugin.xml
79+
80+
# Cursive Clojure plugin
81+
.idea/replstate.xml
82+
83+
# SonarLint plugin
84+
.idea/sonarlint/
85+
86+
# Crashlytics plugin (for Android Studio and IntelliJ)
87+
com_crashlytics_export_strings.xml
88+
crashlytics.properties
89+
crashlytics-build.properties
90+
fabric.properties
91+
92+
# Editor-based Rest Client
93+
.idea/httpRequests
94+
95+
# Android studio 3.1+ serialized cache file
96+
.idea/caches/build_file_checksums.ser
97+
.vscode/*
98+
!.vscode/settings.json
99+
!.vscode/tasks.json
100+
!.vscode/launch.json
101+
!.vscode/extensions.json
102+
!.vscode/*.code-snippets
103+
104+
# Local History for Visual Studio Code
105+
.history/
106+
107+
# Built Visual Studio Code Extensions
108+
*.vsix
109+
# General
110+
.DS_Store
111+
.AppleDouble
112+
.LSOverride
113+
114+
# Icon must end with two \r
115+
Icon[\r]
116+
117+
118+
# Thumbnails
119+
._*
120+
121+
# Files that might appear in the root of a volume
122+
.DocumentRevisions-V100
123+
.fseventsd
124+
.Spotlight-V100
125+
.TemporaryItems
126+
.Trashes
127+
.VolumeIcon.icns
128+
.com.apple.timemachine.donotpresent
129+
130+
# Directories potentially created on remote AFP share
131+
.AppleDB
132+
.AppleDesktop
133+
Network Trash Folder
134+
Temporary Items
135+
.apdisk
1136
# Byte-compiled / optimized / DLL files
2137
__pycache__/
3138
*.py[cod]
@@ -20,7 +155,6 @@ parts/
20155
sdist/
21156
var/
22157
wheels/
23-
pip-wheel-metadata/
24158
share/python-wheels/
25159
*.egg-info/
26160
.installed.cfg
@@ -50,6 +184,7 @@ coverage.xml
50184
*.py,cover
51185
.hypothesis/
52186
.pytest_cache/
187+
cover/
53188

54189
# Translations
55190
*.mo
@@ -72,6 +207,7 @@ instance/
72207
docs/_build/
73208

74209
# PyBuilder
210+
.pybuilder/
75211
target/
76212

77213
# Jupyter Notebook
@@ -82,7 +218,9 @@ profile_default/
82218
ipython_config.py
83219

84220
# pyenv
85-
.python-version
221+
# For a library or package, you might want to ignore these files since the code is
222+
# intended to run in multiple environments; otherwise, check them in:
223+
# .python-version
86224

87225
# pipenv
88226
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
@@ -91,7 +229,24 @@ ipython_config.py
91229
# install all needed dependencies.
92230
#Pipfile.lock
93231

94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
232+
# poetry
233+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
234+
# This is especially recommended for binary packages to ensure reproducibility, and is more
235+
# commonly ignored for libraries.
236+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
237+
#poetry.lock
238+
239+
# pdm
240+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
241+
#pdm.lock
242+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
243+
# in version control.
244+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
245+
.pdm.toml
246+
.pdm-python
247+
.pdm-build/
248+
249+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
95250
__pypackages__/
96251

97252
# Celery stuff
@@ -128,12 +283,23 @@ dmypy.json
128283
# Pyre type checker
129284
.pyre/
130285

131-
# testing files generated
132-
*.txt.json
286+
# pytype static type analyzer
287+
.pytype/
288+
289+
# Cython debug symbols
290+
cython_debug/
291+
292+
# PyCharm
293+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
294+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
295+
# and can be added to the global gitignore or merged into this file. For a more nuclear
296+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
297+
#.idea/
133298

134299
*.ipynb
135300
env
136301

137302
# Matching pyproject.toml
138303
paperqa/version.py
139304
tests/example*
305+
tests/test_index/*

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
- id: mixed-line-ending
2323
- id: trailing-whitespace
2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: v0.5.0
25+
rev: v0.6.2
2626
hooks:
2727
- id: ruff
2828
args: [--fix, --exit-non-zero-on-fix]
@@ -41,6 +41,7 @@ repos:
4141
- pydantic~=2.0 # Match pyproject.toml
4242
- types-requests
4343
- types-setuptools
44+
- types-PyYAML
4445
- repo: https://github.com/rbubley/mirrors-prettier
4546
rev: v3.3.2
4647
hooks:

dev-requirements.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)