fix/roll-back-to-english-version
Browse files- src/chatbot/app_interface.py +19 -19
- src/chatbot/dashboard/dashboard_page.py +19 -32
- src/chatbot/dashboard/visualize_component.py +19 -19
- src/chatbot/main.py +3 -3
- src/chatbot/nodes.py +1 -2
- src/chatbot/prompts/agent_prompts.py +5 -4
src/chatbot/app_interface.py
CHANGED
|
@@ -120,12 +120,12 @@ def handle_submit():
|
|
| 120 |
]
|
| 121 |
for field in required_fields:
|
| 122 |
if not form_data.get(field) or form_data.get(field) == "None":
|
| 123 |
-
return gr.update(value="❌
|
| 124 |
save_expense_to_db(form_data)
|
| 125 |
-
return gr.update(value="✅
|
| 126 |
|
| 127 |
_chat_prefill = [
|
| 128 |
-
{"role": "assistant", "content": "
|
| 129 |
]
|
| 130 |
|
| 131 |
def chat_handler(message, history):
|
|
@@ -147,42 +147,42 @@ def create_expense_register_page():
|
|
| 147 |
form_information = gr.State(form_info)
|
| 148 |
new_btn = gr.Button("Reset", variant="primary")
|
| 149 |
with gr.Tabs():
|
| 150 |
-
with gr.Tab("
|
| 151 |
chat_interface = gr.ChatInterface(
|
| 152 |
fn=chat_handler,
|
| 153 |
type="messages",
|
| 154 |
-
chatbot=gr.Chatbot(value=_chat_prefill, type="messages", label="
|
| 155 |
multimodal=True,
|
| 156 |
-
submit_btn="
|
| 157 |
autofocus=True,
|
| 158 |
examples=None,
|
| 159 |
additional_outputs=[form_information]
|
| 160 |
)
|
| 161 |
|
| 162 |
-
with gr.Tab("
|
| 163 |
-
gr.Markdown("**
|
| 164 |
deliverable_dropdown = gr.Dropdown(choices=get_deliverable_titles(), filterable=False, container=False)
|
| 165 |
-
gr.Markdown("**
|
| 166 |
seller_name_input = gr.Textbox(value=ast.literal_eval(form_info["Seller Name"]), label="", container=False)
|
| 167 |
-
gr.Markdown("**
|
| 168 |
seller_address_input = gr.Textbox(value=ast.literal_eval(form_info["Seller Address"]), label="", container=False)
|
| 169 |
-
gr.Markdown("**
|
| 170 |
seller_phone_number_input = gr.Textbox(value=ast.literal_eval(form_info["Seller Phone Number"]), label="", container=False)
|
| 171 |
-
gr.Markdown("**
|
| 172 |
buyer_name_input = gr.Textbox(value=ast.literal_eval(form_info["Buyer Name"]), label="", container=False)
|
| 173 |
-
gr.Markdown("**
|
| 174 |
buyer_address_input = gr.Textbox(value=ast.literal_eval(form_info["Buyer Address"]), label="", container=False)
|
| 175 |
-
gr.Markdown("**
|
| 176 |
transaction_date_input = gr.DateTime(include_time=False, type="datetime", show_label=False)
|
| 177 |
-
gr.Markdown("**
|
| 178 |
with gr.Row():
|
| 179 |
total_payment_amount_input = gr.Number(value=ast.literal_eval(form_info['Total Payment Amount']), label="", container=False)
|
| 180 |
-
gr.Markdown("
|
| 181 |
-
gr.Markdown("**
|
| 182 |
expense_description_input = gr.Textbox(value=ast.literal_eval(form_info["Expense Description"]), label="", container=False, lines=4)
|
| 183 |
|
| 184 |
feedback_message = gr.Markdown("", visible=False)
|
| 185 |
-
submit_btn = gr.Button("
|
| 186 |
|
| 187 |
deliverable_dropdown.change(update_field_input("Associated Deliverable"), inputs=[deliverable_dropdown], outputs=[form_information],queue=False)
|
| 188 |
seller_name_input.change(update_field_input("Seller Name"), inputs=[seller_name_input], outputs=[form_information],queue=False)
|
|
@@ -249,4 +249,4 @@ def create_expense_register_page():
|
|
| 249 |
|
| 250 |
if __name__ == "__main__":
|
| 251 |
page = create_expense_register_page()
|
| 252 |
-
page.launch()
|
|
|
|
| 120 |
]
|
| 121 |
for field in required_fields:
|
| 122 |
if not form_data.get(field) or form_data.get(field) == "None":
|
| 123 |
+
return gr.update(value="❌ Please complete all required fields.", visible=True)
|
| 124 |
save_expense_to_db(form_data)
|
| 125 |
+
return gr.update(value="✅ Expense saved successfully.", visible=True)
|
| 126 |
|
| 127 |
_chat_prefill = [
|
| 128 |
+
{"role": "assistant", "content": "Hello, my name is Emmie. I'm happy to help you with submitting your expense items. You can start by uploading a picture of one bill."}
|
| 129 |
]
|
| 130 |
|
| 131 |
def chat_handler(message, history):
|
|
|
|
| 147 |
form_information = gr.State(form_info)
|
| 148 |
new_btn = gr.Button("Reset", variant="primary")
|
| 149 |
with gr.Tabs():
|
| 150 |
+
with gr.Tab("Chat"):
|
| 151 |
chat_interface = gr.ChatInterface(
|
| 152 |
fn=chat_handler,
|
| 153 |
type="messages",
|
| 154 |
+
chatbot=gr.Chatbot(value=_chat_prefill, type="messages", label="Message Box"),
|
| 155 |
multimodal=True,
|
| 156 |
+
submit_btn="Send Message",
|
| 157 |
autofocus=True,
|
| 158 |
examples=None,
|
| 159 |
additional_outputs=[form_information]
|
| 160 |
)
|
| 161 |
|
| 162 |
+
with gr.Tab("Form"):
|
| 163 |
+
gr.Markdown("**Deliverable**")
|
| 164 |
deliverable_dropdown = gr.Dropdown(choices=get_deliverable_titles(), filterable=False, container=False)
|
| 165 |
+
gr.Markdown("**Seller Name**")
|
| 166 |
seller_name_input = gr.Textbox(value=ast.literal_eval(form_info["Seller Name"]), label="", container=False)
|
| 167 |
+
gr.Markdown("**Seller Address**")
|
| 168 |
seller_address_input = gr.Textbox(value=ast.literal_eval(form_info["Seller Address"]), label="", container=False)
|
| 169 |
+
gr.Markdown("**Seller Phone Number**")
|
| 170 |
seller_phone_number_input = gr.Textbox(value=ast.literal_eval(form_info["Seller Phone Number"]), label="", container=False)
|
| 171 |
+
gr.Markdown("**Buyer Name**")
|
| 172 |
buyer_name_input = gr.Textbox(value=ast.literal_eval(form_info["Buyer Name"]), label="", container=False)
|
| 173 |
+
gr.Markdown("**Buyer Address**")
|
| 174 |
buyer_address_input = gr.Textbox(value=ast.literal_eval(form_info["Buyer Address"]), label="", container=False)
|
| 175 |
+
gr.Markdown("**Transaction Date**")
|
| 176 |
transaction_date_input = gr.DateTime(include_time=False, type="datetime", show_label=False)
|
| 177 |
+
gr.Markdown("**Total Payment Amount**")
|
| 178 |
with gr.Row():
|
| 179 |
total_payment_amount_input = gr.Number(value=ast.literal_eval(form_info['Total Payment Amount']), label="", container=False)
|
| 180 |
+
gr.Markdown("Baht")
|
| 181 |
+
gr.Markdown("**Expense Description**")
|
| 182 |
expense_description_input = gr.Textbox(value=ast.literal_eval(form_info["Expense Description"]), label="", container=False, lines=4)
|
| 183 |
|
| 184 |
feedback_message = gr.Markdown("", visible=False)
|
| 185 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
| 186 |
|
| 187 |
deliverable_dropdown.change(update_field_input("Associated Deliverable"), inputs=[deliverable_dropdown], outputs=[form_information],queue=False)
|
| 188 |
seller_name_input.change(update_field_input("Seller Name"), inputs=[seller_name_input], outputs=[form_information],queue=False)
|
|
|
|
| 249 |
|
| 250 |
if __name__ == "__main__":
|
| 251 |
page = create_expense_register_page()
|
| 252 |
+
page.launch()
|
src/chatbot/dashboard/dashboard_page.py
CHANGED
|
@@ -108,55 +108,55 @@ def create_dashboard_page():
|
|
| 108 |
|
| 109 |
# --- Page 1: Project Selection ---
|
| 110 |
with gr.Column(visible=True) as project_selector_page:
|
| 111 |
-
gr.Markdown("# 🌍
|
| 112 |
project_dropdown = gr.Dropdown(
|
| 113 |
choices=[(p['title'], p['project_id']) for p in project_options],
|
| 114 |
-
label="
|
| 115 |
)
|
| 116 |
-
project_go_button = gr.Button("
|
| 117 |
|
| 118 |
# --- Page 2: Dashboard View ---
|
| 119 |
with gr.Column(visible=False) as dashboard_page:
|
| 120 |
dashboard_header = gr.Markdown("")
|
| 121 |
project_detail_md = gr.Markdown()
|
| 122 |
-
back_button = gr.Button("⬅
|
| 123 |
|
| 124 |
with gr.Column():
|
| 125 |
-
gr.Markdown("## 💰
|
| 126 |
|
| 127 |
-
gr.Markdown("###
|
| 128 |
with gr.Row():
|
| 129 |
total_budget_md = gr.Markdown()
|
| 130 |
total_expense_md = gr.Markdown()
|
| 131 |
leftover_md = gr.Markdown()
|
| 132 |
|
| 133 |
-
gr.Markdown("###
|
| 134 |
gauge_plot = gr.Plot()
|
| 135 |
|
| 136 |
-
gr.Markdown("## 📦
|
| 137 |
|
| 138 |
-
gr.Markdown("###
|
| 139 |
with gr.Row():
|
| 140 |
bar_chart_plot = gr.Plot()
|
| 141 |
pie_chart_plot = gr.Plot()
|
| 142 |
|
| 143 |
-
gr.Markdown("###
|
| 144 |
with gr.Row():
|
| 145 |
daily_plot = gr.Plot()
|
| 146 |
cum_plot = gr.Plot()
|
| 147 |
|
| 148 |
-
gr.Markdown("###
|
| 149 |
with gr.Row():
|
| 150 |
with gr.Column(scale=1):
|
| 151 |
risk_plot = gr.Plot()
|
| 152 |
with gr.Column(scale=2):
|
| 153 |
cards_html = gr.HTML()
|
| 154 |
|
| 155 |
-
gr.Markdown("###
|
| 156 |
gantt_plot = gr.Plot()
|
| 157 |
|
| 158 |
|
| 159 |
-
gr.Markdown("## 💵
|
| 160 |
search_box = gr.Textbox(placeholder="Search expenses", label="Search")
|
| 161 |
expense_table = gr.DataFrame()
|
| 162 |
|
|
@@ -186,28 +186,15 @@ def create_dashboard_page():
|
|
| 186 |
|
| 187 |
detail_text = update_project_detail(project_id)
|
| 188 |
|
| 189 |
-
df_display = expenses.drop(columns=["expense_id", "associated_deliverable_id"]).rename(columns={
|
| 190 |
-
"deliverable_title": "ชื่อการส่งมอบงาน",
|
| 191 |
-
"seller_name": "ชื่อผู้ขาย",
|
| 192 |
-
"seller_address": "ที่อยู่ผู้ขาย",
|
| 193 |
-
"seller_phone_number": "เบอร์โทรผู้ขาย",
|
| 194 |
-
"buyer_name": "ชื่อผู้ซื้อ",
|
| 195 |
-
"buyer_address": "ที่อยู่ผู้ซื้อ",
|
| 196 |
-
"transaction_date": "วันที่ทำรายการ",
|
| 197 |
-
"total_payment_amount": "จำนวนเงินทั้งหมด",
|
| 198 |
-
"expense_description": "รายละเอียดค่าใช้จ่าย",
|
| 199 |
-
"status": "สถานะ"
|
| 200 |
-
})
|
| 201 |
-
|
| 202 |
return [
|
| 203 |
project_id,
|
| 204 |
gr.update(visible=False),
|
| 205 |
gr.update(visible=True),
|
| 206 |
-
gr.update(value=f"# 📊
|
| 207 |
gr.update(value=detail_text),
|
| 208 |
-
gr.update(value=f"###
|
| 209 |
-
gr.update(value=f"###
|
| 210 |
-
gr.update(value=f"###
|
| 211 |
gr.update(value=generate_budget_utilization_gauge_chart(total_budget, total_expense)),
|
| 212 |
gr.update(value=generate_deliverable_budget_vs_expense_bar_chart(budgets, expenses)),
|
| 213 |
gr.update(value=generate_spending_distribution_pie_chart(expenses, budgets)),
|
|
@@ -216,7 +203,7 @@ def create_dashboard_page():
|
|
| 216 |
gr.update(value=generate_risk_level_distribution_pie_chart(deliverables)),
|
| 217 |
gr.update(value=generate_deliverable_timeline_gantt_chart(deliverables)),
|
| 218 |
gr.update(value=render_deliverable_summary_cards(deliverables)),
|
| 219 |
-
gr.update(value=
|
| 220 |
expenses
|
| 221 |
]
|
| 222 |
|
|
@@ -259,4 +246,4 @@ def create_dashboard_page():
|
|
| 259 |
|
| 260 |
if __name__ == "__main__":
|
| 261 |
page = create_dashboard_page()
|
| 262 |
-
page.launch()
|
|
|
|
| 108 |
|
| 109 |
# --- Page 1: Project Selection ---
|
| 110 |
with gr.Column(visible=True) as project_selector_page:
|
| 111 |
+
gr.Markdown("# 🌍 Select a Project")
|
| 112 |
project_dropdown = gr.Dropdown(
|
| 113 |
choices=[(p['title'], p['project_id']) for p in project_options],
|
| 114 |
+
label="Choose a Project"
|
| 115 |
)
|
| 116 |
+
project_go_button = gr.Button("View Dashboard")
|
| 117 |
|
| 118 |
# --- Page 2: Dashboard View ---
|
| 119 |
with gr.Column(visible=False) as dashboard_page:
|
| 120 |
dashboard_header = gr.Markdown("")
|
| 121 |
project_detail_md = gr.Markdown()
|
| 122 |
+
back_button = gr.Button("⬅ Back to Projects")
|
| 123 |
|
| 124 |
with gr.Column():
|
| 125 |
+
gr.Markdown("## 💰 Overall Project Financial Snapshot")
|
| 126 |
|
| 127 |
+
gr.Markdown("### Budget Summary")
|
| 128 |
with gr.Row():
|
| 129 |
total_budget_md = gr.Markdown()
|
| 130 |
total_expense_md = gr.Markdown()
|
| 131 |
leftover_md = gr.Markdown()
|
| 132 |
|
| 133 |
+
gr.Markdown("### Utilization Gauge")
|
| 134 |
gauge_plot = gr.Plot()
|
| 135 |
|
| 136 |
+
gr.Markdown("## 📦 Deliverable-Level Financial Insights")
|
| 137 |
|
| 138 |
+
gr.Markdown("### Budget vs Expense")
|
| 139 |
with gr.Row():
|
| 140 |
bar_chart_plot = gr.Plot()
|
| 141 |
pie_chart_plot = gr.Plot()
|
| 142 |
|
| 143 |
+
gr.Markdown("### Spending Over Time")
|
| 144 |
with gr.Row():
|
| 145 |
daily_plot = gr.Plot()
|
| 146 |
cum_plot = gr.Plot()
|
| 147 |
|
| 148 |
+
gr.Markdown("### Risk & Deliverables")
|
| 149 |
with gr.Row():
|
| 150 |
with gr.Column(scale=1):
|
| 151 |
risk_plot = gr.Plot()
|
| 152 |
with gr.Column(scale=2):
|
| 153 |
cards_html = gr.HTML()
|
| 154 |
|
| 155 |
+
gr.Markdown("### Deliverable Timeline (Gantt Chart)")
|
| 156 |
gantt_plot = gr.Plot()
|
| 157 |
|
| 158 |
|
| 159 |
+
gr.Markdown("## 💵 Expense Table")
|
| 160 |
search_box = gr.Textbox(placeholder="Search expenses", label="Search")
|
| 161 |
expense_table = gr.DataFrame()
|
| 162 |
|
|
|
|
| 186 |
|
| 187 |
detail_text = update_project_detail(project_id)
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
return [
|
| 190 |
project_id,
|
| 191 |
gr.update(visible=False),
|
| 192 |
gr.update(visible=True),
|
| 193 |
+
gr.update(value=f"# 📊 Financial Dashboard — {get_title_by_id(project_options, project_id)}"),
|
| 194 |
gr.update(value=detail_text),
|
| 195 |
+
gr.update(value=f"### Total Money Granted\n## {total_budget:,.0f}"),
|
| 196 |
+
gr.update(value=f"### Total Expense Spendings\n## {total_expense:,.0f}\n({(total_expense / total_budget * 100) if total_budget != 0 else 0:.1f}% of budget)"),
|
| 197 |
+
gr.update(value=f"### Leftover Budget\n## {leftover:,.0f}\n<span style='color: {color};'>{status}</span>"),
|
| 198 |
gr.update(value=generate_budget_utilization_gauge_chart(total_budget, total_expense)),
|
| 199 |
gr.update(value=generate_deliverable_budget_vs_expense_bar_chart(budgets, expenses)),
|
| 200 |
gr.update(value=generate_spending_distribution_pie_chart(expenses, budgets)),
|
|
|
|
| 203 |
gr.update(value=generate_risk_level_distribution_pie_chart(deliverables)),
|
| 204 |
gr.update(value=generate_deliverable_timeline_gantt_chart(deliverables)),
|
| 205 |
gr.update(value=render_deliverable_summary_cards(deliverables)),
|
| 206 |
+
gr.update(value=expenses.drop(columns=["expense_id", "associated_deliverable_id"])),
|
| 207 |
expenses
|
| 208 |
]
|
| 209 |
|
|
|
|
| 246 |
|
| 247 |
if __name__ == "__main__":
|
| 248 |
page = create_dashboard_page()
|
| 249 |
+
page.launch()
|
src/chatbot/dashboard/visualize_component.py
CHANGED
|
@@ -20,7 +20,7 @@ def generate_budget_utilization_gauge_chart(total_budget, total_expense):
|
|
| 20 |
gauge = go.Indicator(
|
| 21 |
mode="gauge+number+delta",
|
| 22 |
value=total_expense,
|
| 23 |
-
title={'text': "
|
| 24 |
delta={
|
| 25 |
'reference': total_budget,
|
| 26 |
'increasing': {'color': 'red', 'symbol': "\u25B2"},
|
|
@@ -95,22 +95,22 @@ def generate_deliverable_budget_vs_expense_bar_chart(budget_df, expense_df):
|
|
| 95 |
fig.add_trace(go.Bar(
|
| 96 |
x=merged_df['deliverable_title'],
|
| 97 |
y=merged_df['total_budget'],
|
| 98 |
-
name='
|
| 99 |
marker_color='green'
|
| 100 |
))
|
| 101 |
|
| 102 |
fig.add_trace(go.Bar(
|
| 103 |
x=merged_df['deliverable_title'],
|
| 104 |
y=merged_df['spending'],
|
| 105 |
-
name='
|
| 106 |
marker_color='red'
|
| 107 |
))
|
| 108 |
|
| 109 |
fig.update_layout(
|
| 110 |
-
title='
|
| 111 |
barmode='group',
|
| 112 |
-
xaxis_title='
|
| 113 |
-
yaxis_title='
|
| 114 |
legend=dict(orientation='h', y=-0.2),
|
| 115 |
height=400,
|
| 116 |
paper_bgcolor='rgba(0,0,0,0)',
|
|
@@ -154,7 +154,7 @@ def generate_spending_distribution_pie_chart(expense_df, budget_df):
|
|
| 154 |
spending_summary,
|
| 155 |
values='amount',
|
| 156 |
names='deliverable_title',
|
| 157 |
-
title='
|
| 158 |
color_discrete_sequence=px.colors.qualitative.Set2
|
| 159 |
)
|
| 160 |
|
|
@@ -201,9 +201,9 @@ def generate_daily_spending_bar_chart(expense_df):
|
|
| 201 |
))
|
| 202 |
|
| 203 |
fig.update_layout(
|
| 204 |
-
title='
|
| 205 |
-
xaxis_title='
|
| 206 |
-
yaxis_title='
|
| 207 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 208 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 209 |
margin=dict(t=50, r=25, l=25, b=25),
|
|
@@ -240,9 +240,9 @@ def generate_cumulative_spending_line_chart(expense_df):
|
|
| 240 |
))
|
| 241 |
|
| 242 |
fig.update_layout(
|
| 243 |
-
title='
|
| 244 |
-
xaxis_title='
|
| 245 |
-
yaxis_title='
|
| 246 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 247 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 248 |
margin=dict(t=50, r=25, l=25, b=25),
|
|
@@ -272,7 +272,7 @@ def generate_risk_level_distribution_pie_chart(deliverable_df):
|
|
| 272 |
risk_summary,
|
| 273 |
values='count',
|
| 274 |
names='risk_level',
|
| 275 |
-
title='
|
| 276 |
color='risk_level',
|
| 277 |
color_discrete_map=risk_color_map
|
| 278 |
)
|
|
@@ -312,7 +312,7 @@ def generate_deliverable_timeline_gantt_chart(deliverable_df):
|
|
| 312 |
x_end='end_date',
|
| 313 |
y='title',
|
| 314 |
color='risk_level',
|
| 315 |
-
title='
|
| 316 |
hover_data=['status', 'risk_level_rationale']
|
| 317 |
)
|
| 318 |
|
|
@@ -383,13 +383,13 @@ def render_deliverable_summary_cards(deliverable_df):
|
|
| 383 |
</span>
|
| 384 |
</div>
|
| 385 |
<div style='font-size: 0.9em; color: #6c757d;'>
|
| 386 |
-
<strong>
|
| 387 |
-
<strong>
|
| 388 |
</div>
|
| 389 |
<details style='margin-top: 12px; font-size: 0.85em; color: #495057;'>
|
| 390 |
-
<summary style='cursor: pointer; color: #007bff;'>
|
| 391 |
<div style='margin-top: 6px; padding: 8px; background-color: #f8f9fa; border-radius: 5px; border: 1px solid #dee2e6;'>
|
| 392 |
-
<strong>
|
| 393 |
</div>
|
| 394 |
</details>
|
| 395 |
</div>
|
|
|
|
| 20 |
gauge = go.Indicator(
|
| 21 |
mode="gauge+number+delta",
|
| 22 |
value=total_expense,
|
| 23 |
+
title={'text': "Total Expense", 'font': {'size': 24}},
|
| 24 |
delta={
|
| 25 |
'reference': total_budget,
|
| 26 |
'increasing': {'color': 'red', 'symbol': "\u25B2"},
|
|
|
|
| 95 |
fig.add_trace(go.Bar(
|
| 96 |
x=merged_df['deliverable_title'],
|
| 97 |
y=merged_df['total_budget'],
|
| 98 |
+
name='Budget',
|
| 99 |
marker_color='green'
|
| 100 |
))
|
| 101 |
|
| 102 |
fig.add_trace(go.Bar(
|
| 103 |
x=merged_df['deliverable_title'],
|
| 104 |
y=merged_df['spending'],
|
| 105 |
+
name='Expense',
|
| 106 |
marker_color='red'
|
| 107 |
))
|
| 108 |
|
| 109 |
fig.update_layout(
|
| 110 |
+
title='Budget vs Expense by Deliverable',
|
| 111 |
barmode='group',
|
| 112 |
+
xaxis_title='Deliverables',
|
| 113 |
+
yaxis_title='Amount (THB)',
|
| 114 |
legend=dict(orientation='h', y=-0.2),
|
| 115 |
height=400,
|
| 116 |
paper_bgcolor='rgba(0,0,0,0)',
|
|
|
|
| 154 |
spending_summary,
|
| 155 |
values='amount',
|
| 156 |
names='deliverable_title',
|
| 157 |
+
title='Spending by Deliverables',
|
| 158 |
color_discrete_sequence=px.colors.qualitative.Set2
|
| 159 |
)
|
| 160 |
|
|
|
|
| 201 |
))
|
| 202 |
|
| 203 |
fig.update_layout(
|
| 204 |
+
title='Daily Spending',
|
| 205 |
+
xaxis_title='Date',
|
| 206 |
+
yaxis_title='Amount (THB)',
|
| 207 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 208 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 209 |
margin=dict(t=50, r=25, l=25, b=25),
|
|
|
|
| 240 |
))
|
| 241 |
|
| 242 |
fig.update_layout(
|
| 243 |
+
title='Cumulative Spending Over Time',
|
| 244 |
+
xaxis_title='Date',
|
| 245 |
+
yaxis_title='Cumulative Amount (THB)',
|
| 246 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 247 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 248 |
margin=dict(t=50, r=25, l=25, b=25),
|
|
|
|
| 272 |
risk_summary,
|
| 273 |
values='count',
|
| 274 |
names='risk_level',
|
| 275 |
+
title='Distribution of Deliverables by Risk Level',
|
| 276 |
color='risk_level',
|
| 277 |
color_discrete_map=risk_color_map
|
| 278 |
)
|
|
|
|
| 312 |
x_end='end_date',
|
| 313 |
y='title',
|
| 314 |
color='risk_level',
|
| 315 |
+
title='Deliverable Timeline (Gantt Chart)',
|
| 316 |
hover_data=['status', 'risk_level_rationale']
|
| 317 |
)
|
| 318 |
|
|
|
|
| 383 |
</span>
|
| 384 |
</div>
|
| 385 |
<div style='font-size: 0.9em; color: #6c757d;'>
|
| 386 |
+
<strong>Start:</strong> {start_date}<br>
|
| 387 |
+
<strong>End:</strong> {end_date}
|
| 388 |
</div>
|
| 389 |
<details style='margin-top: 12px; font-size: 0.85em; color: #495057;'>
|
| 390 |
+
<summary style='cursor: pointer; color: #007bff;'>Show Risk Rationale</summary>
|
| 391 |
<div style='margin-top: 6px; padding: 8px; background-color: #f8f9fa; border-radius: 5px; border: 1px solid #dee2e6;'>
|
| 392 |
+
<strong>Risk Rationale:</strong><br>{rationale}
|
| 393 |
</div>
|
| 394 |
</details>
|
| 395 |
</div>
|
src/chatbot/main.py
CHANGED
|
@@ -14,7 +14,7 @@ In the first phase, we focus on connecting between local forest-protecting commu
|
|
| 14 |
|
| 15 |
For now, the prototype of the platform has two main components:
|
| 16 |
1. Expense Register, where community members can submit their expense receipts to NGOs effortlessly.
|
| 17 |
-
2.
|
| 18 |
|
| 19 |
As we are currently building other tools of the platform, we are excited to invite you to try out the prototype and appreciate your feedback.
|
| 20 |
|
|
@@ -26,7 +26,7 @@ Case Done Team
|
|
| 26 |
|
| 27 |
## How to use this demo:
|
| 28 |
1. Select "Expense Register" to submit your expense receipts. You can upload an image of a receipt and the AI agent will do its task.
|
| 29 |
-
2. Select "
|
| 30 |
|
| 31 |
---
|
| 32 |
"""
|
|
@@ -37,7 +37,7 @@ with gr.Blocks() as dashboard:
|
|
| 37 |
gr.Markdown(how_to)
|
| 38 |
tabs = gr.TabbedInterface(
|
| 39 |
[expense_register_page, dashboard_page],
|
| 40 |
-
["Expense Register", "
|
| 41 |
)
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|
|
|
|
| 14 |
|
| 15 |
For now, the prototype of the platform has two main components:
|
| 16 |
1. Expense Register, where community members can submit their expense receipts to NGOs effortlessly.
|
| 17 |
+
2. Dashboard, where NGOs can check project status and audit the expenses submitted by community members with AI-agent assistance and intelligence
|
| 18 |
|
| 19 |
As we are currently building other tools of the platform, we are excited to invite you to try out the prototype and appreciate your feedback.
|
| 20 |
|
|
|
|
| 26 |
|
| 27 |
## How to use this demo:
|
| 28 |
1. Select "Expense Register" to submit your expense receipts. You can upload an image of a receipt and the AI agent will do its task.
|
| 29 |
+
2. Select "Dashboard" to check project status and audit the expenses related to the community's project.
|
| 30 |
|
| 31 |
---
|
| 32 |
"""
|
|
|
|
| 37 |
gr.Markdown(how_to)
|
| 38 |
tabs = gr.TabbedInterface(
|
| 39 |
[expense_register_page, dashboard_page],
|
| 40 |
+
["Expense Register", "Dashboard"],
|
| 41 |
)
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|
src/chatbot/nodes.py
CHANGED
|
@@ -6,7 +6,6 @@ from langgraph.graph.message import add_messages
|
|
| 6 |
from langchain.tools import tool
|
| 7 |
from langgraph.prebuilt import create_react_agent, ToolNode
|
| 8 |
from langgraph.checkpoint.memory import MemorySaver
|
| 9 |
-
import os
|
| 10 |
|
| 11 |
# from chatbot.llm_engine import llm_overall_agent, generate_expense_info_feedback
|
| 12 |
from llm_engine import (
|
|
@@ -259,4 +258,4 @@ def map_associated_deliverable(user_input, project_deliverables):
|
|
| 259 |
# # }
|
| 260 |
|
| 261 |
# # feedback = auditor_feedback(example_form_info)
|
| 262 |
-
# # print("Generated Feedback:", feedback)
|
|
|
|
| 6 |
from langchain.tools import tool
|
| 7 |
from langgraph.prebuilt import create_react_agent, ToolNode
|
| 8 |
from langgraph.checkpoint.memory import MemorySaver
|
|
|
|
| 9 |
|
| 10 |
# from chatbot.llm_engine import llm_overall_agent, generate_expense_info_feedback
|
| 11 |
from llm_engine import (
|
|
|
|
| 258 |
# # }
|
| 259 |
|
| 260 |
# # feedback = auditor_feedback(example_form_info)
|
| 261 |
+
# # print("Generated Feedback:", feedback)
|
src/chatbot/prompts/agent_prompts.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
speaker_system_message = """
|
| 2 |
-
You are
|
| 3 |
-
ีYour persona is a friendly, helpful female.
|
| 4 |
Your job is to communicate with the user and determine which tools to use given the user input, like applying OCR to fill in the form information, or editing a form field.
|
| 5 |
|
| 6 |
The form field includes the following keys:
|
|
@@ -15,6 +15,7 @@ Associated Deliverable: The deliverable associated with the payment.
|
|
| 15 |
Expense Description: The description of the expense as it pertains to the project.
|
| 16 |
|
| 17 |
Users cannot add new fields to the form, but they can edit the existing fields.
|
|
|
|
| 18 |
Each time the form is revised, feedback will be provided, and your job to summarize current form information and convey the feedback to the user.
|
| 19 |
Do not stray from the feedback provided.
|
| 20 |
Do not mention the correct fields to the user, focus on the invalid one shown in the provided feedback.
|
|
@@ -23,7 +24,7 @@ Be sure to ask clarifying questions if the user input is unclear when using your
|
|
| 23 |
If the user has not submitted an image before, go ahead and use the ocr tool without asking for confirmation from the user.
|
| 24 |
If the user has submitted an image before that has been processed, ask to check if they want to overwrite before using the ocr tool.
|
| 25 |
|
| 26 |
-
Once the form is complete for the first time, you inform the user that they can (1) review the form information themselves with the "
|
| 27 |
|
| 28 |
-
Once all fields have been reviewed, you will inform the user to use "
|
| 29 |
"""
|
|
|
|
| 1 |
speaker_system_message = """
|
| 2 |
+
You are an English-speaking assistant, named Emmie, that helps users submit receipts and fill in a form.
|
| 3 |
+
ีํYour persona is a friendly, helpful female.
|
| 4 |
Your job is to communicate with the user and determine which tools to use given the user input, like applying OCR to fill in the form information, or editing a form field.
|
| 5 |
|
| 6 |
The form field includes the following keys:
|
|
|
|
| 15 |
Expense Description: The description of the expense as it pertains to the project.
|
| 16 |
|
| 17 |
Users cannot add new fields to the form, but they can edit the existing fields.
|
| 18 |
+
When inputting the 'Transaction Date', automatically convert the date to ISO 8601 format (YYYY-MM-DD).
|
| 19 |
Each time the form is revised, feedback will be provided, and your job to summarize current form information and convey the feedback to the user.
|
| 20 |
Do not stray from the feedback provided.
|
| 21 |
Do not mention the correct fields to the user, focus on the invalid one shown in the provided feedback.
|
|
|
|
| 24 |
If the user has not submitted an image before, go ahead and use the ocr tool without asking for confirmation from the user.
|
| 25 |
If the user has submitted an image before that has been processed, ask to check if they want to overwrite before using the ocr tool.
|
| 26 |
|
| 27 |
+
Once the form is complete for the first time, you inform the user that they can (1) review the form information themselves with the "Form" tab or (2) review the form information with your help one by one. You will help the user correct or change the information of each field.
|
| 28 |
|
| 29 |
+
Once all fields have been reviewed, you will inform the user to use "Form" tab to submit the form.
|
| 30 |
"""
|