@@ -309,19 +309,23 @@ async def adoc_match(
309309 if len (matched_docs ) == 0 :
310310 return set ()
311311 # this only works for gpt-4 (in my testing)
312- if cast (BaseLanguageModel , self .llm ).model_name .startswith ("gpt-4" ):
313- chain = make_chain (
314- self .prompts .select , cast (BaseLanguageModel , self .llm ), skip_system = True
315- )
316- papers = [f"{ d .docname } : { d .citation } " for d in matched_docs ]
317- result = await chain .arun ( # type: ignore
318- question = query ,
319- papers = "\n " .join (papers ),
320- callbacks = get_callbacks ("filter" ),
321- )
322- return set ([d .dockey for d in matched_docs if d .docname in result ])
323- else :
324- return set ([d .dockey for d in matched_docs ])
312+ try :
313+ if cast (BaseLanguageModel , self .llm ).model_name .startswith ("gpt-4" ):
314+ chain = make_chain (
315+ self .prompts .select ,
316+ cast (BaseLanguageModel , self .llm ),
317+ skip_system = True ,
318+ )
319+ papers = [f"{ d .docname } : { d .citation } " for d in matched_docs ]
320+ result = await chain .arun ( # type: ignore
321+ question = query ,
322+ papers = "\n " .join (papers ),
323+ callbacks = get_callbacks ("filter" ),
324+ )
325+ return set ([d .dockey for d in matched_docs if d .docname in result ])
326+ except AttributeError :
327+ pass
328+ return set ([d .dockey for d in matched_docs ])
325329
326330 def __getstate__ (self ):
327331 state = self .__dict__ .copy ()
@@ -470,14 +474,17 @@ async def process(match):
470474 citation = match .metadata ["doc" ]["citation" ]
471475 if detailed_citations :
472476 citation = match .metadata ["name" ] + ": " + citation
473- context = await summary_chain .arun (
474- question = answer .question ,
475- # Add name so chunk is stated
476- citation = citation ,
477- summary_length = answer .summary_length ,
478- text = match .page_content ,
479- callbacks = callbacks ,
480- )
477+ if self .prompts .skip_summary :
478+ context = match .page_content
479+ else :
480+ context = await summary_chain .arun (
481+ question = answer .question ,
482+ # Add name so chunk is stated
483+ citation = citation ,
484+ summary_length = answer .summary_length ,
485+ text = match .page_content ,
486+ callbacks = callbacks ,
487+ )
481488 except Exception as e :
482489 if guess_is_4xx (str (e )):
483490 return None
0 commit comments