David Chu commited on
Commit
f045eec
·
unverified ·
1 Parent(s): d9a5339

fix: spaces between sentences

Browse files
Files changed (1) hide show
  1. main.py +9 -5
main.py CHANGED
@@ -5,14 +5,15 @@ from app import agent, config, models
5
 
6
 
7
  def format_output(statements: models.Statements) -> tuple[str, str]:
8
- answer = ""
9
  citations = {}
10
 
11
  for statement in statements.statements:
12
- if statement.text.startswith(("*", "-")):
 
 
13
  # Bullet points should be on a newline.
14
- answer += "\n"
15
- answer += statement.text
16
 
17
  if statement.sources:
18
  citation_ids = []
@@ -21,8 +22,11 @@ def format_output(statements: models.Statements) -> tuple[str, str]:
21
  citation_id = len(citations) + 1
22
  citations[source.citation] = citation_id
23
  citation_ids.append(citation_id)
24
- answer += " ".join(f"[^{i}]" for i in sorted(citation_ids))
 
 
25
 
 
26
  footnotes = "\n".join(f"[^{id}]: {citation}" for citation, id in citations.items())
27
  return answer, footnotes
28
 
 
5
 
6
 
7
  def format_output(statements: models.Statements) -> tuple[str, str]:
8
+ sentences = []
9
  citations = {}
10
 
11
  for statement in statements.statements:
12
+ sentence = statement.text
13
+
14
+ if sentence.startswith(("*", "-")):
15
  # Bullet points should be on a newline.
16
+ sentence = f"\n{sentence}"
 
17
 
18
  if statement.sources:
19
  citation_ids = []
 
22
  citation_id = len(citations) + 1
23
  citations[source.citation] = citation_id
24
  citation_ids.append(citation_id)
25
+ sentence += " ".join(f"[^{i}]" for i in sorted(citation_ids))
26
+
27
+ sentences.append(sentence)
28
 
29
+ answer = " ".join(sentences)
30
  footnotes = "\n".join(f"[^{id}]: {citation}" for citation, id in citations.items())
31
  return answer, footnotes
32