# genesis/pipeline.py """ GENESIS-AI Research Pipeline Coordinates ontology expansion, literature retrieval, summaries, citations, structure fetching, graphDB storage, and narration. """ import os from datetime import datetime from .ontology import expand_terms_with_ontology from .molecule_viewer import fetch_structure from .narration import narrate_text from .providers import ( run_deepseek_summary, run_gemini_polish, run_openai_image, pubmed_fallback_search ) from .graphdb import write_topic_and_papers # ENV ELEVEN_LABS_API_KEY = os.getenv("ELEVEN_LABS_API_KEY") GEMINI_API_KEY = os.getenv("GEMINI_API_KEY") NEO4J_URI = os.getenv("NEO4J_URI") SYNBIO_MODE = True def synthetic_biology_prompt_inject(query, expanded_terms): """Injects domain-specific bias toward synthetic biology research.""" context = ( "You are an expert in synthetic biology. Focus on CRISPR, metabolic engineering, " "living therapeutics, protein design, biosensors, and biosecurity. Include literature, " "structures, market trends, and regulatory insights with citations." ) return f"{context}\n\nQuery: {query}\nExpanded terms: {', '.join(expanded_terms)}" def research_once(query, graph_preview=True, narration=True): """Runs the GENESIS-AI pipeline for a given research query.""" # 1. Expand ontology expanded_terms = expand_terms_with_ontology(query) # 2. Domain injection enriched_query = synthetic_biology_prompt_inject(query, expanded_terms) if SYNBIO_MODE else query # 3. Summarize (DeepSeek) summary_raw = run_deepseek_summary(enriched_query) # 4. Polish (Gemini) summary_polished = run_gemini_polish(summary_raw) # 5. Citations citations = pubmed_fallback_search(query) # 6. Structures structures = [fetch_structure(term) for term in expanded_terms] # 7. Visual (OpenAI Image) image_url = run_openai_image(query) # 8. GraphDB if graph_preview and NEO4J_URI: write_topic_and_papers(query, citations, expanded_terms) # 9. Narration audio_url = narrate_text(summary_polished) if narration and ELEVEN_LABS_API_KEY else None # 10. Output return { "timestamp": datetime.utcnow().isoformat(), "query": query, "expanded_terms": expanded_terms, "summary": summary_polished, "citations": citations, "structures": structures, "image_url": image_url, "audio_url": audio_url }