RichardZhu52 commited on
Commit
f6e0f52
·
1 Parent(s): 6bf89d5

update with secret

Browse files
Files changed (2) hide show
  1. app.py +835 -14
  2. utils.py +13 -4
app.py CHANGED
@@ -6,6 +6,826 @@ import json
6
  from utils import format_chat, append_to_sheet, read_sheet_to_df
7
  import random
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  # Load tool lists
10
  fda_drug_labeling_tools_path = "fda_drug_labeling_tools.json"
11
  monarch_tools_path = "monarch_tools.json"
@@ -459,20 +1279,21 @@ with gr.Blocks(css=centered_col_css) as demo:
459
  with gr.Row():
460
  submit_questions_btn = gr.Button("Submit Questions for TxAgent Evaluation")
461
  participate_eval_btn = gr.Button("Participate in TxAgent Evaluation")
462
- gr.HTML("""
463
- <div>
464
- <p><strong>About TxAgent:</strong> TxAgent is a first-of-its-kind AI model developed in the Zitnik Lab at Harvard Medical School. It leverages multi-step reasoning and real-time biomedical knowledge retrieval from a toolbox of 211 tools to analyze drug interactions, contraindications, and patient-specific treatment strategies. It is designed to provide personalized treatment recommendations across a wide range of diseases, including rare diseases.</p>
465
- <p>TxAgent evaluates how drugs interact at molecular, pharmacokinetic, and clinical levels, identifies contraindications based on patient comorbidities and concurrent medications, and tailors treatment strategies to individual patient characteristics, including age, genetic factors, and disease progression. It achieves 92.1% accuracy in open-ended drug reasoning tasks, surpassing GPT-4o by up to 25.8% and outperforming DeepSeek-R1 (671B) in structured multi-step reasoning.</p>
466
- <p>TxAgent's toolbox, ToolUniverse, consolidates 211 tools from trusted sources, including all US FDA-approved drugs since 1939 and validated clinical insights from Open Targets. By integrating multi-step inference, real-time knowledge grounding, and tool-assisted decision-making, TxAgent ensures that treatment recommendations align with established clinical guidelines and real-world evidence, reducing the risk of adverse events and improving therapeutic decision-making.</p>
467
- <p>We are currently conducting a user study with physicians, rare disease experts, and others with relevant medical background to assess TxAgent's performance on personalized therapeutic reasoning across multiple criteria, including helpfulness, clinical consensus, and scientific accuracy.</p>
468
- <p>Please choose one of the options below:</p>
469
- <ul>
470
- <li>If you would like to submit new questions for TxAgent to be evaluated on, please click the "Submit Questions" button.</li>
471
- <li>If you are here to participate in the evaluation of TxAgent's responses to existing questions, please click the "Participate in Evaluation" button.</li>
472
- </ul>
473
- <p>Your contribution is invaluable to us. Thank you for your time and expertise!</p>
474
- </div>
475
- """)
 
476
 
477
  # Define actions for the new buttons
478
  # For the Google Form button, we'll use JavaScript to open a new tab.
 
6
  from utils import format_chat, append_to_sheet, read_sheet_to_df
7
  import random
8
 
9
+ TxAgent_Project_Page_HTML = """<html>
10
+ <head>
11
+ <meta charset="utf-8" />
12
+ <!-- Meta tags for social media banners, these should be filled in appropriatly as they are your "business card" -->
13
+ <!-- Replace the content tag with appropriate information -->
14
+ <meta name="description" content="Project page of TxAgent" />
15
+ <meta property="og:title" content="TxAgent" />
16
+ <meta
17
+ property="og:description"
18
+ content="An AI Agent for therapeutic reasoning across a universe of tools"
19
+ />
20
+ <meta
21
+ property="og:url"
22
+ content="https://zitniklab.hms.harvard.edu/TxAgent/"
23
+ />
24
+ <!-- Path to banner image, should be in the path listed below. Optimal dimenssions are 1200X630-->
25
+ <meta property="og:image" content="static/image/TxAgent.jpg" />
26
+ <meta property="og:image:width" content="1200" />
27
+ <meta property="og:image:height" content="630" />
28
+
29
+ <meta name="twitter:title" content="TxAgent" />
30
+ <meta
31
+ name="twitter:description"
32
+ content="An AI Agent for therapeutic reasoning across a universe of tools"
33
+ />
34
+ <!-- Path to banner image, should be in the path listed below. Optimal dimenssions are 1200X600-->
35
+ <meta name="twitter:image" content="static/image/TxAgent.jpg" />
36
+ <meta name="twitter:card" content="summary_large_image" />
37
+ <!-- Keywords for your paper to be indexed by-->
38
+ <meta
39
+ name="keywords"
40
+ content="AI Agent, Agentic AI, therapeutic reasoning, tool use, tool universe, AI scientist"
41
+ />
42
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
43
+
44
+ <title>
45
+ TxAgent: An AI Agent for Therapeutic Reasoning Across a Universe of Tools
46
+ </title>
47
+ <link rel="icon" type="image/x-icon" href="static/images/favicon.ico" />
48
+ <link
49
+ href="https://fonts.googleapis.com/css?family=Google+Sans|Noto+Sans|Castoro"
50
+ rel="stylesheet"
51
+ />
52
+
53
+ <link rel="stylesheet" href="static/css/bulma.min.css" />
54
+ <link rel="stylesheet" href="static/css/bulma-carousel.min.css" />
55
+ <link rel="stylesheet" href="static/css/bulma-slider.min.css" />
56
+ <link rel="stylesheet" href="static/css/fontawesome.all.min.css" />
57
+ <link
58
+ rel="stylesheet"
59
+ href="https://cdn.jsdelivr.net/gh/jpswalsh/academicons@1/css/academicons.min.css"
60
+ />
61
+ <link rel="stylesheet" href="static/css/index.css" />
62
+
63
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
64
+ <script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
65
+ <script defer src="static/js/fontawesome.all.min.js"></script>
66
+ <script src="static/js/bulma-carousel.min.js"></script>
67
+ <script src="static/js/bulma-slider.min.js"></script>
68
+ <script src="static/js/index.js"></script>
69
+ <script src="https://code.highcharts.com/highcharts.js"></script>
70
+ <script src="https://code.highcharts.com/modules/sunburst.js"></script>
71
+ <script src="https://code.highcharts.com/modules/exporting.js"></script>
72
+
73
+ <style>
74
+ .tooluniverse-wrapper {
75
+ display: flex;
76
+ justify-content: center;
77
+ align-items: center;
78
+ width: 100%;
79
+ height: 100%;
80
+ }
81
+
82
+ #tooluniverse-container {
83
+ width: 65%;
84
+ height: 65%;
85
+ }
86
+ .small-text {
87
+ font-size: 0.65rem;
88
+ }
89
+
90
+ /* Fixed styles for centering all images */
91
+ img {
92
+ display: block;
93
+ margin-left: auto !important;
94
+ margin-right: auto !important;
95
+ max-width: 100%;
96
+ height: auto;
97
+ }
98
+
99
+ /* Fix carousel images */
100
+ .item img {
101
+ margin: 0 auto !important;
102
+ }
103
+
104
+ /* Center videos too */
105
+ video {
106
+ display: block;
107
+ margin: 0 auto !important;
108
+ max-width: 100%;
109
+ }
110
+
111
+ /* Force responsive image centering */
112
+ .responsive-image {
113
+ display: block !important;
114
+ margin: 0 auto !important;
115
+ max-width: 90% !important;
116
+ }
117
+
118
+ /* Simplify content container centering */
119
+ .content-container {
120
+ text-align: center;
121
+ }
122
+
123
+ /* Ensure container centering */
124
+ .container.is-centered {
125
+ text-align: center;
126
+ }
127
+ </style>
128
+ </head>
129
+
130
+ <body>
131
+ <section class="hero">
132
+ <div class="hero-body">
133
+ <div class="container is-max-desktop">
134
+ <div class="columns is-centered">
135
+ <div class="column has-text-centered">
136
+ <h1 class="title is-1 publication-title">
137
+ TxAgent: An AI agent for therapeutic reasoning across a universe
138
+ of tools
139
+ </h1>
140
+ <div class="is-size-5 publication-authors">
141
+ <!-- Paper authors -->
142
+ <span class="author-block">
143
+ <a href="https://shgao.site" target="_blank">Shanghua Gao</a
144
+ ><sup>1</sup>,</span
145
+ >
146
+ <span class="author-block">
147
+ <a
148
+ href="https://www.linkedin.com/in/richard-zhu-4236901a7/"
149
+ target="_blank"
150
+ >Richard Zhu</a
151
+ ><sup>1</sup>,</span
152
+ >
153
+ <span class="author-block">
154
+ <a href="https://zlkong.github.io/homepage/" target="_blank"
155
+ >Zhenglun Kong</a
156
+ ><sup>1</sup>,</span
157
+ >
158
+ <span class="author-block">
159
+ <a href="https://www.ayushnoori.com/" target="_blank"
160
+ >Ayush Noori</a
161
+ ><sup>1</sup>,</span
162
+ >
163
+ <span class="author-block">
164
+ <a
165
+ href="https://scholar.google.com/citations?hl=zh-CN&user=Awdn73MAAAAJ"
166
+ target="_blank"
167
+ >Xiaorui Su</a
168
+ ><sup>1</sup>,</span
169
+ >
170
+ <span class="author-block">
171
+ <a
172
+ href="https://www.linkedin.com/in/curtisginder/"
173
+ target="_blank"
174
+ >Curtis Ginder</a
175
+ ><sup>1,2</sup>,</span
176
+ >
177
+ <span class="author-block">
178
+ <a href="https://sites.google.com/view/theo-t" target="_blank"
179
+ >Theodoros Tsiligkaridis</a
180
+ ><sup>3</sup>,</span
181
+ >
182
+ <span class="author-block">
183
+ <a href="https://zitniklab.hms.harvard.edu/" target="_blank"
184
+ >Marinka Zitnik</a
185
+ ><sup>1,4,5,6&Dagger;;</sup></span
186
+ >
187
+ </div>
188
+ <details>
189
+ <summary>Author Affiliations</summary>
190
+ <div class="is-size-5 publication-authors">
191
+ <span class="author-block"
192
+ ><sup>1</sup>Department of Biomedical Informatics, Harvard
193
+ Medical School, Boston, MA</span
194
+ >
195
+ <span class="author-block"
196
+ ><sup>2</sup>Cardiovascular Division, Department of
197
+ Medicine, Brigham and Women’s Hospital, Harvard Medical
198
+ School, Boston, MA</span
199
+ >
200
+ <span class="author-block"
201
+ ><sup>3</sup>MIT Lincoln Laboratory, Lexington, MA</span
202
+ >
203
+ <span class="author-block"
204
+ ><sup>4</sup>Kempner Institute for the Study of Natural and
205
+ Artificial Intelligence, Harvard University, Cambridge,
206
+ MA</span
207
+ >
208
+ <span class="author-block"
209
+ ><sup>5</sup>Broad Institute of MIT and Harvard, Cambridge,
210
+ MA</span
211
+ ><br />
212
+ <span class="author-block"
213
+ ><sup>6</sup>Harvard Data Science Initiative, Cambridge,
214
+ MA</span
215
+ >
216
+ </div>
217
+ </details>
218
+
219
+ <div class="column has-text-centered">
220
+ <div class="publication-links">
221
+ <!-- Arxiv PDF link -->
222
+ <span class="link-block">
223
+ <a
224
+ href="https://arxiv.org/pdf/2503.10970"
225
+ target="_blank"
226
+ class="external-link button is-normal is-rounded is-dark"
227
+ >
228
+ <span class="icon">
229
+ <i class="fas fa-file-pdf"></i>
230
+ </span>
231
+ <span>Paper</span>
232
+ </a>
233
+ </span>
234
+
235
+ <!-- Github link -->
236
+ <span class="link-block">
237
+ <a
238
+ href="https://github.com/mims-harvard/TxAgent"
239
+ target="_blank"
240
+ class="external-link button is-normal is-rounded is-dark"
241
+ >
242
+ <span class="icon">
243
+ <i class="fab fa-github"></i>
244
+ </span>
245
+ <span>TxAgent code</span>
246
+ </a>
247
+ </span>
248
+
249
+ <span class="link-block">
250
+ <a
251
+ href="https://github.com/mims-harvard/ToolUniverse"
252
+ target="_blank"
253
+ class="external-link button is-normal is-rounded is-dark"
254
+ >
255
+ <span class="icon">
256
+ <i class="fab fa-github"></i>
257
+ </span>
258
+ <span>ToolUniverse code</span>
259
+ </a>
260
+ </span>
261
+
262
+ <!-- Github link -->
263
+ <span class="link-block">
264
+ <a
265
+ href="https://huggingface.co/collections/mims-harvard/txagent-67c8e54a9d03a429bb0c622c"
266
+ target="_blank"
267
+ class="external-link button is-normal is-rounded is-dark"
268
+ >
269
+ <span class="icon"> 🤗 </span>
270
+ <span>HuggingFace</span>
271
+ </a>
272
+ </span>
273
+ <span class="link-block">
274
+ <a
275
+ href="https://kempnerinstitute.harvard.edu/research/deeper-learning/txagent-an-ai-agent-for-therapeutic-reasoning-across-a-universe-of-211-tools/"
276
+ target="_blank"
277
+ class="external-link button is-normal is-rounded is-dark"
278
+ >
279
+ <span>Kempner Blog</span>
280
+ </a>
281
+ </span>
282
+ </div>
283
+ </div>
284
+ </div>
285
+ </div>
286
+ </div>
287
+ </div>
288
+ </section>
289
+
290
+ <!-- Model overview -->
291
+ <section class="hero is-small">
292
+ <div class="hero-body content-container">
293
+ <div class="container">
294
+ <h2 class="title is-2 has-text-centered">TxAgent model</h2>
295
+ <div class="container is-centered has-text-centered">
296
+ <img
297
+ src="static/images/txagent.jpg"
298
+ alt="TxAgent model"
299
+ style="height: auto; max-width: 48vw"
300
+ class="responsive-image"
301
+ />
302
+ </div>
303
+ </div>
304
+ </div>
305
+ </section>
306
+ <!-- End model overview -->
307
+
308
+ <!-- Paper abstract -->
309
+ <section class="section hero is-light">
310
+ <div class="container is-max-desktop">
311
+ <div class="columns is-centered has-text-centered">
312
+ <div class="column is-four-fifths">
313
+ <h2 class="title is-3">Abstract</h2>
314
+ <div class="content has-text-justified">
315
+ <p>
316
+ Precision therapeutics require multimodal adaptive models that
317
+ generate personalized treatment recommendations. We introduce
318
+ TxAgent, an AI agent that leverages multi-step reasoning and
319
+ real-time biomedical knowledge retrieval across a toolbox of 211
320
+ tools to analyze drug interactions, contraindications, and
321
+ patient-specific treatment strategies. TxAgent evaluates how
322
+ drugs interact at molecular, pharmacokinetic, and clinical
323
+ levels, identifies contraindications based on patient
324
+ comorbidities and concurrent medications, and tailors treatment
325
+ strategies to individual patient characteristics, including age,
326
+ genetic factors, and disease progression. TxAgent retrieves and
327
+ synthesizes evidence from multiple biomedical sources, assesses
328
+ interactions between drugs and patient conditions, and refines
329
+ treatment recommendations through iterative reasoning. It
330
+ selects tools based on task objectives and executes structured
331
+ function calls to solve therapeutic tasks that require clinical
332
+ reasoning and cross-source validation. The ToolUniverse
333
+ consolidates 211 tools from trusted sources, including all US
334
+ FDA-approved drugs since 1939 and validated clinical insights
335
+ from Open Targets. TxAgent outperforms leading LLMs, tool-use
336
+ models, and reasoning agents across five new benchmarks: DrugPC,
337
+ BrandPC, GenericPC, TreatmentPC, and DescriptionPC, covering
338
+ 3,168 drug reasoning tasks and 456 personalized treatment
339
+ scenarios. It achieves 92.1% accuracy in open-ended drug
340
+ reasoning tasks, surpassing GPT-4o by up to 25.8% and
341
+ outperforming DeepSeek-R1 (671B) in structured multi-step
342
+ reasoning. TxAgent generalizes across drug name variants and
343
+ descriptions, maintaining a variance of &lt;0.01 between brand,
344
+ generic, and description-based drug references, exceeding
345
+ existing tool-use LLMs by over 55%. By integrating multi-step
346
+ inference, real-time knowledge grounding, and tool- assisted
347
+ decision-making, TxAgent ensures that treatment recommendations
348
+ align with established clinical guidelines and real-world
349
+ evidence, reducing the risk of adverse events and improving
350
+ therapeutic decision-making.
351
+ </p>
352
+ </div>
353
+ </div>
354
+ </div>
355
+ </div>
356
+ </section>
357
+ <!-- End paper abstract -->
358
+
359
+ <!-- Use TxAgent -->
360
+ <section class="hero is-small">
361
+ <div class="hero-body content-container">
362
+ <h2 class="title is-2 has-text-centered py-2">A Simple Guide to Using TxAgent</h2>
363
+ <div class="container is-centered has-text-centered is-max-desktop">
364
+ <section class="section hero is-light py-2">
365
+ <div class="hero-body has-text-left py-2">
366
+ <h2 class="has-text-weight-normal">
367
+ Install ToolUniverse:
368
+ <code> pip install tooluniverse </code>
369
+ <br />
370
+ Install TxAgent:
371
+ <code> pip install txagent </code>
372
+ <br />
373
+ Run TxAgent demo/script:
374
+ <code> https://github.com/mims-harvard/TxAgent </code>
375
+ </div>
376
+ </section>
377
+ </div>
378
+ </div>
379
+ </section>
380
+ <!-- End use txagent -->
381
+
382
+ <!-- Model capabilities -->
383
+ <section class="hero is-small">
384
+ <div class="hero-body content-container">
385
+ <div class="container">
386
+ <h2 class="title is-2 has-text-centered">TxAgent capabilities</h2>
387
+ <div class="container is-centered has-text-centered">
388
+ <img
389
+ src="static/images/txagent_capabilities.jpg"
390
+ alt="TxAgent Capabilities"
391
+ style="height: auto; max-width: 50vw"
392
+ class="responsive-image"
393
+ />
394
+ </div>
395
+ <div class="container is-centered has-text-centered is-max-desktop">
396
+ <section class="section hero is-light py-2 content">
397
+ <div class="has-text-left py-2">
398
+ <ul>
399
+ <li>
400
+ <b>Knowledge grounding using tool calls</b>: TxAgent
401
+ utilizes tools to obtain verified knowledge and provides
402
+ outputs based on it.
403
+ </li>
404
+ <li>
405
+ <b>Goal-oriented tool selection</b>: TxAgent proactively
406
+ requests tools from ToolUniverse using the ToolRAG model and
407
+ selects and applies the most suitable tool from the
408
+ available candidates.
409
+ </li>
410
+ <li>
411
+ <b>Problem solving with multi-step reasoning</b>: TxAgent
412
+ manages complex tasks or unexpected responses from tools
413
+ through multiple iterations of thought and function calls.
414
+ </li>
415
+ <li>
416
+ <b>Leveraging constantly updated knowledge bases</b>:
417
+ TxAgent accesses continuously updated databases via tools to
418
+ handle problems that go beyond the TxAgent’s intrinsic
419
+ knowledge.
420
+ </li>
421
+ </ul>
422
+ </div>
423
+ </section>
424
+ </div>
425
+ </div>
426
+ </div>
427
+ </section>
428
+ <!-- End model capabilities -->
429
+
430
+ <!-- Tool universe -->
431
+ <section class="hero is-small">
432
+ <div class="hero-body content-container">
433
+ <h2 class="title is-2 has-text-centered py-2">ToolUniverse</h2>
434
+ <!-- Image carousel -->
435
+ <section class="hero is-small">
436
+ <div class="hero-body">
437
+ <div class="container has-text-centered">
438
+ <div id="results-carousel" class="carousel results-carousel">
439
+ <div class="item">
440
+ <!-- Your image here -->
441
+ <img
442
+ src="static/images/tool_openfda.jpg"
443
+ alt="MY ALT TEXT"
444
+ style="height: auto; max-width: 50vw"
445
+ />
446
+ <h2 class="subtitle has-text-centered">
447
+ Tool example linked to OpenFDA.
448
+ </h2>
449
+ </div>
450
+ <div class="item">
451
+ <!-- Your image here -->
452
+ <img
453
+ src="static/images/tool_opentarget.jpg"
454
+ alt="MY ALT TEXT"
455
+ style="height: auto; max-width: 50vw"
456
+ />
457
+ <h2 class="subtitle has-text-centered">
458
+ Tool example linked to OpenTarget.
459
+ </h2>
460
+ </div>
461
+ <div class="item">
462
+ <!-- Your image here -->
463
+ <img
464
+ src="static/images/tool_monarch.jpg"
465
+ alt="MY ALT TEXT"
466
+ style="height: auto; max-width: 50vw"
467
+ />
468
+ <h2 class="subtitle has-text-centered">
469
+ Tool example linked to Monarch Initiative.
470
+ </h2>
471
+ </div>
472
+ </div>
473
+ </div>
474
+ </div>
475
+ </section>
476
+ <!-- End image carousel -->
477
+ <div class="container is-centered has-text-centered is-max-desktop">
478
+ <section class="section hero is-light py-2">
479
+ <div class="hero-body has-text-left py-2">
480
+ <h2 class="has-text-weight-normal">
481
+ ToolUniverse is a critical component of TxAgent, providing the
482
+ agent with the ability to access and leverage a vast array of
483
+ biomedical knowledge to solve complex therapeutic reasoning
484
+ tasks. ToolUniverse includes 211 biomedical tools that address
485
+ various aspects of drugs and diseases. These tools are linked to
486
+ trusted sources, including all US FDA-approved drugs since 1939
487
+ and validated clinical insights from Open Targets and Monarch
488
+ Initiative.
489
+ <br />
490
+ Install
491
+ <a href="https://github.com/mims-harvard/ToolUniverse/"
492
+ >ToolUniverse</a
493
+ >
494
+ with one line of code:
495
+ <code> pip install tooluniverse </code>
496
+ </h2>
497
+ </div>
498
+ </section>
499
+ </div>
500
+ <div class="tooluniverse-wrapper">
501
+ <div id="tooluniverse-container"></div>
502
+ </div>
503
+ </div>
504
+ </section>
505
+ <!-- End tool universe -->
506
+
507
+ <!-- Model training -->
508
+ <section class="hero is-small">
509
+ <div class="hero-body content-container">
510
+ <div class="container">
511
+ <h2 class="title is-2 has-text-centered">
512
+ Training TxAgent: TxAgent-instruct dataset
513
+ </h2>
514
+ <div class="container is-centered has-text-centered">
515
+ <img
516
+ src="static/images/txagent_train.jpg"
517
+ alt="TxAgent Capabilities"
518
+ style="height: auto; max-width: 50vw"
519
+ class="responsive-image"
520
+ />
521
+ </div>
522
+ <div class="container is-centered has-text-centered is-max-desktop">
523
+ <section class="section hero is-light py-2">
524
+ <div class="hero-body has-text-left py-2">
525
+ <h2 class="has-text-weight-normal">
526
+ The multi-agent systems (i.e., ToolGen, QuestionGen, and
527
+ TraceGen) construct the TxAgent-Instruct training dataset for
528
+ instruction tuning LLM to achieve the capabilities of TxAgent.
529
+ TxAgent-Instruct is a diverse, synthetic, multi-step reasoning
530
+ and large-scale function call training dataset anchored in
531
+ biomedical knowledge. It consists of 378,027
532
+ instruction-tuning data samples, with each sample generated by
533
+ breaking down complete reasoning traces into step-by-step
534
+ training data. These samples are derived from 85,340
535
+ multi-step reasoning traces, which collectively include
536
+ 177,626 reasoning steps and 281,695 function calls.
537
+ </h2>
538
+ </div>
539
+ </section>
540
+ </div>
541
+ </div>
542
+ </div>
543
+ </section>
544
+ <!-- End model training -->
545
+
546
+ <!-- Multi-agent system -->
547
+ <section class="hero is-small">
548
+ <div class="hero-body content-container">
549
+ <div class="container">
550
+ <h2 class="title is-2 has-text-centered">
551
+ Building TxAgent-Instruct: multi-agent systems
552
+ </h2>
553
+ <div class="container is-centered has-text-centered">
554
+ <img
555
+ src="static/images/multi-agent.jpg"
556
+ alt="TxAgent Capabilities"
557
+ style="height: auto; max-width: 50vw"
558
+ class="responsive-image"
559
+ />
560
+ </div>
561
+ <div class="container is-centered has-text-centered is-max-desktop">
562
+ <section class="section hero is-light py-2 content">
563
+ <div class="has-text-left py-2">
564
+ <ul>
565
+ <li>
566
+ <b>ToolGen</b>: A tool generation multi-agent system that
567
+ transforms APIs into 211 agent-compatible tools, aggregating
568
+ them into the ToolUniverse.
569
+ </li>
570
+ <li>
571
+ <b>QuestionGen</b>: A question generation multi-agent system
572
+ designed to extract critical information from documents
573
+ (e.g., FDA drug documentation) and generate relevant
574
+ questions.
575
+ </li>
576
+ <li>
577
+ <b>TraceGen</b>: A reasoning trace generation multi-agent
578
+ system, where a Helper agent and a Tool Provider module
579
+ assist the Solver agent in generating step-by-step reasoning
580
+ and function calls to solve a problem.
581
+ </li>
582
+ </ul>
583
+ </div>
584
+ </section>
585
+ </div>
586
+ </div>
587
+ </div>
588
+ </section>
589
+ <!-- End multi-agent system -->
590
+
591
+ <!-- DrugPC -->
592
+ <section class="hero is-small">
593
+ <div class="hero-body content-container">
594
+ <div class="container">
595
+ <h2 class="title is-2 has-text-centered">
596
+ Drug reasoning on 11 tasks
597
+ </h2>
598
+ <div class="container is-centered has-text-centered">
599
+ <img
600
+ src="static/images/drugpc-open-end.jpg"
601
+ alt="TxAgent Capabilities"
602
+ style="height: auto; max-width: 50vw"
603
+ class="responsive-image"
604
+ />
605
+ </div>
606
+ <div class="container is-centered has-text-centered is-max-desktop">
607
+ <section class="section hero is-light py-2">
608
+ <div class="hero-body has-text-left py-2">
609
+ <h2 class="has-text-weight-normal">
610
+ DrugPC (Drug Prescribing Card) benchmark includes 3,168
611
+ questions covering 11 common tasks related to drugs. TxAgent
612
+ outperforms larger open-source LLMs and GPT-4 as well as
613
+ existing tool-use LLMs across 11 tasks, excelling in both
614
+ open-ended questions. These tasks cover various drug-related
615
+ topics, including drug overview, ingredients, warnings and
616
+ safety, dependence and abuse, dosage and administration, use
617
+ in specific populations, pharmacology, clinical information,
618
+ nonclinical toxicology, patient-focused information, and
619
+ storage and supply.
620
+ </h2>
621
+ </div>
622
+ </section>
623
+ </div>
624
+ </div>
625
+ </div>
626
+ </section>
627
+ <!-- End DrugPC -->
628
+
629
+ <!-- TreatmentPC -->
630
+ <section class="hero is-small">
631
+ <div class="hero-body content-container">
632
+ <div class="container">
633
+ <h2 class="title is-2 has-text-centered">
634
+ Specialized treatment recommendations
635
+ </h2>
636
+ <div class="container is-centered has-text-centered">
637
+ <img
638
+ src="static/images/treatmentpc.jpg"
639
+ alt="TxAgent Capabilities"
640
+ style="height: auto; max-width: 50vw"
641
+ class="responsive-image"
642
+ />
643
+ </div>
644
+ <div class="container is-centered has-text-centered is-max-desktop">
645
+ <section class="section hero is-light py-2">
646
+ <div class="hero-body has-text-left py-2">
647
+ <h2 class="has-text-weight-normal">
648
+ TreatmentPC (Treatment Prescribing Cards) benchmark includes
649
+ 456 questions regarding specialized treatment recommendations.
650
+ While multiple indications can be applied to a single disease,
651
+ patients with specific conditions—such as pregnancy or
652
+ comorbidities—require specialized treatment approaches,
653
+ including customized drug selection and dosage adjustments.
654
+ The TreatmentPC benchmark is designed to evaluate such
655
+ specialized treatment scenarios with questions that account
656
+ for the varying application conditions of drugs.
657
+ <br />
658
+ TxAgnet outperforms larger LLMs such as GPT-4o and Llama
659
+ 3.1-70B-Instruct as well as tool-use LLMs in both open-ended
660
+ and multiple-choice settings. TxAgent achieves superior
661
+ performance compared to the full DeepSeek-R1 model (671B) and
662
+ its two distilled versions based on Llama-3.1-8B and
663
+ Llama-3.3-70B.
664
+ </h2>
665
+ </div>
666
+ </section>
667
+ </div>
668
+ </div>
669
+ </div>
670
+ </section>
671
+ <!-- End TreatmentPC -->
672
+
673
+ <!-- Demo -->
674
+ <section class="hero is-small">
675
+ <div class="hero-body content-container">
676
+ <h2 class="title is-2 has-text-centered py-2">TxAgent demos</h2>
677
+ <!-- Image carousel -->
678
+ <section class="hero is-small">
679
+ <div class="hero-body">
680
+ <div class="container has-text-centered">
681
+ <div id="results-carousel" class="carousel results-carousel">
682
+ <div class="item">
683
+ <video
684
+ poster=""
685
+ id="tree"
686
+ autoplay
687
+ controls
688
+ muted
689
+ loop
690
+ height="100%"
691
+ >
692
+ <!-- Your video here -->
693
+ <source src="static/videos/q1.mov" type="video/mp4" />
694
+ </video>
695
+ <h2 class="subtitle has-text-centered">
696
+ Demo 1: Treatment adjustments considering drug mechanism and
697
+ patient condition.
698
+ </h2>
699
+ </div>
700
+ <div class="item">
701
+ <video
702
+ poster=""
703
+ id="tree"
704
+ autoplay
705
+ controls
706
+ muted
707
+ loop
708
+ height="100%"
709
+ >
710
+ <!-- Your video here -->
711
+ <source src="static/videos/q2.mov" type="video/mp4" />
712
+ </video>
713
+ <h2 class="subtitle has-text-centered">
714
+ Demo2: Treatment adjustments considering the precise patient
715
+ condition (e.g., changing the patient condition from
716
+ moderate to severe hepatic impairment).
717
+ </h2>
718
+ </div>
719
+ <div class="item">
720
+ <video
721
+ poster=""
722
+ id="tree"
723
+ autoplay
724
+ controls
725
+ muted
726
+ loop
727
+ height="100%"
728
+ >
729
+ <!-- Your video here -->
730
+ <source src="static/videos/q3.mov" type="video/mp4" />
731
+ </video>
732
+ <h2 class="subtitle has-text-centered">
733
+ Demo 3: Treatment selection considering drug-drug
734
+ interactions.
735
+ </h2>
736
+ </div>
737
+ </div>
738
+ </div>
739
+ </div>
740
+ </section>
741
+ <!-- End image carousel -->
742
+ <div class="container is-centered has-text-centered is-max-desktop">
743
+ <section class="section hero is-light py-2">
744
+ <div class="hero-body has-text-left py-2">
745
+ <h2 class="has-text-weight-normal">
746
+ Get code in
747
+ <a href="https://github.com/mims-harvard/TxAgent/">TxAgent</a>!
748
+ Lauch the TxAgent demo to see how TxAgent can assist in
749
+ therapeutic reasoning across a universe of tools.
750
+ </h2>
751
+ </div>
752
+ </section>
753
+ </div>
754
+ <div class="tooluniverse-wrapper">
755
+ <div id="tooluniverse-container"></div>
756
+ </div>
757
+ </div>
758
+ </section>
759
+ <!-- End Demo -->
760
+
761
+ <!--BibTex citation -->
762
+ <section class="section" id="BibTeX">
763
+ <div class="container is-max-desktop content">
764
+ <h2 class="title">BibTeX</h2>
765
+ <pre><code>@misc{gao2025txagent,
766
+ title={TxAgent: An AI Agent for Therapeutic Reasoning Across a Universe of Tools},
767
+ author={Shanghua Gao and Richard Zhu and Zhenglun Kong and Ayush Noori and Xiaorui Su and Curtis Ginder and Theodoros Tsiligkaridis and Marinka Zitnik},
768
+ year={2025},
769
+ eprint={2503.10970},
770
+ archivePrefix={arXiv},
771
+ primaryClass={cs.AI},
772
+ url={https://arxiv.org/abs/2503.10970},
773
+ }</code></pre>
774
+ </div>
775
+ </section>
776
+ <!--End BibTex citation -->
777
+
778
+ <!--BibTex citation -->
779
+ <section class="section" id="BibTeX">
780
+ <div class="container is-max-desktop content">
781
+ <h2 class="title">Contact</h2>
782
+ <p>If you have any questions or suggestions, please email
783
+ <a href="mailto:[email protected]">Shanghua Gao</a> and
784
+ <a href="mailto:[email protected]">Marinka Zitnik</a>.
785
+ </p>
786
+ </div>
787
+ </section>
788
+ <!--End BibTex citation -->
789
+
790
+ <footer class="footer small-text">
791
+ <div class="container">
792
+ <div class="columns is-centered">
793
+ <div class="column is-8">
794
+ <div class="content">
795
+ <p>
796
+ We gratefully acknowledge the support of NIH R01-HD108794, NSF CAREER 2339524, US DoD FA8702-15-D-0001, Harvard Data Science Initiative, Amazon Faculty Research, Google Research Scholar Program, AstraZeneca Research, Roche Alliance with Distinguished Scientists, Sanofi iDEA-iTECH, Pfizer Research, Gates Foundation (INV-079038), Chan Zuckerberg Initiative, John and Virginia Kaneb Fellowship at Harvard Medical School, Biswas Computational Biology Initiative in partnership with the Milken Institute, Harvard Medical School Dean's Innovation Fund for the Use of Artificial Intelligence, and Kempner Institute for the Study of Natural and Artificial Intelligence at Harvard University. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the funders.
797
+ We thank Owen Queen and Thomas Hartvigsen for their valuable discussions on this project and NVIDIA AI for providing access to DeepSeek R1 models.
798
+ <p>
799
+ This page was built using the
800
+ <a
801
+ href="https://github.com/eliahuhorwitz/Academic-project-page-template"
802
+ target="_blank"
803
+ >Academic Project Page Template</a
804
+ >
805
+ which was adopted from the <a
806
+ href="https://nerfies.github.io"
807
+ target="_blank"
808
+ >Nerfies</a
809
+ > project page. You are free to borrow the source code of this
810
+ website, we just ask that you link back to this page in the
811
+ footer.
812
+ This website is licensed under a
813
+ <a
814
+ rel="license"
815
+ href="http://creativecommons.org/licenses/by-sa/4.0/"
816
+ target="_blank"
817
+ >Creative Commons Attribution-ShareAlike 4.0 International
818
+ License</a
819
+ >.
820
+ </p>
821
+ </div>
822
+ </div>
823
+ </div>
824
+ </div>
825
+ </footer>
826
+ </body>
827
+ </html>"""
828
+
829
  # Load tool lists
830
  fda_drug_labeling_tools_path = "fda_drug_labeling_tools.json"
831
  monarch_tools_path = "monarch_tools.json"
 
1279
  with gr.Row():
1280
  submit_questions_btn = gr.Button("Submit Questions for TxAgent Evaluation")
1281
  participate_eval_btn = gr.Button("Participate in TxAgent Evaluation")
1282
+ gr.HTML(TxAgent_Project_Page_HTML)
1283
+ # gr.HTML("""
1284
+ # <div>
1285
+ # <p><strong>About TxAgent:</strong> TxAgent is a first-of-its-kind AI model developed in the Zitnik Lab at Harvard Medical School. It leverages multi-step reasoning and real-time biomedical knowledge retrieval from a toolbox of 211 tools to analyze drug interactions, contraindications, and patient-specific treatment strategies. It is designed to provide personalized treatment recommendations across a wide range of diseases, including rare diseases.</p>
1286
+ # <p>TxAgent evaluates how drugs interact at molecular, pharmacokinetic, and clinical levels, identifies contraindications based on patient comorbidities and concurrent medications, and tailors treatment strategies to individual patient characteristics, including age, genetic factors, and disease progression. It achieves 92.1% accuracy in open-ended drug reasoning tasks, surpassing GPT-4o by up to 25.8% and outperforming DeepSeek-R1 (671B) in structured multi-step reasoning.</p>
1287
+ # <p>TxAgent's toolbox, ToolUniverse, consolidates 211 tools from trusted sources, including all US FDA-approved drugs since 1939 and validated clinical insights from Open Targets. By integrating multi-step inference, real-time knowledge grounding, and tool-assisted decision-making, TxAgent ensures that treatment recommendations align with established clinical guidelines and real-world evidence, reducing the risk of adverse events and improving therapeutic decision-making.</p>
1288
+ # <p>We are currently conducting a user study with physicians, rare disease experts, and others with relevant medical background to assess TxAgent's performance on personalized therapeutic reasoning across multiple criteria, including helpfulness, clinical consensus, and scientific accuracy.</p>
1289
+ # <p>Please choose one of the options below:</p>
1290
+ # <ul>
1291
+ # <li>If you would like to submit new questions for TxAgent to be evaluated on, please click the "Submit Questions" button.</li>
1292
+ # <li>If you are here to participate in the evaluation of TxAgent's responses to existing questions, please click the "Participate in Evaluation" button.</li>
1293
+ # </ul>
1294
+ # <p>Your contribution is invaluable to us. Thank you for your time and expertise!</p>
1295
+ # </div>
1296
+ # """)
1297
 
1298
  # Define actions for the new buttons
1299
  # For the Google Form button, we'll use JavaScript to open a new tab.
utils.py CHANGED
@@ -11,10 +11,19 @@ import json
11
  import gradio as gr
12
  import os
13
 
14
- GSERVICE_ACCOUNT_INFO = os.environ.get("GSERVICE_ACCOUNT_INFO")
15
-
16
- # Optionally, get the sheet name from environment (or use a default)
17
- # GSHEET_NAME = os.environ.get("GSHEET_NAME", "Your Google Sheet Name")
 
 
 
 
 
 
 
 
 
18
  GSHEET_NAME = "TxAgent_data_collection"
19
 
20
  #Exponential backoff retry decorator
 
11
  import gradio as gr
12
  import os
13
 
14
+ GSERVICE_ACCOUNT_INFO = {
15
+ "type": "service_account",
16
+ "project_id": "txagent",
17
+ "private_key_id": "cc1a12e427917244a93faf6f19e72b589a685e65",
18
+ "private_key": os.getenv("GSheets_Shanghua_PrivateKey"),
19
+ "client_email": "[email protected]",
20
+ "client_id": "108950722202634464257",
21
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
22
+ "token_uri": "https://oauth2.googleapis.com/token",
23
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
24
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/shanghua%40txagent.iam.gserviceaccount.com",
25
+ "universe_domain": "googleapis.com"
26
+ }
27
  GSHEET_NAME = "TxAgent_data_collection"
28
 
29
  #Exponential backoff retry decorator