File size: 1,146 Bytes
5218d60 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | """Prepare a question with source notes that all three seats can read."""
import argparse
from pathlib import Path
from reference import retrieve
def brief(root, question):
sections = []
for database in sorted((root / "sources").glob("*/references.sqlite")):
hits = retrieve(database, question)
if hits:
notes = "\n\n".join(f"{h['title']}\n{h['url']}\n{h['body']}" for h in hits)
sections.append(f"{database.parent.name}\n{notes}")
if not sections:
return question
return (
"Reference notes for all participants and the synthesizer. "
"For the final answer, cover each part of the question. Use the relevant passages "
"to resolve conflicts between drafts, cite their documentation, and identify "
"any dispute the sources do not settle.\n\n"
+ "\n\n".join(sections)
+ "\n\nQuestion: "
+ question
)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("question")
args = parser.parse_args()
print(brief(Path(__file__).resolve().parent, args.question))
|