Skip to content
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5675e97
Image reader and image support in `gather_evidence` (#1046)
jamesbraza Aug 6, 2025
d1cde22
Preventing Greek name from crashing `DocDetails` creation (#1048)
jamesbraza Aug 6, 2025
0caa926
Better invalid name logs (#1049)
jamesbraza Aug 6, 2025
f71d023
Multimodal PDF support (#1047)
jamesbraza Aug 7, 2025
d3760c9
Fix paperqa/configs link in README.md (#1051)
chrisranderson Aug 8, 2025
948423f
Fixing all broken links, `pymarkdown` (#1052)
jamesbraza Aug 9, 2025
d34543e
Documenting `DocMetadataTask`/`MetadataProvider` (#1050)
jamesbraza Aug 9, 2025
beb838e
chore(deps): lock file maintenance (#1053)
renovate[bot] Aug 9, 2025
81ea858
chore(deps): update actions/checkout action to v5 (#1058)
renovate[bot] Aug 11, 2025
193feb6
chore(deps): update actions/download-artifact action to v5 (#1059)
renovate[bot] Aug 11, 2025
72b7f26
Moved `mypy` to use `local` hook to unsilence it on missing dependenc…
jamesbraza Aug 11, 2025
6801155
Removed dead `patch` from `test_add_clinical_trials_to_docs` (#1056)
jamesbraza Aug 11, 2025
34ceb70
Restored `UnpaywallProvider` by updating expected response (#1057)
jamesbraza Aug 11, 2025
fab944a
Refreshed `test_crossref_journalquality_fields_filtering` cassette (#…
jamesbraza Aug 11, 2025
4862764
Updating `journal_quality.csv` from script (#1061)
jamesbraza Aug 11, 2025
2d58202
Better lookup failure message in `Settings.from_name` (#1064)
jamesbraza Aug 16, 2025
62afb8c
Lower bibtex logging to debug (#1067)
mskarlin Aug 19, 2025
687ce40
Fix: handle non-UTF-8 input in util.py
dmcgrath19 Aug 20, 2025
7a88d42
Add comments to utf-8 error handling
dmcgrath19 Aug 20, 2025
46e21d6
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Aug 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better lookup failure message in Settings.from_name (#1064)
  • Loading branch information
jamesbraza authored Aug 16, 2025
commit 2d58202f97b65070664dc5fd887e97c13ece1fad
38 changes: 21 additions & 17 deletions src/paperqa/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from pydantic.fields import FieldInfo
from pydantic_settings import BaseSettings, CliSettingsSource, SettingsConfigDict

import paperqa.configs
from paperqa._ldp_shims import (
HAS_LDP_INSTALLED,
Agent,
Expand Down Expand Up @@ -927,24 +928,25 @@ def from_name(
)
return Settings(_cli_settings_source=cli_source(args=True))

# First, try to find the config file in the user's .config directory
user_config_path = pqa_directory("settings") / f"{config_name}.json"

pkg_config_path = (
# Use importlib.resources.files() which is recommended for Python 3.9+
importlib.resources.files(paperqa.configs)
/ f"{config_name}.json"
)
if user_config_path.exists():
# First, try to find the config file in the user's .config directory
json_path = user_config_path

# If not found, fall back to the package's default config
try:
# Use importlib.resources.files() which is recommended for Python 3.9+
pkg_config_path = (
importlib.resources.files("paperqa.configs") / f"{config_name}.json"
)
if pkg_config_path.is_file():
json_path = cast("pathlib.Path", pkg_config_path)
except FileNotFoundError as e:
raise FileNotFoundError(
f"No configuration file found for {config_name}"
) from e
else:
# If not found, fall back to the package's default config
try:
if pkg_config_path.is_file():
json_path = cast("pathlib.Path", pkg_config_path)
except FileNotFoundError as e:
raise FileNotFoundError(
f"No configuration file {config_name!r} found at user config path"
f" {user_config_path} or bundled config path {pkg_config_path}."
) from e

if json_path:
# we do the ole switcheroo
Expand All @@ -956,8 +958,10 @@ def from_name(
**(tmp.model_dump()),
_cli_settings_source=cli_source(args=True) if cli_source else None,
)

raise FileNotFoundError(f"No configuration file found for {config_name}")
raise FileNotFoundError(
f"No configuration file {config_name!r} found at user config path"
f" {user_config_path} or bundled config path {pkg_config_path}."
)

def get_llm(self) -> LiteLLMModel:
return LiteLLMModel(
Expand Down