snsynth commited on
Commit
4cd0922
·
1 Parent(s): f05dd37

moving around app file

Browse files
Files changed (3) hide show
  1. Dockerfile +2 -1
  2. rag_app/app.py +0 -77
  3. rag_app/chat_utils.py +1 -1
Dockerfile CHANGED
@@ -34,4 +34,5 @@ COPY . /finance-rag-chatbot-group39
34
  WORKDIR /finance-rag-chatbot-group39
35
 
36
  # Final command: run the mesop script
37
- CMD ["mesop", "rag_app/app.py", "--port", "8080"]
 
 
34
  WORKDIR /finance-rag-chatbot-group39
35
 
36
  # Final command: run the mesop script
37
+ # CMD ["mesop", "rag_app/app.py", "--port", "8080"]
38
+ CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:me"]
rag_app/app.py DELETED
@@ -1,77 +0,0 @@
1
- import mesop as me
2
- from 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
-
7
- _STYLE_APP_CONTAINER = me.Style(
8
- background=_COLOR_BACKGROUND,
9
- display="flex",
10
- flex_direction="column",
11
- height="100%",
12
- margin=me.Margin.symmetric(vertical=0, horizontal="auto"),
13
- width="min(1024px, 100%)",
14
- box_shadow="0 3px 1px -2px #0003, 0 2px 2px #00000024, 0 1px 5px #0000001f",
15
- padding=me.Padding(top=20, left=20, right=20),
16
- )
17
-
18
-
19
- @me.page()
20
- def app():
21
- state = me.state(State)
22
- with me.box(style=_STYLE_APP_CONTAINER):
23
- with me.box(style=me.Style(
24
- width="min(680%, 100%)",
25
- margin=me.Margin.symmetric(vertical=36, horizontal="auto"),
26
- flex_grow=1,
27
- overflow_y="auto",
28
- padding=me.Padding(left=20, right=20)
29
- )):
30
- me.text("""
31
- FinanceGPT - Powered by open source language models capable of document QnA on Annual
32
- Investor Reports of top companies.
33
- """,
34
- style=me.Style(font_size=20, margin=me.Margin(bottom=24), text_align="center")
35
- )
36
- me.text("ℹ️ Upload annual reports to start asking questions.",
37
- style=me.Style(font_size=12, margin=me.Margin(bottom=24), text_align="center")
38
- )
39
- for index, msg in enumerate(state.output):
40
- with me.box(style=_make_style_chat_bubble_wrapper(msg.role), key=f"msg-{index}"):
41
- if msg.role == _ROLE_ASSISTANT:
42
- me.text("assistant", style=_STYLE_CHAT_BUBBLE_NAME)
43
- with me.box(style=_make_chat_bubble_style(msg.role)):
44
- me.markdown(msg.content)
45
- if state.in_progress:
46
- me.progress_spinner()
47
- with me.box(key="scroll-to", style=me.Style(height=250)):
48
- pass
49
- with me.box(style=me.Style(
50
- padding=me.Padding(top=30, left=20, right=20),
51
- display="flex",
52
- flex_direction="row"
53
- )):
54
- with me.content_uploader(
55
- accepted_file_types=["application/pdf"],
56
- on_upload=handle_pdf_upload,
57
- type="icon",
58
- style=me.Style(font_weight="bold", margin=me.Margin(right=8)),
59
- ):
60
- me.icon("attach_file")
61
-
62
- with me.box(style=me.Style(flex_grow=1)):
63
- me.input(
64
- label="Enter your prompt",
65
- key=f"input-{len(state.output)}",
66
- on_input=on_chat_input,
67
- on_enter=on_click_submit_chat_msg,
68
- style=me.Style(width="100%")
69
- )
70
- with me.content_button(
71
- color="primary",
72
- type="flat",
73
- disabled=state.in_progress,
74
- on_click=on_click_submit_chat_msg,
75
- style=me.Style(margin=me.Margin(top=8, left=8))
76
- ):
77
- me.icon("send" if not state.in_progress else "pending")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rag_app/chat_utils.py CHANGED
@@ -3,7 +3,7 @@ import mesop as me
3
  from dataclasses import dataclass, field
4
  from typing import Callable, Generator, Literal
5
  import time
6
- from rag import extract_final_answer, answer_question
7
 
8
 
9
  Role = Literal["user", "assistant"]
 
3
  from dataclasses import dataclass, field
4
  from typing import Callable, Generator, Literal
5
  import time
6
+ from rag_app.rag import extract_final_answer, answer_question
7
 
8
 
9
  Role = Literal["user", "assistant"]