Skip to content

Commit

Permalink
Fixes to frontend app, demo app up again
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomarin committed Mar 15, 2024
1 parent 1304843 commit 587c2e4
Show file tree
Hide file tree
Showing 12 changed files with 363 additions and 227 deletions.
56 changes: 53 additions & 3 deletions 03-Quering-AOpenAI.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@
{
"data": {
"text/markdown": [
"El medicamento que se utiliza comúnmente para reducir la inflamación en los pulmones es un corticoide inhalado. Este tipo de medicamento ayuda a disminuir la inflamación en las vías respiratorias y puede ser recetado para tratar condiciones como el asma y la enfermedad pulmonar obstructiva crónica (EPOC). Es importante seguir las indicaciones de un médico para el uso adecuado de este tipo de medicamentos y para controlar cualquier efecto secundario que pueda presentarse."
"El medicamento que reduce la inflamación en los pulmones se llama corticoide inhalado. Este tipo de medicamento se usa comúnmente para tratar enfermedades respiratorias como el asma y la enfermedad pulmonar obstructiva crónica (EPOC). Los corticoides inhalados ayudan a reducir la inflamación en los pulmones y a aliviar los síntomas respiratorios. Es importante seguir las indicaciones de un médico para el uso adecuado de este medicamento."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -748,8 +748,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 45.9 ms, sys: 4.05 ms, total: 49.9 ms\n",
"Wall time: 2.32 s\n"
"CPU times: user 38.5 ms, sys: 7.78 ms, total: 46.3 ms\n",
"Wall time: 900 ms\n"
]
}
],
Expand Down Expand Up @@ -877,6 +877,56 @@
"print(\"Number of results:\",len(ordered_results))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "d9334b4b-a378-4d99-b04b-4762d35e8c0a",
"metadata": {},
"outputs": [],
"source": [
"top_docs = []\n",
"for key,value in ordered_results.items():\n",
" location = value[\"location\"] if value[\"location\"] is not None else \"\"\n",
" top_docs.append(Document(page_content=value[\"chunk\"], metadata={\"source\": location, \"score\":value[\"score\"]}))"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "ffed0ea2-1d21-477b-a6cd-20621589e204",
"metadata": {},
"outputs": [],
"source": [
"chain = (\n",
" DOCSEARCH_PROMPT # Passes the 4 variables above to the prompt template\n",
" | llm # Passes the finished prompt to the LLM\n",
" | StrOutputParser() # converts the output (Runnable object) to the desired output (string)\n",
")\n",
"\n",
"answer = chain.invoke({\"question\": QUESTION, \"context\":top_docs})"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "32ba674f-4094-4d32-add4-761d1d79940f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Chloroquine is a medicine that has been found to reduce inflammation in the lungs. On human lung parenchymal explants, chloroquine concentration clinically achievable in the lung (100 μM) inhibited the lipopolysaccharide-induced release of TNF-α (by 76%), IL-6 (by 68%), CCL2 (by 72%) and CCL3 (by 67%)<sup><a href=\"https://doi.org/10.1093/cid/ciaa546\" target=\"_blank\">[1]</a></sup>. Additionally, chest irradiation using low doses of radiation therapy (RT) has been shown to mitigate lung inflammatory processes. It was found that low doses of RT significantly increased the percentage of Nerve- and airway-associated macrophages (NAMs) producing IL-10, leading to lung protection from inflammation<sup><a href=\"https://doi.org/10.1101/2020.05.11.077651\" target=\"_blank\">[3]</a></sup>. Furthermore, the anti-inflammatory effects of glucocorticoids in the lungs of severe acute respiratory syndrome (SARS) patients have been studied. The corticosteroid dexamethasone (DEX) was found to decrease innate and Th1 cytokines in bronchoalveolar lavage (BAL) and serum in a porcine respiratory coronavirus (PRCV) infection model, suggesting potential local immunosuppression of immune responses in the lung and systemic Th1 cytokine-biased suppression<sup><a href=\"https://doi.org/10.1128/jvi.02190-07\" target=\"_blank\">[14]</a></sup>.\\n\\nReferences:\\n1. https://doi.org/10.1093/cid/ciaa546\\n2. https://doi.org/10.1101/2020.05.11.077651\\n3. https://doi.org/10.1128/jvi.02190-07'"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"answer"
]
},
{
"cell_type": "code",
"execution_count": 14,
Expand Down
6 changes: 3 additions & 3 deletions 07-TabularDataQA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"--2024-03-14 21:21:20-- https://covidtracking.com/data/download/all-states-history.csv\n",
"--2024-03-15 09:41:47-- https://covidtracking.com/data/download/all-states-history.csv\n",
"Resolving covidtracking.com (covidtracking.com)... 104.21.64.114, 172.67.183.132, 2606:4700:3032::ac43:b784, ...\n",
"Connecting to covidtracking.com (covidtracking.com)|104.21.64.114|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: unspecified [text/csv]\n",
"Saving to: ‘./data/all-states-history.csv’\n",
"\n",
"all-states-history. [ <=> ] 2.61M --.-KB/s in 0.08s \n",
"all-states-history. [ <=> ] 2.61M --.-KB/s in 0.05s \n",
"\n",
"2024-03-14 21:21:21 (33.9 MB/s) - ‘./data/all-states-history.csv’ saved [2738601]\n",
"2024-03-15 09:41:48 (49.1 MB/s) - ‘./data/all-states-history.csv’ saved [2738601]\n",
"\n"
]
}
Expand Down
Loading

0 comments on commit 587c2e4

Please sign in to comment.