Skip to content

Commit

Permalink
Resolved evidence_detailed_citations deprecation warnings in test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbraza committed Nov 13, 2024
1 parent 365bbce commit f9f7e7d
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion paperqa/configs/contracrow.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"verbosity": 0,
"answer": {
"evidence_k": 30,
"evidence_detailed_citations": true,
"evidence_retrieval": true,
"evidence_summary_length": "about 300 words",
"evidence_skip_summary": false,
Expand Down
4 changes: 2 additions & 2 deletions paperqa/configs/debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"summary_llm": "text-completion-openai/babbage-002",
"answer": {
"evidence_k": 2,
"evidence_detailed_citations": false,
"evidence_summary_length": "25 to 50 words",
"answer_max_sources": 2,
"answer_length": "50 to 100 words",
Expand All @@ -14,6 +13,7 @@
"defer_embedding": true
},
"prompts": {
"use_json": false
"use_json": false,
"context_inner": "{name}: {text}"
}
}
4 changes: 2 additions & 2 deletions paperqa/configs/fast.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"answer": {
"evidence_k": 5,
"evidence_detailed_citations": false,
"evidence_summary_length": "25 to 50 words",
"answer_max_sources": 3,
"answer_length": "50 to 100 words",
Expand All @@ -11,7 +10,8 @@
"use_doc_details": false
},
"prompts": {
"use_json": false
"use_json": false,
"context_inner": "{name}: {text}"
},
"agent": {
"agent_type": "fake"
Expand Down
4 changes: 2 additions & 2 deletions paperqa/configs/tier1_limits.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"answer": {
"evidence_k": 5,
"evidence_detailed_citations": false,
"evidence_summary_length": "25 to 50 words",
"answer_max_sources": 3,
"answer_length": "50 to 100 words",
Expand All @@ -11,7 +10,8 @@
"use_doc_details": false
},
"prompts": {
"use_json": true
"use_json": true,
"context_inner": "{name}: {text}"
},
"llm_config": {
"rate_limit": {
Expand Down
1 change: 0 additions & 1 deletion paperqa/configs/wikicrow.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"verbosity": 0,
"answer": {
"evidence_k": 25,
"evidence_detailed_citations": true,
"evidence_retrieval": true,
"evidence_summary_length": "about 300 words",
"evidence_skip_summary": false,
Expand Down
1 change: 1 addition & 0 deletions paperqa/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ async def aquery( # noqa: PLR0912
not answer_config.evidence_detailed_citations
and "\nFrom {citation}" in context_inner_prompt
):
# Only keep "\nFrom {citation}" if we are showing detailed citations
context_inner_prompt = context_inner_prompt.replace("\nFrom {citation}", "")

inner_context_strs = [
Expand Down
3 changes: 2 additions & 1 deletion paperqa/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@
)

CONTEXT_OUTER_PROMPT = "{context_str}\n\nValid Keys: {valid_keys}"
CONTEXT_INNER_PROMPT = "{name}: {text}\nFrom {citation}"
CONTEXT_INNER_PROMPT_NOT_DETAILED = "{name}: {text}"
CONTEXT_INNER_PROMPT = f"{CONTEXT_INNER_PROMPT_NOT_DETAILED}\nFrom {{citation}}"
3 changes: 2 additions & 1 deletion tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
make_status,
)
from paperqa.docs import Docs
from paperqa.prompts import CONTEXT_INNER_PROMPT_NOT_DETAILED
from paperqa.settings import AgentSettings, IndexSettings, Settings
from paperqa.types import Context, Doc, PQASession, Text
from paperqa.utils import extract_thought, get_year, md5sum
Expand Down Expand Up @@ -382,7 +383,7 @@ async def test_propagate_options(agent_test_settings: Settings) -> None:
agent_test_settings.prompts.pre = None
agent_test_settings.prompts.system = "End all responses with ###"
agent_test_settings.answer.evidence_skip_summary = True
agent_test_settings.answer.evidence_detailed_citations = False
agent_test_settings.prompts.context_inner = CONTEXT_INNER_PROMPT_NOT_DETAILED

query = QueryRequest(
query="What is is a self-explanatory model?", settings=agent_test_settings
Expand Down
2 changes: 1 addition & 1 deletion tests/test_paperqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,9 @@ def test_context_inner_outer_prompt(stub_data_dir: Path) -> None:


def test_evidence_detailed_citations_shim(stub_data_dir: Path) -> None:

# TODO: delete this test in v6
settings = Settings.from_name("fast")
# NOTE: this bypasses DeprecationWarning, as the warning is done on construction
settings.answer.evidence_detailed_citations = False
docs = Docs()
docs.add(stub_data_dir / "bates.txt", "WikiMedia Foundation, 2023, Accessed now")
Expand Down

0 comments on commit f9f7e7d

Please sign in to comment.