Spaces:
Running
Running
Istvan-Adem
commited on
Commit
·
6278824
1
Parent(s):
0b19cec
add ai
Browse files- ocr/api/message/prompts.py +14 -36
- ocr/api/message/views.py +2 -2
ocr/api/message/prompts.py
CHANGED
@@ -1,44 +1,22 @@
|
|
1 |
class OCRPrompts:
|
2 |
-
generate_general_answer = """
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
The report should be structured as follows, with each section containing only relevant information from the document:
|
9 |
|
|
|
10 |
```markdown
|
11 |
-
##
|
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 |
-
|
40 |
|
41 |
-
|
42 |
-
- Ensure that the format is followed strictly, and the output is complete without any deviations.
|
43 |
|
44 |
-
[
|
|
|
|
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 |
-
|
24 |
-
return OcrResponseWrapper(data=OcrResponse(text=
|
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()
|