kaurm43 commited on
Commit
483a973
·
verified ·
1 Parent(s): 9b3049a

Update PolyAgent/gradio_interface.py

Browse files
Files changed (1) hide show
  1. PolyAgent/gradio_interface.py +34 -30
PolyAgent/gradio_interface.py CHANGED
@@ -84,41 +84,45 @@ DEFAULT_TARGET_BY_PROPERTY = {
84
  # Run instructions bubble
85
  # -----------------------------------------------------------------------------
86
  RUN_INSTRUCTIONS_MD = (
87
- "### How to run PolyAgent (one-time setup)\n"
88
  "\n"
89
- "**1) Environment**\n"
90
- "- Activate your conda/venv where this repository is installed.\n"
91
- "- Install required Python packages (project-specific; example):\n"
92
- " - `pip install gradio torch transformers numpy joblib sentencepiece requests beautifulsoup4`\n"
93
- " - If you want PNG visuals and RDKit validation: install RDKit (recommended via conda-forge).\n"
94
  "\n"
95
- "**2) Required model/artifact paths**\n"
96
- "- Ensure these paths exist and contain the expected artifacts (as configured in `OrchestratorConfig`):\n"
97
- " - `cl_weights_path` (CL encoder weights)\n"
98
- " - `DOWNSTREAM_BESTWEIGHTS_5M_DIR` (property heads)\n"
99
- " - `INVERSE_DESIGN_5M_DIR` (inverse design generator bundles)\n"
100
- " - `spm_5M.model` (SentencePiece model)\n"
 
101
  "\n"
102
- "**3) Required environment variables**\n"
103
- "- `OPENAI_API_KEY` (required for planning + composed answers)\n"
104
- "- Optional:\n"
105
- " - `OPENAI_MODEL` (defaults to `gpt-4.1` in config)\n"
106
- " - `HF_TOKEN` (recommended for `materials.selfies-ted` model downloads)\n"
107
- " - `SPRINGER_NATURE_API_KEY`, `SEMANTIC_SCHOLAR_API_KEY` (improves web_search coverage)\n"
 
108
  "\n"
109
- "**4) Start the interface**\n"
110
- "- Run:\n"
111
- " - `python gradio_interface.py --server-name 0.0.0.0 --server-port 7860`\n"
 
 
 
 
 
 
112
  "\n"
113
- "**5) How to prompt in the Console**\n"
114
- "- To trigger inverse design: include a generation intent (e.g., “generate”, “inverse design”) and a target value.\n"
115
- "- You can specify `target_value` in text (examples): `target_value=60`, `target: 60`, `Tg 60`.\n"
116
- "- To seed with a polymer, include a pSMILES in a code block or via `seed_psmiles:`.\n"
117
- "- To control citation count: ask explicitly (e.g., “cite 10 papers”).\n"
118
  "\n"
119
- "**Notes**\n"
120
- "- Tool facts are cited as `[T]`.\n"
121
- "- Literature/web/RAG citations appear inline as clickable DOI links (e.g., `[https://doi.org/...](https://doi.org/...)`) next to the claim.\n"
 
122
  )
123
 
124
  def pretty_json(x: Any) -> str:
@@ -1261,7 +1265,7 @@ def build_ui() -> gr.Blocks:
1261
  ) as demo:
1262
  state = gr.State({})
1263
 
1264
- gr.Markdown("## PolyAgent\n")
1265
 
1266
  # Big bubble shown on load and retained (no dismiss / no state gating).
1267
  gr.Markdown(RUN_INSTRUCTIONS_MD, elem_classes=["info-bubble"])
 
84
  # Run instructions bubble
85
  # -----------------------------------------------------------------------------
86
  RUN_INSTRUCTIONS_MD = (
87
+ "### How to use PolyAgent\n"
88
  "\n"
89
+ "PolyAgent is a web app with three **Tabs** at the top:\n"
90
+ "- **PolyAgent Console** (main workflow)\n"
91
+ "- **Tools** (run individual tools)\n"
92
+ "- **Other LLMs** (baseline LLM-only answers)\n"
 
93
  "\n"
94
+ "#### PolyAgent Console\n"
95
+ "Use this Tab for the full, end-to-end run.\n"
96
+ "1) In **Questions**, paste your request (one question or multiple).\n"
97
+ "2) Click **Run PolyAgent**.\n"
98
+ "3) Read the results in:\n"
99
+ " - **PolyAgent Answer**: the final structured response.\n"
100
+ " - **PNG Artifacts**: any available visuals (molecule render, generation grid, explainability heatmap).\n"
101
  "\n"
102
+ "**Prompt tips (what PolyAgent detects automatically):**\n"
103
+ "- **Inverse design / generation**: include words like `generate` or `inverse design` **and** include a numeric target\n"
104
+ " (examples: `target_value=60`, `target: 60`, `Tg 60`).\n"
105
+ "- **Seed polymer**: provide a pSMILES either:\n"
106
+ " - inside a fenced code block, or\n"
107
+ " - with a keyed prefix like `seed_psmiles:`.\n"
108
+ "- **Citations**: if you want a specific count, say it explicitly (example: `cite 10 papers`).\n"
109
  "\n"
110
+ "#### Tools (debugging / run one step at a time)\n"
111
+ "Use this Tab when you want to run a single tool and inspect its raw output.\n"
112
+ "Each section is a collapsible **Accordion** with its own inputs and a run button:\n"
113
+ "- **Data Extraction** (parse/canonicalize pSMILES; may also produce PNGs)\n"
114
+ "- **Property Prediction**\n"
115
+ "- **Polymer Generation (inverse design)**\n"
116
+ "- **Web / RAG** (search + retrieval)\n"
117
+ "- **Explainability**\n"
118
+ "- **Diagnostics** (health checks, e.g., OpenAI probe)\n"
119
  "\n"
120
+ "Outputs appear as JSON (for tool results) and/or PNGs (for visuals), depending on the tool.\n"
 
 
 
 
121
  "\n"
122
+ "#### Other LLMs (no tools)\n"
123
+ "Use this Tab to get a direct answer from a selected non-GPT model.\n"
124
+ "It does **not** run PolyAgent tools (no property prediction, no generation tools, no retrieval).\n"
125
+ "Pick a model, paste your prompt, and run it.\n"
126
  )
127
 
128
  def pretty_json(x: Any) -> str:
 
1265
  ) as demo:
1266
  state = gr.State({})
1267
 
1268
+ gr.Markdown("## PolyAgent 🧪\n")
1269
 
1270
  # Big bubble shown on load and retained (no dismiss / no state gating).
1271
  gr.Markdown(RUN_INSTRUCTIONS_MD, elem_classes=["info-bubble"])