Istvan-Adem commited on
Commit
6278824
·
1 Parent(s): 0b19cec
ocr/api/message/prompts.py CHANGED
@@ -1,44 +1,22 @@
1
  class OCRPrompts:
2
- generate_general_answer = """## Task
3
 
4
- You must analyze the text extracted from medical document and generate a comprehensive report in **Markdown2** format. Ensure that every detail provided in the document is included, and do not omit or modify any information. Your output must strictly follow the required format.
 
 
 
 
5
 
6
- ## Report Structure
7
-
8
- The report should be structured as follows, with each section containing only relevant information from the document:
9
 
 
10
  ```markdown
11
- ## Patient Information
12
-
13
- - Name: [Patient Name]
14
- - Age: [Patient Age]
15
- - Date of Scan: [Date]
16
- - Indication: [Reason for the CT scan]
17
-
18
- ## Findings
19
-
20
- **Primary findings**:
21
- [Describe significant abnormalities or findings relevant to the indication]
22
-
23
- ** Secondary findings**:
24
- [List incidental findings, e.g., "Mild hepatic steatosis noted."]
25
- **No abnormalities**:
26
- [Mention organs or systems without abnormalities, e.g., "No evidence of lymphadenopathy or pleural effusion."]
27
-
28
- ## Impression
29
-
30
- [Summarize the findings concisely, e.g., "Findings suggest a primary lung tumor. Biopsy recommended for further evaluation."]
31
-
32
- ## Recommendations
33
-
34
- [Include next steps or further tests, e.g., "PET scan and consultation with oncology recommended."]
35
- ```
36
-
37
- [INST]
38
 
39
- ## Instructions
40
 
41
- - **Do not invent or infer any information.** Only use data provided in the user request.
42
- - Ensure that the format is followed strictly, and the output is complete without any deviations.
43
 
44
- [/INST]"""
 
 
1
  class OCRPrompts:
2
+ generate_general_answer = """*Task:* Generate a concise and structured report based on the extracted text from a file. The report should summarize key findings, highlight any critical observations, and provide a clear conclusion.
3
 
4
+ **Instruction:**
5
+ 1. **Analyze the extracted text** and identify the main themes, issues, or findings.
6
+ 2. **Structure the report** into the following sections:
7
+ - **Simple Overview:** A brief summary of the key points in the extracted text.
8
+ - **Conclusion:** A succinct evaluation or interpretation of the findings, including any necessary recommendations or next steps.
9
 
10
+ 3. **Ensure clarity and conciseness** in the report. Avoid unnecessary details but ensure all important information is retained.
11
+ 4. **Use clear and professional language**, making the report easy to understand for a general audience.
 
12
 
13
+ **Format Example:**
14
  ```markdown
15
+ ## Simple Overview of the Report
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ [Provide a brief and clear summary of the main points from the extracted text.]
18
 
19
+ ## Conclusion
 
20
 
21
+ [Summarize key insights and provide any recommendations based on the findings.]
22
+ ```"""
ocr/api/message/views.py CHANGED
@@ -20,7 +20,7 @@ async def get_all_chat_messages(
20
  else:
21
  raise HTTPException(status_code=400, detail='Unsupported file type.')
22
  text_content = extract_text_from_images(images)
23
- # response = await generate_report(text_content)
24
- return OcrResponseWrapper(data=OcrResponse(text=text_content))
25
  finally:
26
  await file.close()
 
20
  else:
21
  raise HTTPException(status_code=400, detail='Unsupported file type.')
22
  text_content = extract_text_from_images(images)
23
+ response = await generate_report(text_content)
24
+ return OcrResponseWrapper(data=OcrResponse(text=clean_response(response)))
25
  finally:
26
  await file.close()