File size: 2,107 Bytes
3b5a8b1
c8891d8
3b5a8b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c16c548
 
dbfae32
c16c548
 
dbfae32
dd61286
 
 
 
 
 
 
e2bb6ed
c16c548
 
dbfae32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import streamlit as st
from langchain_pipeline import pipeline, model_names

st.title("Canarie AI Prototype")
st.subheader("Finding the canarie in the coal mine")

model_name = st.selectbox(
    "Model",
    model_names())

balance_type = st.selectbox(
    "Do you charge on available balance or ledger balance?",
    ["available balance", "ledger balance"]
)

apsn_transactions = st.selectbox(
    "Do you charge for APSN transactions?",
    ["yes", "no"]
)

max_fees_per_day = st.number_input(
    "How many overdraft fees per day can be charged?",
    min_value=0, max_value=10,
)

min_overdrawn_fee = st.number_input(
    "What is the minimum amount overdrawn to incur a fee?",
    min_value=0, max_value=500
)

min_transaction_overdraft = st.number_input(
    "What is the minimum transaction amount to trigger an overdraft?",
    min_value=0, max_value=500
)

uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
    diff = ""
    with st.spinner('Please wait ...'):
        try:
            diff = pipeline(
                uploaded_file,
                model_name,
                balance_type,
                apsn_transactions,
                max_fees_per_day,
                min_overdrawn_fee,
                min_transaction_overdraft
            )
        except Exception as e:
            st.exception(e)

    diff_lines = diff.split("\n")

    styled_diff = """
    <style>
    body {
        font-family: 'Times New Roman', serif;
        line-height: 1.5;
    }
    .diff {
        margin: 10px 0;
        padding: 5px;
    }
    .add {
        color: green;
    }
    .remove {
        color: red;
    }
    </style>
    <div>
    """
    for line in diff_lines:
        if line.startswith('+'):
            styled_diff += f'<div class="diff add">{line}</div>'
        elif line.startswith('-'):
            styled_diff += f'<div class="diff remove">{line}</div>'
        else:
            styled_diff += f'<div class="diff">{line}</div>'
    styled_diff += "</div>"

    st.markdown(styled_diff, unsafe_allow_html=True)

st.markdown("The key changes are:")