Daksh Chaudhary commited on
Commit
ed1f000
·
verified ·
1 Parent(s): 268896c

Debug: Updated the export bibtex function

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -45,13 +45,27 @@ def export_bibtex_flow(documents, file_obj):
45
  print(f"--- BibTeX Export: Starting citation extraction for {filename} ---")
46
 
47
  first_page_text = documents[0].text
 
 
 
48
  Settings.llm = get_llm()
49
- extractor_agent = create_specialist_agent(CITATION_EXTRACTOR_PROMPT, Settings.llm, [])
50
 
51
- response = extractor_agent.chat(f"Extract bibliographic data from this text: {first_page_text[:4000]}")
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
- print(f"--- BibTeX Export: Agent responded with: {response.response} ---")
54
- bibtex_string = format_to_bibtex(response.response, filename)
55
 
56
  return bibtex_string
57
 
 
45
  print(f"--- BibTeX Export: Starting citation extraction for {filename} ---")
46
 
47
  first_page_text = documents[0].text
48
+
49
+ # --- THIS IS THE CORRECTED LOGIC ---
50
+ # Instead of creating an agent, we create a direct prompt for the LLM.
51
  Settings.llm = get_llm()
 
52
 
53
+ # We combine the system prompt and the user message into one.
54
+ extraction_prompt = f"""{CITATION_EXTRACTOR_PROMPT}
55
+
56
+ Here is the text to analyze:
57
+ ---
58
+ {first_page_text[:4000]}
59
+ """
60
+
61
+ # Make a direct, simple call to the LLM.
62
+ response = Settings.llm.complete(extraction_prompt)
63
+ # --- END OF CORRECTION ---
64
+
65
+ print(f"--- BibTeX Export: LLM responded with: {response.text} ---")
66
 
67
+ # Format the extracted JSON into a BibTeX string
68
+ bibtex_string = format_to_bibtex(response.text, filename)
69
 
70
  return bibtex_string
71