Spaces:
Sleeping
Sleeping
Update genesis/pipeline.py
Browse files- genesis/pipeline.py +10 -12
genesis/pipeline.py
CHANGED
@@ -1,31 +1,29 @@
|
|
1 |
# genesis/pipeline.py
|
2 |
import os
|
3 |
import re
|
4 |
-
import
|
5 |
-
from typing import Dict, Any, List, Optional
|
6 |
from datetime import datetime
|
7 |
|
8 |
from .ontology import expand_terms_with_ontology
|
9 |
from .structures import fetch_structures_for_terms
|
10 |
from .narration import narrate_text
|
11 |
from .graphdb import write_topic_and_papers
|
12 |
-
from .providers import run_deepseek_summary, run_gemini_polish,
|
13 |
-
from .providers import pubmed_fallback_search
|
14 |
|
|
|
15 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
16 |
UMLS_API_KEY = os.getenv("UMLS_API_KEY")
|
17 |
BIOPORTAL_API_KEY = os.getenv("BIOPORTAL_API_KEY")
|
18 |
NCBI_API_KEY = os.getenv("NCBI_API_KEY")
|
19 |
NCBI_EMAIL = os.getenv("NCBI_EMAIL")
|
20 |
ELEVEN_LABS_API_KEY = os.getenv("ELEVEN_LABS_API_KEY")
|
21 |
-
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
|
22 |
NEO4J_USER = os.getenv("NEO4J_USER")
|
23 |
NEO4J_PASSWORD = os.getenv("NEO4J_PASSWORD")
|
24 |
NEO4J_URI = os.getenv("NEO4J_URI")
|
25 |
|
26 |
-
SYNBIO_MODE = True # force synthetic biology bias
|
27 |
|
28 |
-
#
|
29 |
DEMO_QUERIES = [
|
30 |
"Map all CRISPR-based living therapeutics in clinical trials since 2020",
|
31 |
"Graph metabolic engineering pathways for bio-based drug production",
|
@@ -87,20 +85,20 @@ def research_once(query: str, graph_preview: bool = True, narration: bool = True
|
|
87 |
fallback_cites = pubmed_fallback_search(query, NCBI_API_KEY, NCBI_EMAIL)
|
88 |
citations.extend(fallback_cites)
|
89 |
|
90 |
-
# 6. Fetch molecular structures
|
91 |
structures = fetch_structures_for_terms(expanded_terms)
|
92 |
|
93 |
-
# 7. Generate visual diagram with
|
94 |
-
visual_image_url =
|
95 |
|
96 |
-
# 8. Write to Neo4j
|
97 |
if graph_preview and NEO4J_URI:
|
98 |
write_topic_and_papers(query, citations, expanded_terms)
|
99 |
|
100 |
# 9. Narrate executive summary
|
101 |
audio_url = narrate_text(polished_summary) if narration and ELEVEN_LABS_API_KEY else None
|
102 |
|
103 |
-
# 10. Build output
|
104 |
report = {
|
105 |
"timestamp": datetime.utcnow().isoformat(),
|
106 |
"query": query,
|
|
|
1 |
# genesis/pipeline.py
|
2 |
import os
|
3 |
import re
|
4 |
+
from typing import Dict, Any, List
|
|
|
5 |
from datetime import datetime
|
6 |
|
7 |
from .ontology import expand_terms_with_ontology
|
8 |
from .structures import fetch_structures_for_terms
|
9 |
from .narration import narrate_text
|
10 |
from .graphdb import write_topic_and_papers
|
11 |
+
from .providers import run_deepseek_summary, run_gemini_polish, run_openai_image, pubmed_fallback_search
|
|
|
12 |
|
13 |
+
# ===== ENV VARIABLES =====
|
14 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
15 |
UMLS_API_KEY = os.getenv("UMLS_API_KEY")
|
16 |
BIOPORTAL_API_KEY = os.getenv("BIOPORTAL_API_KEY")
|
17 |
NCBI_API_KEY = os.getenv("NCBI_API_KEY")
|
18 |
NCBI_EMAIL = os.getenv("NCBI_EMAIL")
|
19 |
ELEVEN_LABS_API_KEY = os.getenv("ELEVEN_LABS_API_KEY")
|
|
|
20 |
NEO4J_USER = os.getenv("NEO4J_USER")
|
21 |
NEO4J_PASSWORD = os.getenv("NEO4J_PASSWORD")
|
22 |
NEO4J_URI = os.getenv("NEO4J_URI")
|
23 |
|
24 |
+
SYNBIO_MODE = True # force synthetic biology bias for demo
|
25 |
|
26 |
+
# ===== DEMO PRESETS =====
|
27 |
DEMO_QUERIES = [
|
28 |
"Map all CRISPR-based living therapeutics in clinical trials since 2020",
|
29 |
"Graph metabolic engineering pathways for bio-based drug production",
|
|
|
85 |
fallback_cites = pubmed_fallback_search(query, NCBI_API_KEY, NCBI_EMAIL)
|
86 |
citations.extend(fallback_cites)
|
87 |
|
88 |
+
# 6. Fetch molecular structures
|
89 |
structures = fetch_structures_for_terms(expanded_terms)
|
90 |
|
91 |
+
# 7. Generate visual diagram with OpenAI image model
|
92 |
+
visual_image_url = run_openai_image(query) if OPENAI_API_KEY else None
|
93 |
|
94 |
+
# 8. Write to Neo4j graph
|
95 |
if graph_preview and NEO4J_URI:
|
96 |
write_topic_and_papers(query, citations, expanded_terms)
|
97 |
|
98 |
# 9. Narrate executive summary
|
99 |
audio_url = narrate_text(polished_summary) if narration and ELEVEN_LABS_API_KEY else None
|
100 |
|
101 |
+
# 10. Build output package
|
102 |
report = {
|
103 |
"timestamp": datetime.utcnow().isoformat(),
|
104 |
"query": query,
|