File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -163,9 +163,13 @@ async def map_fxn_summary(
163
163
success = False
164
164
165
165
if summary_llm_model and prompt_templates :
166
- data = {"question" : question , "citation" : citation , "text" : text .text } | (
167
- extra_prompt_data or {}
168
- )
166
+ data = {
167
+ "question" : question ,
168
+ "citation" : citation ,
169
+ # Strip newlines in case chunking led to blank lines,
170
+ # but not spaces, to preserve text alignment
171
+ "text" : text .text .strip ("\n " ),
172
+ } | (extra_prompt_data or {})
169
173
message_prompt , system_prompt = prompt_templates
170
174
messages = [
171
175
Message (role = "system" , content = system_prompt .format (** data )),
@@ -193,7 +197,9 @@ async def map_fxn_summary(
193
197
except KeyError :
194
198
success = False
195
199
else :
196
- context = text .text
200
+ # Strip newlines in case chunking led to blank lines,
201
+ # but not spaces, to preserve text alignment
202
+ context = text .text .strip ("\n " )
197
203
# If we don't assign scores, just default to 5.
198
204
# why 5? Because we filter out 0s in another place
199
205
# and 5/10 is the other default I could come up with
You can’t perform that action at this time.
0 commit comments