From edc6a7e4f7835404a1dfa59e3a8bb15b69d2550e Mon Sep 17 00:00:00 2001 From: James Braza Date: Fri, 7 Nov 2025 10:31:20 -0800 Subject: [PATCH 1/2] Added description to Context.score, with updated default value of -1 --- src/paperqa/types.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/paperqa/types.py b/src/paperqa/types.py index f1716ac64..8f847db23 100644 --- a/src/paperqa/types.py +++ b/src/paperqa/types.py @@ -216,6 +216,9 @@ class Context(BaseModel): # or useful excerpts of text model_config = ConfigDict(extra="allow") + # Value was chosen to be below a 0-10 scale, making the 'unset' nature obvious + UNSET_RELEVANCE: ClassVar[int] = -1 + id: str = Field( default=AUTOPOPULATE_VALUE, description="Unique identifier for the context. Auto-generated if not provided.", @@ -236,7 +239,15 @@ class Context(BaseModel): ), ) text: Text - score: int = 5 + score: int = Field( + default=UNSET_RELEVANCE, + description=( + "Relevance score for this context to the question." + " The range used here is 0-10, where 0 is 'irrelevant'," + " 1 is barely relevant, and 10 is most relevant." + " The default is -1 to have a 'sorting safe' default as sub-relevant." + ), + ) CONTEXT_ENCODING_LENGTH: ClassVar[int] = 500 # chars ID_HASH_LENGTH: ClassVar[int] = 8 # chars From 0ae1c1c0efff9446aaae402fe3975fd2eecb5ac2 Mon Sep 17 00:00:00 2001 From: James Braza Date: Fri, 7 Nov 2025 10:57:12 -0800 Subject: [PATCH 2/2] Adjusted wording in Context.context description to match --- src/paperqa/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/paperqa/types.py b/src/paperqa/types.py index 8f847db23..601614c2c 100644 --- a/src/paperqa/types.py +++ b/src/paperqa/types.py @@ -227,8 +227,8 @@ class Context(BaseModel): context: Annotated[str, StringConstraints(strip_whitespace=True)] = Field( description=( "Summary of the text with respect to a question." - " Can be an empty string if a summary is not useful" - " (which should accompany a score of 0)." + " Can be an empty string if a summary is not useful/irrelevant" + " (which should be paired with a score of 0)." ) ) question: str | None = Field(