Spaces:
Sleeping
Sleeping
revert to og
Browse files- backend/main.py +31 -80
backend/main.py
CHANGED
|
@@ -40,98 +40,49 @@ GROQ_MODEL = "llama-3.3-70b-versatile"
|
|
| 40 |
GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")
|
| 41 |
|
| 42 |
# ββ Prompts βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 43 |
-
EXTRACTION_SYSTEM = """
|
| 44 |
-
You are an expert in bioengineering and experimental reproducibility.
|
| 45 |
-
|
| 46 |
-
Extract structured protocol parameters from the Methods section of a research paper.
|
| 47 |
-
|
| 48 |
-
Return ONLY valid JSON:
|
| 49 |
-
|
| 50 |
{
|
| 51 |
-
"title": "",
|
| 52 |
-
"authors": "",
|
| 53 |
-
"year": "",
|
| 54 |
-
"protocol_type": "",
|
| 55 |
"parameters": {
|
| 56 |
-
"reagents": [],
|
| 57 |
-
"cell_lines": [],
|
| 58 |
-
"
|
| 59 |
-
"
|
| 60 |
-
"
|
| 61 |
-
"
|
| 62 |
-
"
|
| 63 |
-
"
|
| 64 |
-
"selection": [],
|
| 65 |
-
"analysis_pipeline": [],
|
| 66 |
-
"other": []
|
| 67 |
}
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
Guidelines:
|
| 71 |
-
|
| 72 |
-
- Extract exact numerical values with units
|
| 73 |
-
- Preserve scientific names exactly as written
|
| 74 |
-
- Include concentrations, temperatures, durations, and volumes
|
| 75 |
-
- If a value is missing, write "Not specified"
|
| 76 |
-
- Do not summarize or infer missing data
|
| 77 |
-
- Focus on experimentally relevant parameters only
|
| 78 |
-
"""
|
| 79 |
-
|
| 80 |
-
COMPARISON_SYSTEM = """
|
| 81 |
-
You are a senior scientist evaluating experimental reproducibility.
|
| 82 |
-
|
| 83 |
-
Compare protocols from multiple research papers and identify methodological contradictions.
|
| 84 |
-
|
| 85 |
-
Return ONLY valid JSON:
|
| 86 |
|
|
|
|
|
|
|
|
|
|
| 87 |
{
|
| 88 |
-
"protocol_type": "",
|
| 89 |
"contradictions": [
|
| 90 |
{
|
| 91 |
-
"parameter": "",
|
| 92 |
-
"category": "",
|
| 93 |
"severity": "high|medium|low",
|
| 94 |
-
"values": {
|
| 95 |
-
|
| 96 |
-
"paper_1": ""
|
| 97 |
-
},
|
| 98 |
-
"explanation": ""
|
| 99 |
}
|
| 100 |
],
|
| 101 |
-
"ranked_issues": [
|
|
|
|
|
|
|
| 102 |
"optimal_protocol": {
|
| 103 |
-
"rationale": "",
|
| 104 |
-
"parameters": [
|
|
|
|
|
|
|
| 105 |
},
|
| 106 |
-
"summary": {
|
| 107 |
-
|
| 108 |
-
"high": 0,
|
| 109 |
-
"medium": 0,
|
| 110 |
-
"low": 0
|
| 111 |
-
}
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
Rules:
|
| 115 |
-
|
| 116 |
-
1. A contradiction exists when the same parameter has different numerical values.
|
| 117 |
-
2. Always report exact numbers with units.
|
| 118 |
-
3. Ignore parameters that appear in only one paper.
|
| 119 |
-
4. Do not compare unrelated reagents or buffers.
|
| 120 |
-
5. Focus on parameters that affect reproducibility.
|
| 121 |
-
|
| 122 |
-
Severity guide:
|
| 123 |
-
|
| 124 |
-
HIGH:
|
| 125 |
-
- affects experimental outcome
|
| 126 |
-
- changes biological behavior
|
| 127 |
-
- alters measurement conditions
|
| 128 |
-
|
| 129 |
-
MEDIUM:
|
| 130 |
-
- affects efficiency or data quality
|
| 131 |
-
|
| 132 |
-
LOW:
|
| 133 |
-
- minor procedural differences
|
| 134 |
-
"""
|
| 135 |
|
| 136 |
# ββ Core helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 137 |
|
|
|
|
| 40 |
GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")
|
| 41 |
|
| 42 |
# ββ Prompts βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 43 |
+
EXTRACTION_SYSTEM = """Extract protocol parameters from this research paper. Return ONLY valid JSON:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
{
|
| 45 |
+
"title": "paper title",
|
| 46 |
+
"authors": "first author et al.",
|
| 47 |
+
"year": "year",
|
| 48 |
+
"protocol_type": "e.g. Western blot / ELISA / PCR",
|
| 49 |
"parameters": {
|
| 50 |
+
"reagents": [{"name": "...", "concentration": "...", "vendor": "..."}],
|
| 51 |
+
"cell_lines": [{"name": "...", "culture_conditions": "...", "serum": "..."}],
|
| 52 |
+
"temperatures": [{"step": "...", "value": "...", "unit": "C"}],
|
| 53 |
+
"timings": [{"step": "...", "duration": "..."}],
|
| 54 |
+
"equipment": [{"name": "...", "settings": "..."}],
|
| 55 |
+
"buffers": [{"name": "...", "composition": "...", "pH": "..."}],
|
| 56 |
+
"antibodies": [{"target": "...", "dilution": "...", "vendor": "..."}],
|
| 57 |
+
"other": [{"parameter": "...", "value": "..."}]
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
+
}"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
COMPARISON_SYSTEM = """You are an expert in bioengineering reproducibility and experimental methodology.
|
| 62 |
+
Compare protocols from multiple research papers and identify ALL methodological contradictions.
|
| 63 |
+
Return ONLY valid JSON (no markdown fences, no extra text) using this schema:
|
| 64 |
{
|
| 65 |
+
"protocol_type": "detected protocol type",
|
| 66 |
"contradictions": [
|
| 67 |
{
|
| 68 |
+
"parameter": "parameter name",
|
| 69 |
+
"category": "reagents|cell_lines|temperatures|timings|equipment|buffers|antibodies|other",
|
| 70 |
"severity": "high|medium|low",
|
| 71 |
+
"values": {"paper_0": "value from paper 1", "paper_1": "value from paper 2"},
|
| 72 |
+
"explanation": "why this is a contradiction and its likely impact on reproducibility"
|
|
|
|
|
|
|
|
|
|
| 73 |
}
|
| 74 |
],
|
| 75 |
+
"ranked_issues": [
|
| 76 |
+
{"rank": 1, "parameter": "...", "severity": "high|medium|low", "brief": "one-sentence impact"}
|
| 77 |
+
],
|
| 78 |
"optimal_protocol": {
|
| 79 |
+
"rationale": "overall recommendation rationale",
|
| 80 |
+
"parameters": [
|
| 81 |
+
{"label": "parameter name", "value": "recommended value", "reason": "why this is optimal"}
|
| 82 |
+
]
|
| 83 |
},
|
| 84 |
+
"summary": {"total_contradictions": 0, "high": 0, "medium": 0, "low": 0}
|
| 85 |
+
}"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
# ββ Core helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 88 |
|