Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
@@ -54,6 +54,31 @@ def get_right_col_content(selected_type):
|
|
54 |
type="dot",
|
55 |
children=[html.Div(id="loading-output")]
|
56 |
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
controls.append(
|
58 |
dbc.Row([
|
59 |
dbc.Col(
|
@@ -104,13 +129,37 @@ def get_right_col_content(selected_type):
|
|
104 |
def get_left_col_content():
|
105 |
chat_card = dbc.Card(
|
106 |
dbc.CardBody([
|
107 |
-
html.H5("
|
108 |
dcc.Loading(
|
109 |
id="chat-loading",
|
110 |
type="dot",
|
111 |
children=[
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
html.Div(id="chat-output")
|
115 |
]
|
116 |
)
|
@@ -118,29 +167,10 @@ def get_left_col_content():
|
|
118 |
className="mt-4"
|
119 |
)
|
120 |
return [
|
121 |
-
html.H4("Proposal
|
122 |
html.Div([
|
123 |
html.Div(className="blinking-dot", style={'margin':'0 auto','width':'16px','height':'16px'}),
|
124 |
], style={'textAlign':'center', 'marginBottom':'10px'}),
|
125 |
-
dcc.Upload(
|
126 |
-
id='upload-document',
|
127 |
-
children=html.Div([
|
128 |
-
'Drag and Drop or ',
|
129 |
-
html.A('Select Files')
|
130 |
-
]),
|
131 |
-
style={
|
132 |
-
'width': '100%',
|
133 |
-
'height': '60px',
|
134 |
-
'lineHeight': '60px',
|
135 |
-
'borderWidth': '1px',
|
136 |
-
'borderStyle': 'dashed',
|
137 |
-
'borderRadius': '5px',
|
138 |
-
'textAlign': 'center',
|
139 |
-
'margin': '10px 0'
|
140 |
-
},
|
141 |
-
multiple=True
|
142 |
-
),
|
143 |
-
file_list_component(),
|
144 |
html.Hr(),
|
145 |
html.Div(
|
146 |
id='doc-type-buttons'
|
@@ -519,12 +549,19 @@ Now, generate the {document_type}:
|
|
519 |
Output('chat-output', 'children'),
|
520 |
Output('document-preview', 'children', allow_duplicate=True),
|
521 |
Input('btn-send-chat', 'n_clicks'),
|
|
|
522 |
State('chat-input', 'value'),
|
523 |
State('selected-doc-type', 'data'),
|
524 |
prevent_initial_call=True
|
525 |
)
|
526 |
-
def update_document_via_chat(
|
527 |
global current_document, document_type
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
if not chat_input or current_document is None:
|
529 |
raise dash.exceptions.PreventUpdate
|
530 |
|
|
|
54 |
type="dot",
|
55 |
children=[html.Div(id="loading-output")]
|
56 |
))
|
57 |
+
# Show upload box for SHRED only
|
58 |
+
if selected_type == "Shred":
|
59 |
+
controls.append(
|
60 |
+
html.Div([
|
61 |
+
dcc.Upload(
|
62 |
+
id='upload-document',
|
63 |
+
children=html.Div([
|
64 |
+
'Drag and Drop or ',
|
65 |
+
html.A('Select Files')
|
66 |
+
]),
|
67 |
+
style={
|
68 |
+
'width': '100%',
|
69 |
+
'height': '60px',
|
70 |
+
'lineHeight': '60px',
|
71 |
+
'borderWidth': '1px',
|
72 |
+
'borderStyle': 'dashed',
|
73 |
+
'borderRadius': '5px',
|
74 |
+
'textAlign': 'center',
|
75 |
+
'margin': '10px 0'
|
76 |
+
},
|
77 |
+
multiple=True
|
78 |
+
),
|
79 |
+
file_list_component()
|
80 |
+
])
|
81 |
+
)
|
82 |
controls.append(
|
83 |
dbc.Row([
|
84 |
dbc.Col(
|
|
|
129 |
def get_left_col_content():
|
130 |
chat_card = dbc.Card(
|
131 |
dbc.CardBody([
|
132 |
+
html.H5("Maiko Chat", className="mb-2"),
|
133 |
dcc.Loading(
|
134 |
id="chat-loading",
|
135 |
type="dot",
|
136 |
children=[
|
137 |
+
dcc.Textarea(
|
138 |
+
id="chat-input",
|
139 |
+
placeholder="Chat with AI to update document...",
|
140 |
+
className="mb-2",
|
141 |
+
style={
|
142 |
+
'whiteSpace':'pre-wrap',
|
143 |
+
'width': '100%',
|
144 |
+
'minHeight': '100px',
|
145 |
+
'maxHeight': '300px',
|
146 |
+
'resize': 'vertical',
|
147 |
+
'overflowY': 'auto'
|
148 |
+
},
|
149 |
+
rows=5,
|
150 |
+
autoFocus=False,
|
151 |
+
wrap='soft'
|
152 |
+
),
|
153 |
+
dbc.Row([
|
154 |
+
dbc.Col(
|
155 |
+
dbc.Button("Send", id="btn-send-chat", color="primary", className="mb-3 w-100"),
|
156 |
+
width=6
|
157 |
+
),
|
158 |
+
dbc.Col(
|
159 |
+
dbc.Button("Clear Chat", id="btn-clear-chat", color="secondary", className="mb-3 w-100"),
|
160 |
+
width=6
|
161 |
+
),
|
162 |
+
], className="g-1 mb-2"),
|
163 |
html.Div(id="chat-output")
|
164 |
]
|
165 |
)
|
|
|
167 |
className="mt-4"
|
168 |
)
|
169 |
return [
|
170 |
+
html.H4("Proposal Writer", className="mt-3 mb-4"),
|
171 |
html.Div([
|
172 |
html.Div(className="blinking-dot", style={'margin':'0 auto','width':'16px','height':'16px'}),
|
173 |
], style={'textAlign':'center', 'marginBottom':'10px'}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
html.Hr(),
|
175 |
html.Div(
|
176 |
id='doc-type-buttons'
|
|
|
549 |
Output('chat-output', 'children'),
|
550 |
Output('document-preview', 'children', allow_duplicate=True),
|
551 |
Input('btn-send-chat', 'n_clicks'),
|
552 |
+
Input('btn-clear-chat', 'n_clicks'),
|
553 |
State('chat-input', 'value'),
|
554 |
State('selected-doc-type', 'data'),
|
555 |
prevent_initial_call=True
|
556 |
)
|
557 |
+
def update_document_via_chat(btn_send, btn_clear, chat_input, selected_doc_type):
|
558 |
global current_document, document_type
|
559 |
+
ctx = callback_context
|
560 |
+
if not ctx.triggered:
|
561 |
+
raise dash.exceptions.PreventUpdate
|
562 |
+
trigger_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
563 |
+
if trigger_id == 'btn-clear-chat':
|
564 |
+
return "", dash.no_update
|
565 |
if not chat_input or current_document is None:
|
566 |
raise dash.exceptions.PreventUpdate
|
567 |
|