wakeupmh commited on
Commit
67b3686
·
1 Parent(s): 4660a83

test: agentic rag

Browse files
Files changed (2) hide show
  1. app.py +17 -23
  2. requirements.txt +1 -3
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, pipeline
3
  import os
4
  from datasets import load_from_disk, Dataset
5
  import torch
@@ -8,8 +8,6 @@ import pandas as pd
8
  import arxiv
9
  import requests
10
  import xml.etree.ElementTree as ET
11
- from agno.embedder.huggingface import HuggingfaceCustomEmbedder
12
- from agno.vectordb.lancedb import LanceDb, SearchType
13
 
14
  # Configure logging
15
  logging.basicConfig(level=logging.INFO)
@@ -167,15 +165,26 @@ Answer:"""
167
 
168
  # Streamlit App
169
  st.title("🧩 AMA Autism")
170
- st.write("This app searches through scientific papers to answer your questions about autism. For best results, be specific in your questions.")
171
- query = st.text_input("Please ask me anything about autism ✨")
 
 
 
 
 
172
 
173
  if query:
174
  with st.status("Searching for answers...") as status:
175
  # Search for papers
176
  df = search_research_papers(query)
 
177
  st.write("Searching for data in PubMed and arXiv...")
178
- st.write("Data found!")
 
 
 
 
 
179
 
180
  # Get relevant context
181
  context = "\n".join([
@@ -183,21 +192,6 @@ if query:
183
  ])
184
 
185
  # Generate answer
186
- answer = generate_answer(query, context)
187
  st.write("Generating answer...")
188
- status.update(
189
- label="Search complete!", state="complete", expanded=False
190
- )
191
- if answer and not answer.isspace():
192
- st.success("Answer found!")
193
- st.write(answer)
194
-
195
- st.write("### Sources used:")
196
- for _, row in df.head(3).iterrows():
197
- st.markdown(f"**[{row['title']}]({row['url']})** ({row['published']})")
198
- st.write(f"**Summary:** {row['text'][:200]}...")
199
- st.write("---")
200
- else:
201
- st.warning("I couldn't find a specific answer in the research papers. Try rephrasing your question.")
202
- if df.empty:
203
- st.warning("I couldn't find any relevant research papers about this topic. Please try rephrasing your question or ask something else about autism.")
 
1
  import streamlit as st
2
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
  import os
4
  from datasets import load_from_disk, Dataset
5
  import torch
 
8
  import arxiv
9
  import requests
10
  import xml.etree.ElementTree as ET
 
 
11
 
12
  # Configure logging
13
  logging.basicConfig(level=logging.INFO)
 
165
 
166
  # Streamlit App
167
  st.title("🧩 AMA Autism")
168
+
169
+ st.write("""
170
+ This app searches through scientific papers to answer your questions about autism.
171
+ For best results, be specific in your questions.
172
+ """)
173
+
174
+ query = st.text_input("Please ask me anything about autism >")
175
 
176
  if query:
177
  with st.status("Searching for answers...") as status:
178
  # Search for papers
179
  df = search_research_papers(query)
180
+
181
  st.write("Searching for data in PubMed and arXiv...")
182
+ st.write(f"Found {len(df)} relevant papers!")
183
+
184
+ # Display paper sources
185
+ with st.expander("View source papers"):
186
+ for _, paper in df.iterrows():
187
+ st.markdown(f"- [{paper['title']}]({paper['url']}) ({paper['published']})")
188
 
189
  # Get relevant context
190
  context = "\n".join([
 
192
  ])
193
 
194
  # Generate answer
 
195
  st.write("Generating answer...")
196
+ answer = generate_answer(query, context)
197
+ st.markdown(answer)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -7,6 +7,4 @@ accelerate>=0.26.0
7
  numpy>=1.24.0
8
  pandas>=2.2.0
9
  requests>=2.31.0
10
- arxiv>=2.1.0
11
- lancedb>=0.3.3
12
- tantivy>=0.19.2
 
7
  numpy>=1.24.0
8
  pandas>=2.2.0
9
  requests>=2.31.0
10
+ arxiv>=2.1.0