trish06 commited on
Commit
70e5777
·
verified ·
1 Parent(s): 6752374

Update backend/main.py

Browse files
Files changed (1) hide show
  1. backend/main.py +5 -5
backend/main.py CHANGED
@@ -179,8 +179,8 @@ def extract_text_from_pdf(pdf_path: str) -> str:
179
  text = text[chars // 10: chars // 10 + 15000]
180
 
181
  words = text.split()
182
- if len(words) > 1200:
183
- text = " ".join(words[:1200])
184
 
185
  text = text.replace("\n", " ")
186
 
@@ -220,7 +220,7 @@ def parse_json_response(raw: str) -> dict:
220
 
221
 
222
  def call_groq_with_backoff(client: Groq, messages: list) -> str:
223
- word_limits = [1800, 1400, 1100, 900]
224
  attempt = 0
225
  while attempt < len(word_limits):
226
  try:
@@ -228,7 +228,7 @@ def call_groq_with_backoff(client: Groq, messages: list) -> str:
228
  model=GROQ_MODEL,
229
  messages=messages,
230
  temperature=0.1,
231
- max_tokens=1200,
232
  )
233
  return response.choices[0].message.content
234
  except Exception as e:
@@ -272,7 +272,7 @@ def compare_protocols(client: Groq, extracted: list, paper_names: list) -> dict:
272
  for i, (e, name) in enumerate(zip(extracted, paper_names)):
273
  sections.append(
274
  f"=== Paper {i+1}: {e.get('title', name)} ===\n"
275
- f"{json.dumps(e.get('parameters', {}))[:3000]}"
276
  )
277
  prompt = (
278
  f"Compare these {len(extracted)} research paper protocols "
 
179
  text = text[chars // 10: chars // 10 + 15000]
180
 
181
  words = text.split()
182
+ if len(words) > 1500:
183
+ text = " ".join(words[:1500])
184
 
185
  text = text.replace("\n", " ")
186
 
 
220
 
221
 
222
  def call_groq_with_backoff(client: Groq, messages: list) -> str:
223
+ word_limits = [2500, 2000, 1500, 1000]
224
  attempt = 0
225
  while attempt < len(word_limits):
226
  try:
 
228
  model=GROQ_MODEL,
229
  messages=messages,
230
  temperature=0.1,
231
+ max_tokens=2000,
232
  )
233
  return response.choices[0].message.content
234
  except Exception as e:
 
272
  for i, (e, name) in enumerate(zip(extracted, paper_names)):
273
  sections.append(
274
  f"=== Paper {i+1}: {e.get('title', name)} ===\n"
275
+ f"{json.dumps(e.get('parameters', {}), indent=2)}"
276
  )
277
  prompt = (
278
  f"Compare these {len(extracted)} research paper protocols "