Spaces:
Sleeping
Sleeping
precompute at start
Browse files- Dockerfile +1 -1
- main.py +6 -0
- rag_app/chat_utils.py +3 -3
Dockerfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# Use an official Miniconda image as the base
|
| 2 |
FROM python:3.10.15-bullseye
|
| 3 |
-
ENV PIP_DEFAULT_TIMEOUT=
|
| 4 |
|
| 5 |
RUN apt-get update && \
|
| 6 |
apt-get install -y \
|
|
|
|
| 1 |
# Use an official Miniconda image as the base
|
| 2 |
FROM python:3.10.15-bullseye
|
| 3 |
+
ENV PIP_DEFAULT_TIMEOUT=500
|
| 4 |
|
| 5 |
RUN apt-get update && \
|
| 6 |
apt-get install -y \
|
main.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import mesop as me
|
| 2 |
from rag_app.chat_utils import State, _make_style_chat_bubble_wrapper, _ROLE_ASSISTANT, on_chat_input, _make_chat_bubble_style, \
|
| 3 |
on_click_submit_chat_msg, _STYLE_CHAT_BUBBLE_NAME, handle_pdf_upload
|
|
|
|
|
|
|
| 4 |
|
| 5 |
_COLOR_BACKGROUND = me.theme_var("background")
|
| 6 |
|
|
@@ -20,6 +22,10 @@ _STYLE_APP_CONTAINER = me.Style(
|
|
| 20 |
allowed_iframe_parents=["https://huggingface.co"]
|
| 21 |
))
|
| 22 |
def app():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
state = me.state(State)
|
| 24 |
with me.box(style=_STYLE_APP_CONTAINER):
|
| 25 |
with me.box(style=me.Style(
|
|
|
|
| 1 |
import mesop as me
|
| 2 |
from rag_app.chat_utils import State, _make_style_chat_bubble_wrapper, _ROLE_ASSISTANT, on_chat_input, _make_chat_bubble_style, \
|
| 3 |
on_click_submit_chat_msg, _STYLE_CHAT_BUBBLE_NAME, handle_pdf_upload
|
| 4 |
+
from rag_app.rag_2 import check_if_exists, precompute_index
|
| 5 |
+
|
| 6 |
|
| 7 |
_COLOR_BACKGROUND = me.theme_var("background")
|
| 8 |
|
|
|
|
| 22 |
allowed_iframe_parents=["https://huggingface.co"]
|
| 23 |
))
|
| 24 |
def app():
|
| 25 |
+
if not check_if_exists():
|
| 26 |
+
print("precomputing the index")
|
| 27 |
+
precompute_index()
|
| 28 |
+
|
| 29 |
state = me.state(State)
|
| 30 |
with me.box(style=_STYLE_APP_CONTAINER):
|
| 31 |
with me.box(style=me.Style(
|
rag_app/chat_utils.py
CHANGED
|
@@ -37,9 +37,9 @@ class State:
|
|
| 37 |
|
| 38 |
|
| 39 |
def respond_to_chat(query: str, history: list[ChatMessage]):
|
| 40 |
-
if not check_if_exists():
|
| 41 |
-
|
| 42 |
-
|
| 43 |
|
| 44 |
assistant_message = ChatMessage(role=_ROLE_ASSISTANT)
|
| 45 |
yield assistant_message
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
def respond_to_chat(query: str, history: list[ChatMessage]):
|
| 40 |
+
# if not check_if_exists():
|
| 41 |
+
# print("computing the vector index and the BM 25 retriever which will later be used")
|
| 42 |
+
# precompute_index()
|
| 43 |
|
| 44 |
assistant_message = ChatMessage(role=_ROLE_ASSISTANT)
|
| 45 |
yield assistant_message
|