Spaces:
Sleeping
Sleeping
Commit
·
585c783
1
Parent(s):
d57df86
refactor ♻️: Update Dockerfile and code structure for improved search result layout
Browse files- Dockerfile +2 -1
- app.py +0 -6
- chroma_utils.py +0 -6
- scrap.py +3 -2
Dockerfile
CHANGED
@@ -13,6 +13,7 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
13 |
# Copy Python source files
|
14 |
COPY *.py .
|
15 |
|
16 |
-
|
|
|
17 |
CMD ["streamlit", "run", "app.py", "--server.port", "2000"]
|
18 |
|
|
|
13 |
# Copy Python source files
|
14 |
COPY *.py .
|
15 |
|
16 |
+
RUN [ "python", "-m", "scrap" ]
|
17 |
+
|
18 |
CMD ["streamlit", "run", "app.py", "--server.port", "2000"]
|
19 |
|
app.py
CHANGED
@@ -8,8 +8,6 @@ question = st.text_input("Haz una pregunta para encontrar en el manual")
|
|
8 |
if question:
|
9 |
results = ask_chroma(question, k=5)
|
10 |
for i, result in enumerate(results):
|
11 |
-
# st.page_link(result.metadata['url'],
|
12 |
-
# label=f"{result.metadata['title']}", help=f"{result.page_content[:250]} ...", )
|
13 |
with st.container(border=True):
|
14 |
st.markdown(
|
15 |
f"## [{result.metadata['title']}]({result.metadata['url']}) ")
|
@@ -17,7 +15,3 @@ if question:
|
|
17 |
st.markdown(f"{result.page_content[:500]}...")
|
18 |
else:
|
19 |
st.markdown(result.page_content)
|
20 |
-
# with st.expander(f"**Titulo:** {result.metadata['title']}"):
|
21 |
-
# st.markdown(f"**Resumen:** {result.page_content[:250]} ...")
|
22 |
-
# st.markdown(
|
23 |
-
# f"**Enlace:** [{result.metadata['title']}]({result.metadata['url']})")
|
|
|
8 |
if question:
|
9 |
results = ask_chroma(question, k=5)
|
10 |
for i, result in enumerate(results):
|
|
|
|
|
11 |
with st.container(border=True):
|
12 |
st.markdown(
|
13 |
f"## [{result.metadata['title']}]({result.metadata['url']}) ")
|
|
|
15 |
st.markdown(f"{result.page_content[:500]}...")
|
16 |
else:
|
17 |
st.markdown(result.page_content)
|
|
|
|
|
|
|
|
chroma_utils.py
CHANGED
@@ -63,9 +63,3 @@ def ask_chroma(question: str, k: int = 3) -> dict:
|
|
63 |
except Exception as e:
|
64 |
print(f"Error asking Chroma: {e}")
|
65 |
return {}
|
66 |
-
|
67 |
-
|
68 |
-
# similars = ask_chroma(
|
69 |
-
# "¿Quienes asisten al consejo de barrio?", 2)
|
70 |
-
# for similar in similars:
|
71 |
-
# print(similar.page_content+"\n"*3)
|
|
|
63 |
except Exception as e:
|
64 |
print(f"Error asking Chroma: {e}")
|
65 |
return {}
|
|
|
|
|
|
|
|
|
|
|
|
scrap.py
CHANGED
@@ -102,5 +102,6 @@ def update_handbook_data(handbook_url):
|
|
102 |
save_handbook_to_chroma(handbook_data)
|
103 |
|
104 |
|
105 |
-
|
106 |
-
|
|
|
|
102 |
save_handbook_to_chroma(handbook_data)
|
103 |
|
104 |
|
105 |
+
if __name__ == '__main__':
|
106 |
+
update_handbook_data(
|
107 |
+
"https://www.churchofjesuschrist.org/study/manual/general-handbook?lang=spa")
|