Skip to content

Commit

Permalink
14 missing content (#16)
Browse files Browse the repository at this point in the history
* refactor: prompt flex to different keywords

* refactor: add name placeholder but no speaker assigned

* refactor: add model name to report
  • Loading branch information
Edward-Jackson-ONS authored Aug 19, 2024
1 parent e435f32 commit 5ce8690
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/parliai_public/_config/debates.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ prompt = """
You are a skim reader, specialising in capturing the key points in
frenetic parliamentary debate.
Using only the text provided, you will extract ONLY sentences verbatim
which exactly match to any of these {keywords}.
which exactly reference {keywords}. You may include sentences before and/or after
that provide useful and relevant context.
Do not paraphrase.
Do not return any answer or message if there isn't anything relevant in the text.
Do not include any political asides which do not reference any of these {keywords}.
Now extract all relevant content from the following text:
Expand Down
4 changes: 2 additions & 2 deletions src/parliai_public/_config/wrans.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ prompt = """
You are a skim reader, specialising in capturing the key points in
written parliamentary communications.
Using only the text provided, you will extract ONLY sentences verbatim
which exactly match to any of these {keywords}.
which exactly reference {keywords}. You may include sentences before and/or after
that provide useful and relevant context.
Do not paraphrase.
Do not return any answer or message if there isn't anything relevant in the text.
Do not include any political asides which do not reference any of these {keywords}.
Now extract all relevant content from the following text:
Expand Down
1 change: 1 addition & 0 deletions src/parliai_public/readers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ def make_header(self, urls: list[str] = None) -> str:
f"Publication date: {today}",
f"Period covered: {period}",
f"Search terms: {self.terms}",
f"Model used: {self.llm_name}",
"\n".join((source, *links)),
)
)
Expand Down
21 changes: 15 additions & 6 deletions src/parliai_public/readers/theyworkforyou.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,21 @@ def render(self, transcript: dict) -> str:
title = f"## {label}: [{transcript['title']}]({transcript['url']})"
processed = []
for speech in transcript["speeches"]:
if speech["name"] and "response" in speech:
speaker = (
f"### [{speech['name']}]({speech['url']})"
f" ({speech['position']})"
)
processed.append("\n\n".join((speaker, speech["response"])))
if "response" in speech:
if speech["name"]:
speaker = (
f"### [{speech['name']}]({speech['url']})"
f" ({speech['position']})"
)
processed.append(
"\n\n".join((speaker, speech["response"]))
)
else:
# if no speaker, return placeholder and response
speaker = "### No speaker assigned"
processed.append(
"\n\n".join((speaker, speech["response"]))
)

return "\n\n".join((title, *processed))

Expand Down

0 comments on commit 5ce8690

Please sign in to comment.