|
| 1 | +# PaperQA2 for Clinical Trials |
| 2 | + |
| 3 | +PaperQA2 now natively supports querying clinical trials in addition to any documents supplied by the user. It |
| 4 | +uses a new tool, the aptly named `clinical_trials_search` tool. Users don't have to provide any clinical |
| 5 | +trials to the tool itself, it uses the `clinicaltrials.gov` API to retrieve them on the fly. As of |
| 6 | +January 2025, the tool is not enabled by default, but it's easy to configure. Here's an example |
| 7 | +where we query only clinical trials, without using any documents: |
| 8 | + |
| 9 | +```python |
| 10 | +from paperqa import Settings, agent_query |
| 11 | + |
| 12 | +answer_response = await agent_query( |
| 13 | + query="What drugs have been found to effectively treat Ulcerative Colitis?", |
| 14 | + settings=Settings.from_name("search_only_clinical_trials"), |
| 15 | +) |
| 16 | + |
| 17 | +print(answer_response.session.answer) |
| 18 | +``` |
| 19 | + |
| 20 | +### Output |
| 21 | + |
| 22 | + Several drugs have been found to effectively treat Ulcerative Colitis (UC), |
| 23 | + targeting different mechanisms of the disease. |
| 24 | + |
| 25 | + Golimumab, a tumor necrosis factor (TNF) inhibitor marketed as Simponi®, has demonstrated efficacy |
| 26 | + in treating moderate-to-severe UC. Administered subcutaneously, it was shown to maintain clinical |
| 27 | + response through Week 54 in patients, as assessed by the Partial Mayo Score (NCT02092285). |
| 28 | + |
| 29 | + Mesalazine, an anti-inflammatory drug, is commonly used for UC treatment. In a study comparing |
| 30 | + mesalazine enemas to faecal microbiota transplantation (FMT) for left-sided UC, |
| 31 | + mesalazine enemas (4g daily) were effective in inducing clinical remission (Mayo score ≤ 2) (NCT03104036). |
| 32 | + |
| 33 | + Antibiotics have also shown potential in UC management. A combination of doxycycline, |
| 34 | + amoxicillin, and metronidazole induced remission in 60-70% of patients with moderate-to-severe |
| 35 | + UC in prior studies. These antibiotics are thought to alter gut microbiota, reducing pathobionts |
| 36 | + and promoting beneficial bacteria (NCT02217722, NCT03986996). |
| 37 | + |
| 38 | + Roflumilast, a phosphodiesterase-4 (PDE4) inhibitor, is being investigated for mild-to-moderate UC. |
| 39 | + Preliminary findings suggest it may improve disease severity and biochemical markers when |
| 40 | + added to conventional treatments (NCT05684484). |
| 41 | + |
| 42 | + These treatments highlight diverse therapeutic approaches, including immunosuppression, |
| 43 | + microbiota modulation, and anti-inflammatory mechanisms. |
| 44 | + |
| 45 | +You can see the in-line citations for each clinical trial used as a response for each query. If you'd like |
| 46 | +to see more data on the specific contexts that were used to answer the query: |
| 47 | + |
| 48 | +```python |
| 49 | +print(answer_response.session.contexts) |
| 50 | +``` |
| 51 | + |
| 52 | + [Context(context='The excerpt mentions that a search on ClinicalTrials.gov for clinical trials related to drugs |
| 53 | + treating Ulcerative Colitis yielded 689 trials. However, it does not provide specific information about which |
| 54 | + drugs have been found effective for treating Ulcerative Colitis.', text=Text(text='', name=... |
| 55 | + |
| 56 | +Using `Settings.from_name('search_only_clinical_trials')` is a shortcut, but note that you can easily |
| 57 | +add `clinical_trial_search` into any custom `Settings` by just explicitly naming it as a tool: |
| 58 | + |
| 59 | +```python |
| 60 | +from pathlib import Path |
| 61 | +from paperqa import Settings, agent_query, AgentSetting |
| 62 | +from paperqa.agents.tools import DEFAULT_TOOL_NAMES |
| 63 | + |
| 64 | +# you can start with the default list of PaperQA tools |
| 65 | +print(DEFAULT_TOOL_NAMES) |
| 66 | +# >>> ['paper_search', 'gather_evidence', 'gen_answer', 'reset', 'complete'], |
| 67 | + |
| 68 | +# we can start with a directory with a potentially useful paper in it |
| 69 | +print(list(Path("my_papers").iterdir())) |
| 70 | + |
| 71 | +# now let's query using standard tools + clinical_trials |
| 72 | +answer_response = await agent_query( |
| 73 | + query="What drugs have been found to effectively treat Ulcerative Colitis?", |
| 74 | + settings=Settings( |
| 75 | + paper_directory="my_papers", |
| 76 | + agent={"tool_names": DEFAULT_TOOL_NAMES + ["clinical_trials_search"]}, |
| 77 | + ), |
| 78 | +) |
| 79 | + |
| 80 | +# let's check out the formatted answer (with references included) |
| 81 | +print(answer_response.session.formatted_answer) |
| 82 | +``` |
| 83 | + |
| 84 | + Question: What drugs have been found to effectively treat Ulcerative Colitis? |
| 85 | + |
| 86 | + Several drugs have been found effective in treating Ulcerative Colitis (UC), with treatment |
| 87 | + strategies varying based on disease severity and extent. For mild-to-moderate UC, 5-aminosalicylic |
| 88 | + acid (5-ASA) is the first-line therapy. Topical 5-ASA, such as mesalazine suppositories (1 g/day), |
| 89 | + is effective for proctitis or distal colitis, inducing remission in 31-80% of patients. Oral mesalazine |
| 90 | + at higher doses (e.g., 4.8 g/day) can accelerate clinical improvement in more extensive disease |
| 91 | + (meier2011currenttreatmentof pages 1-2; meier2011currenttreatmentof pages 3-4). |
| 92 | + |
| 93 | + For moderate-to-severe cases, corticosteroids are commonly used. Oral steroids like prednisolone |
| 94 | + (40-60 mg/day) or intravenous steroids such as methylprednisolone (60 mg/day) and hydrocortisone |
| 95 | + (400 mg/day) are standard for inducing remission (meier2011currenttreatmentof pages 3-4). Tumor |
| 96 | + necrosis factor (TNF)-α blockers, such as infliximab, are effective for steroid-refractory cases |
| 97 | + (meier2011currenttreatmentof pages 2-3; meier2011currenttreatmentof pages 3-4). |
| 98 | + |
| 99 | + Immunosuppressive agents, including azathioprine and 6-mercaptopurine, are used for maintenance |
| 100 | + therapy in steroid-dependent or refractory cases (meier2011currenttreatmentof pages 2-3; |
| 101 | + meier2011currenttreatmentof pages 3-4). Antibiotics, such as combinations of penicillin, |
| 102 | + tetracycline, and metronidazole, have shown promise in altering the microbiota and inducing |
| 103 | + remission in some patients, though their efficacy varies (NCT02217722). |
| 104 | + |
| 105 | + References |
| 106 | + |
| 107 | + 1. (meier2011currenttreatmentof pages 2-3): Johannes Meier and Andreas Sturm. Current treatment |
| 108 | + of ulcerative colitis. World journal of gastroenterology, 17 27:3204-12, 2011. |
| 109 | + URL: https://doi.org/10.3748/wjg.v17.i27.3204, doi:10.3748/wjg.v17.i27.3204. |
| 110 | + |
| 111 | + 2. (meier2011currenttreatmentof pages 3-4): Johannes Meier and Andreas Sturm. Current treatment |
| 112 | + of ulcerative colitis. World journal of gastroenterology, 17 27:3204-12, 2011. URL: |
| 113 | + https://doi.org/10.3748/wjg.v17.i27.3204, doi:10.3748/wjg.v17.i27.3204. |
| 114 | + |
| 115 | + 3. (NCT02217722): Prof. Arie Levine. Use of the Ulcerative Colitis Diet for Induction of |
| 116 | + Remission. Prof. Arie Levine. 2014. ClinicalTrials.gov Identifier: NCT02217722 |
| 117 | + |
| 118 | + 4. (meier2011currenttreatmentof pages 1-2): Johannes Meier and Andreas Sturm. Current |
| 119 | + treatment of ulcerative colitis. World journal of gastroenterology, 17 27:3204-12, 2011. |
| 120 | + URL: https://doi.org/10.3748/wjg.v17.i27.3204, doi:10.3748/wjg.v17.i27.3204. |
| 121 | + |
| 122 | +We now see both papers and clinical trials cited in our response. For convenience, we have a |
| 123 | +`Settings.from_name` that works as well: |
| 124 | + |
| 125 | +```python |
| 126 | +from paperqa import Settings, agent_query |
| 127 | + |
| 128 | +answer_response = await agent_query( |
| 129 | + query="What drugs have been found to effectively treat Ulcerative Colitis?", |
| 130 | + settings=Settings.from_name("clinical_trials"), |
| 131 | +) |
| 132 | +``` |
| 133 | + |
| 134 | +And, this works with the `pqa` cli as well: |
| 135 | + |
| 136 | +```bash |
| 137 | +>>> pqa --settings 'search_only_clinical_trials' ask 'what is Ibuprofen effective at treating?' |
| 138 | +``` |
| 139 | + |
| 140 | + ... |
| 141 | + [13:29:50] Completing 'what is Ibuprofen effective at treating?' as 'certain'. |
| 142 | + Answer: Ibuprofen is a non-steroidal anti-inflammatory drug (NSAID) effective |
| 143 | + in treating various conditions, including pain, inflammation, and fever. |
| 144 | + It is widely used for tension-type |
| 145 | + headaches, with studies showing that ibuprofen sodium provides significant |
| 146 | + pain relief and reduces pain intensity compared to standard ibuprofen and placebo |
| 147 | + over a 3-hour period (NCT01362491). |
| 148 | + Intravenous ibuprofen is effective in managing postoperative pain, particularly |
| 149 | + in orthopedic surgeries, and helps control the inflammatory process. When combined |
| 150 | + with opioids, it reduces opioid |
| 151 | + consumption and associated side effects, making it a key component of |
| 152 | + multimodal analgesia (NCT05401916, NCT01773005). |
| 153 | + |
| 154 | + Ibuprofen is also effective in pediatric populations as a first-line |
| 155 | + anti-inflammatory and antipyretic agent due to its relatively |
| 156 | + low adverse effects compared to other NSAIDs (NCT01478022). |
| 157 | + Additionally, it has been studied for its potential use in managing |
| 158 | + chronic periodontitis through subgingival irrigation with a 2% ibuprofen |
| 159 | + mouthwash, which reduces periodontal pocket depth and |
| 160 | + bleeding on probing, improving periodontal health (NCT02538237). |
| 161 | + |
| 162 | + These findings highlight ibuprofen's versatility in treating pain, inflammation, |
| 163 | + fever, and specific conditions like tension headaches, postoperative pain, and periodontal diseases. |
0 commit comments