\"}."} ,
{"role": "user", "content": USER_INPUT},
]
responses = asyncio.run(
generate_from_openai_chat_completion(
client,
messages=[messages],
engine_name="gpt-4.1-mini", # gpt-3.5-turbo
max_tokens=1000, # 32
requests_per_minute = 20,
response_format={"type":"json_object"},
)
)
response = json.loads(responses[0])
title = response["title"]
abstract = response["abstract"]
client = Mistral(api_key=MISTRAL_API)
file_object.seek(0)
uploaded_file = client.files.upload(
file={
"file_name": "upload.pdf",
"content": file_object.read(),
},
purpose="ocr",
)
signed_url = client.files.get_signed_url(file_id=uploaded_file.id, expiry=1)
pdf_response = client.ocr.process(document=DocumentURLChunk(document_url=signed_url.url), model="mistral-ocr-latest", include_image_base64=True)
# response_dict = json.loads(pdf_response.json())
extracted_text = get_combined_markdown(pdf_response)
return extracted_text, title, abstract
def main(api,api_base, paper_pdf, aspect, model_name, limit_num, enable_rag):
start_time = time.time()
# print("key: ", PRIVATE_API_KEY, "\nbase: ", PRIVATE_API_BASE)
comments = ''
output2 = ''
retrieved_content = ''
if not api or not paper_pdf or not api_base:
comments = "It looks like there's a missing API key/base URL or PDF input. Make sure you've provided the necessary information or uploaded the required file."
output2 = "It looks like there's a missing API key or PDF input. Make sure you've provided the necessary information or uploaded the required file."
if not limit_num.isdigit() or int(limit_num) <= 0:
comments = "The input number is not a positive integer."
output2 = "The input number is not a positive integer."
else:
try:
reviewer1 = Reviewer(api,api_base, paper_pdf, aspect, model_name, limit_num, enable_rag)
comments, retrieved_content = reviewer1.review_by_chatgpt(paper_list=paper_pdf)
time_used = time.time() - start_time
output2 ="Processing Time:"+ str(round(time_used, 2)) +"seconds"
except Exception as e:
comments = "Error: "+ str(e)
output2 = "Error: "+ str(e)
return retrieved_content, comments, output2
########################################################################################################
title = "Acceleron - Critique - Limitation Generation with Actionable Feedback"
description = '''
We present a demo for our paper: Can LLMs Identify Critical Limitations within Scientific Research? A Systematic Evaluation on AI Research Papers. Upload the PDF of the paper you want to review, and the demo will automatically generate its identified limitations.
'''
inp = [gradio.Textbox(label="Enter your API-key",
value="",
type='password'),
gradio.Textbox(label="Enter the base URL (ending with /v1). Skip this step if using the original OpenAI API.",
value="https://api.openai.com/v1"),
gradio.File(label="Upload the PDF file of your paper (Make sure the PDF is fully uploaded before clicking Submit)",type="binary"),
gradio.Radio(choices=["Methodology", "Experimental Design", "Result Analysis", "Literature Review"],
value="Methodology",
label="Select the aspect"),
gradio.Dropdown(["gpt-4.1-mini","gpt-4.1"],
label="Select the model name",
value="gpt-4.1"),
gradio.Textbox(label="Enter the number of limitations to generate.",
value="3"),
gradio.Checkbox(label="Enable RAG", value=False),
]
chat_reviewer_gui = gradio.Interface(fn=main,
inputs=inp,
outputs = [gradio.Textbox(lines=6, label="Retrieved Literature"), gradio.Textbox(lines=15, label="Output"), gradio.Textbox(lines=2, label="Resource Statistics")],
title=title,
description=description)
# Start server
chat_reviewer_gui .launch(quiet=True, show_api=False)