georgeek commited on
Commit
a6d744f
·
1 Parent(s): 2123b97
One_model.py CHANGED
@@ -88,7 +88,7 @@ def parseBill(data):
88
  return {
89
  "Data factura": billDate,
90
  "Serie numar factura": billNo,
91
- "De plata": amountDue,
92
  "Costuri suplimentare": extraCharge,
93
  "Total plata factura": totalBillCosts,
94
  "Costuri utilizatori": subscriberCosts,
@@ -101,7 +101,7 @@ def check_related_keys(question, user_id):
101
  categories = set()
102
  for bill in user_data.get("bills", []):
103
  categories.update(bill.get("Entities", []))
104
- st.write(f"Entities: {categories}")
105
  return [category for category in categories if any(word.lower() in question.lower() for word in category.split())]
106
 
107
  def process_query(query, user_id, model_name):
@@ -112,16 +112,16 @@ def process_query(query, user_id, model_name):
112
 
113
  if related_keys_str != "N/A":
114
  context = (
115
- f"Citeste informatiile despre costurile in lei facturate din json: {bill_info} "
116
- f"si raspunde la intrebarea: '{query}' dar numai cu info legate de: {related_keys_str}"
117
  )
118
  else:
119
  context = (
120
- f"Citeste informatiile despre costrurile in lei facturate din json: {bill_info} "
121
- f"si raspunde la intrebarea: '{query}' dar numai cu info legate de factura"
122
  )
123
 
124
- max_input_length = 5550
125
  #st.write(f"Context:\n{context}")
126
  st.write(f"Context size: {len(context)} characters")
127
 
@@ -205,7 +205,7 @@ def main():
205
  st.write({
206
  "Data factura": bill.get("Data factura"),
207
  "Serie numar factura": bill.get("Serie numar factura"),
208
- "De plata": bill.get("De plata"),
209
  "Costuri suplimentare": bill.get("Costuri suplimentare")
210
  })
211
  if not st.session_state.user_data:
 
88
  return {
89
  "Data factura": billDate,
90
  "Serie numar factura": billNo,
91
+ "Total de plata": amountDue,
92
  "Costuri suplimentare": extraCharge,
93
  "Total plata factura": totalBillCosts,
94
  "Costuri utilizatori": subscriberCosts,
 
101
  categories = set()
102
  for bill in user_data.get("bills", []):
103
  categories.update(bill.get("Entities", []))
104
+ #st.write(f"Entities: {categories}")
105
  return [category for category in categories if any(word.lower() in question.lower() for word in category.split())]
106
 
107
  def process_query(query, user_id, model_name):
 
112
 
113
  if related_keys_str != "N/A":
114
  context = (
115
+ f"Citeste informatiile despre costrurile in lei facturate din json: {bill_info}"
116
+ f"si raspunde la intrebarea sau afirmatia: '{query}' dar mai ales cu info legate de: {related_keys_str}. Pentru orice alt subiect raspunde ca nu poti oferi decat informatii despre facturi."
117
  )
118
  else:
119
  context = (
120
+ f"Citeste informatiile despre costrurile in lei facturate din json: {bill_info}"
121
+ f"si raspunde la intrebarea sau afirmatia: '{query}' mai ales cu info din factura. Pentru orice alt subiect raspunde ca nu poti oferi decat informatii despre facturi."
122
  )
123
 
124
+ max_input_length = 7550
125
  #st.write(f"Context:\n{context}")
126
  st.write(f"Context size: {len(context)} characters")
127
 
 
205
  st.write({
206
  "Data factura": bill.get("Data factura"),
207
  "Serie numar factura": bill.get("Serie numar factura"),
208
+ "Total de plata": bill.get("Total de plata"),
209
  "Costuri suplimentare": bill.get("Costuri suplimentare")
210
  })
211
  if not st.session_state.user_data:
data/user_data/user_data_0724077190.json CHANGED
@@ -1 +1,266 @@
1
- {"bills": [{"Data factura": "2025-01-06", "Serie numar factura": "VDF685952701", "De plata": 5550.46, "Costuri suplimentare": 5445.53, "Total plata factura": [{"categorie": "Total factura curenta", "amount": 104.93}, {"categorie": "TVA 19%", "amount": 16.75}, {"categorie": "Total rate terminal", "amount": 5445.53}, {"categorie": "Abonamente si extraoptiuni", "amount": 91.17}, {"categorie": "Reduceri", "amount": -2.99}, {"categorie": "Rest plata", "amount": -5073.74}, {"categorie": "Sold precedent", "amount": -5073.74}, {"categorie": "Total de plata", "amount": 476.72}], "Costuri utilizatori": [{"Numar telefon": "724015962", "Categorie cost": "Abonamente si extraoptiuni", "Cost": "Red 11", "Valoare": 34.08}, {"Numar telefon": "724015962", "Categorie cost": "Abonamente si extraoptiuni", "Cost": "Reducere promo", "Valoare": -8.52}, {"Numar telefon": "724015962", "Categorie cost": "Abonamente si extraoptiuni", "Cost": "Secure Net", "Valoare": 2.99}, {"Numar telefon": "724015962", "Categorie cost": "Abonamente si extraoptiuni", "Cost": "Reducere promotionala 12 luni", "Valoare": -4.26}, {"Numar telefon": "724015962", "Categorie cost": "Rate terminal", "Cost": "Promotie Vodafone Smartphone cu plata in rate 12/36", "Valoare": 70.99}, {"Numar telefon": "373920691", "Categorie cost": "Abonamente si extraoptiuni", "Cost": "Abonament Vodafone WiFi Instant Nelimitat+", "Valoare": 29.82}, {"Numar telefon": "724077190", "Categorie cost": "Reduceri", "Cost": "Reducere Secure Net", "Valoare": -2.99}, {"Numar telefon": "724077190", "Categorie cost": "Abonamente si extraoptiuni", "Cost": "RED Start", "Valoare": 38.33}, {"Numar telefon": "724077190", "Categorie cost": "Abonamente si extraoptiuni", "Cost": "Secure Net", "Valoare": 2.99}, {"Numar telefon": "724077190", "Categorie cost": "Abonamente si extraoptiuni", "Cost": "Reducere promotionala 12 luni", "Valoare": -4.26}, {"Numar telefon": "724077190", "Categorie cost": "Rate terminal", "Cost": "Valoare rate ramase pana la expirare contract", "Valoare": 5374.54}], "Entities": ["Rate terminal", "Reducere promotionala 12 luni", "Total sume datorate rate terminal", "Total de plata", "Secure Net", "Promotie Vodafone Smartphone cu plata in rate 12/36", "Red 11", "Reducere Secure Net", "Rest plata", "TVA 19%", "Reduceri", "Abonamente si extraoptiuni", "RED Start", "Reducere promo", "Total rate terminal", "Sold precedent", "Valoare rate ramase pana la expirare contract", "Abonament Vodafone WiFi Instant Nelimitat+", "Total factura curenta"], "Costuri": ["RED Start", "Secure Net", "Promotie Vodafone Smartphone cu plata in rate 12/36", "Red 11", "Valoare rate ramase pana la expirare contract", "Reducere promotionala 12 luni", "Reducere Secure Net", "Abonament Vodafone WiFi Instant Nelimitat+", "Reducere promo"]}]}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bills": [
3
+ {
4
+ "Data factura": "2025-01-06",
5
+ "Serie numar factura": "VDF685952701",
6
+ "Total de plata": 5550.46,
7
+ "Costuri suplimentare": 5445.53,
8
+ "Total plata factura": [
9
+ {
10
+ "categorie": "Total factura curenta",
11
+ "amount": 104.93
12
+ },
13
+ {
14
+ "categorie": "TVA 19%",
15
+ "amount": 16.75
16
+ },
17
+ {
18
+ "categorie": "Total rate terminal",
19
+ "amount": 5445.53
20
+ },
21
+ {
22
+ "categorie": "Abonamente si extraoptiuni",
23
+ "amount": 91.17
24
+ },
25
+ {
26
+ "categorie": "Reduceri",
27
+ "amount": -2.99
28
+ },
29
+ {
30
+ "categorie": "Rest plata",
31
+ "amount": -5073.74
32
+ },
33
+ {
34
+ "categorie": "Sold precedent",
35
+ "amount": -5073.74
36
+ },
37
+ {
38
+ "categorie": "Total de plata",
39
+ "amount": 476.72
40
+ }
41
+ ],
42
+ "Costuri utilizatori": [
43
+ {
44
+ "Numar telefon": "724015962",
45
+ "Categorie cost": "Abonamente si extraoptiuni",
46
+ "Cost": "Red 11",
47
+ "Valoare": 34.08
48
+ },
49
+ {
50
+ "Numar telefon": "724015962",
51
+ "Categorie cost": "Abonamente si extraoptiuni",
52
+ "Cost": "Reducere promo",
53
+ "Valoare": -8.52
54
+ },
55
+ {
56
+ "Numar telefon": "724015962",
57
+ "Categorie cost": "Abonamente si extraoptiuni",
58
+ "Cost": "Secure Net",
59
+ "Valoare": 2.99
60
+ },
61
+ {
62
+ "Numar telefon": "724015962",
63
+ "Categorie cost": "Abonamente si extraoptiuni",
64
+ "Cost": "Reducere promotionala 12 luni",
65
+ "Valoare": -4.26
66
+ },
67
+ {
68
+ "Numar telefon": "724015962",
69
+ "Categorie cost": "Rate terminal",
70
+ "Cost": "Promotie Vodafone Smartphone cu plata in rate 12/36",
71
+ "Valoare": 70.99
72
+ },
73
+ {
74
+ "Numar telefon": "373920691",
75
+ "Categorie cost": "Abonamente si extraoptiuni",
76
+ "Cost": "Abonament Vodafone WiFi Instant Nelimitat+",
77
+ "Valoare": 29.82
78
+ },
79
+ {
80
+ "Numar telefon": "724077190",
81
+ "Categorie cost": "Reduceri",
82
+ "Cost": "Reducere Secure Net",
83
+ "Valoare": -2.99
84
+ },
85
+ {
86
+ "Numar telefon": "724077190",
87
+ "Categorie cost": "Abonamente si extraoptiuni",
88
+ "Cost": "RED Start",
89
+ "Valoare": 38.33
90
+ },
91
+ {
92
+ "Numar telefon": "724077190",
93
+ "Categorie cost": "Abonamente si extraoptiuni",
94
+ "Cost": "Secure Net",
95
+ "Valoare": 2.99
96
+ },
97
+ {
98
+ "Numar telefon": "724077190",
99
+ "Categorie cost": "Abonamente si extraoptiuni",
100
+ "Cost": "Reducere promotionala 12 luni",
101
+ "Valoare": -4.26
102
+ },
103
+ {
104
+ "Numar telefon": "724077190",
105
+ "Categorie cost": "Rate terminal",
106
+ "Cost": "Valoare rate ramase pana la expirare contract",
107
+ "Valoare": 5374.54
108
+ }
109
+ ],
110
+ "Entities": [
111
+ "Rate terminal",
112
+ "Reducere promotionala 12 luni",
113
+ "Total sume datorate rate terminal",
114
+ "Total de plata",
115
+ "Secure Net",
116
+ "Promotie Vodafone Smartphone cu plata in rate 12/36",
117
+ "Red 11",
118
+ "Reducere Secure Net",
119
+ "Rest plata",
120
+ "TVA 19%",
121
+ "Reduceri",
122
+ "Abonamente si extraoptiuni",
123
+ "RED Start",
124
+ "Reducere promo",
125
+ "Total rate terminal",
126
+ "Sold precedent",
127
+ "Valoare rate ramase pana la expirare contract",
128
+ "Abonament Vodafone WiFi Instant Nelimitat+",
129
+ "Total factura curenta"
130
+ ],
131
+ "Costuri": [
132
+ "RED Start",
133
+ "Secure Net",
134
+ "Promotie Vodafone Smartphone cu plata in rate 12/36",
135
+ "Red 11",
136
+ "Valoare rate ramase pana la expirare contract",
137
+ "Reducere promotionala 12 luni",
138
+ "Reducere Secure Net",
139
+ "Abonament Vodafone WiFi Instant Nelimitat+",
140
+ "Reducere promo"
141
+ ]
142
+ },
143
+ {
144
+ "Data factura": "2024-12-06",
145
+ "Serie numar factura": "VDF685952700",
146
+ "Total de plata": 550.21,
147
+ "Costuri suplimentare": 54.53,
148
+ "Total plata factura": [
149
+ {
150
+ "categorie": "Total factura curenta",
151
+ "amount": 5104.93
152
+ },
153
+ {
154
+ "categorie": "TVA 19%",
155
+ "amount": 716.75
156
+ },
157
+ {
158
+ "categorie": "Total rate terminal",
159
+ "amount": 5445.53
160
+ },
161
+ {
162
+ "categorie": "Abonamente si extraoptiuni",
163
+ "amount": 91.17
164
+ },
165
+ {
166
+ "categorie": "Total de plata",
167
+ "amount": 476.72
168
+ }
169
+ ],
170
+ "Costuri utilizatori": [
171
+ {
172
+ "Numar telefon": "724015962",
173
+ "Categorie cost": "Abonamente si extraoptiuni",
174
+ "Cost": "Red 11",
175
+ "Valoare": 34.08
176
+ },
177
+ {
178
+ "Numar telefon": "724015962",
179
+ "Categorie cost": "Abonamente si extraoptiuni",
180
+ "Cost": "Reducere promo",
181
+ "Valoare": -8.52
182
+ },
183
+ {
184
+ "Numar telefon": "724015962",
185
+ "Categorie cost": "Abonamente si extraoptiuni",
186
+ "Cost": "Secure Net",
187
+ "Valoare": 2.99
188
+ },
189
+ {
190
+ "Numar telefon": "724015962",
191
+ "Categorie cost": "Abonamente si extraoptiuni",
192
+ "Cost": "Reducere promotionala 12 luni",
193
+ "Valoare": -4.26
194
+ },
195
+ {
196
+ "Numar telefon": "724015962",
197
+ "Categorie cost": "Rate terminal",
198
+ "Cost": "Promotie Vodafone Smartphone cu plata in rate 12/36",
199
+ "Valoare": 70.99
200
+ },
201
+ {
202
+ "Numar telefon": "373920691",
203
+ "Categorie cost": "Abonamente si extraoptiuni",
204
+ "Cost": "Abonament Vodafone WiFi Instant Nelimitat+",
205
+ "Valoare": 29.82
206
+ },
207
+ {
208
+ "Numar telefon": "724077190",
209
+ "Categorie cost": "Reduceri",
210
+ "Cost": "Reducere Secure Net",
211
+ "Valoare": -2.99
212
+ },
213
+ {
214
+ "Numar telefon": "724077190",
215
+ "Categorie cost": "Abonamente si extraoptiuni",
216
+ "Cost": "RED Start",
217
+ "Valoare": 38.33
218
+ },
219
+ {
220
+ "Numar telefon": "724077190",
221
+ "Categorie cost": "Abonamente si extraoptiuni",
222
+ "Cost": "Secure Net",
223
+ "Valoare": 2.99
224
+ },
225
+ {
226
+ "Numar telefon": "724077190",
227
+ "Categorie cost": "Abonamente si extraoptiuni",
228
+ "Cost": "Reducere promotionala 12 luni",
229
+ "Valoare": -4.26
230
+ }
231
+ ],
232
+ "Entities": [
233
+ "Rate terminal",
234
+ "Reducere promotionala 12 luni",
235
+ "Total sume datorate rate terminal",
236
+ "Total de plata",
237
+ "Secure Net",
238
+ "Promotie Vodafone Smartphone cu plata in rate 12/36",
239
+ "Red 11",
240
+ "Reducere Secure Net",
241
+ "Rest plata",
242
+ "TVA 19%",
243
+ "Reduceri",
244
+ "Abonamente si extraoptiuni",
245
+ "RED Start",
246
+ "Reducere promo",
247
+ "Total rate terminal",
248
+ "Sold precedent",
249
+ "Valoare rate ramase pana la expirare contract",
250
+ "Abonament Vodafone WiFi Instant Nelimitat+",
251
+ "Total factura curenta"
252
+ ],
253
+ "Costuri": [
254
+ "RED Start",
255
+ "Secure Net",
256
+ "Promotie Vodafone Smartphone cu plata in rate 12/36",
257
+ "Red 11",
258
+ "Valoare rate ramase pana la expirare contract",
259
+ "Reducere promotionala 12 luni",
260
+ "Reducere Secure Net",
261
+ "Abonament Vodafone WiFi Instant Nelimitat+",
262
+ "Reducere promo"
263
+ ]
264
+ }
265
+ ]
266
+ }
pages/Two_models.py CHANGED
@@ -84,8 +84,8 @@ def check_related_keys(question, user_id):
84
  user_data = load_user_data(user_id)
85
  categories = set()
86
  for bill in user_data.get("bills", []):
87
- categories.update(bill.get("Categorii", []))
88
- st.write(f"Entities: {categories}")
89
  return [category for category in categories if any(word.lower() in question.lower() for word in category.split())]
90
 
91
  def process_query(query, user_id, model_name):
@@ -96,16 +96,16 @@ def process_query(query, user_id, model_name):
96
 
97
  if related_keys_str != "N/A":
98
  context = (
99
- f"Citeste informatiile despre costurile in lei facturate din json: {bill_info} "
100
- f"si raspunde la intrebarea: '{query}' dar numai cu info legate de: {related_keys_str}"
101
  )
102
  else:
103
  context = (
104
- f"Citeste informatiile despre costrurile in lei facturate din json: {bill_info} "
105
- f"si raspunde la intrebarea: '{query}' dar numai cu info legate de factura"
106
  )
107
 
108
- max_input_length = 5550
109
  #st.write(f"Context:\n{context}")
110
  st.write(f"Context size: {len(context)} characters")
111
 
@@ -151,7 +151,7 @@ def main():
151
  st.image("https://miro.medium.com/v2/resize:fit:100/format:webp/1*NfE0G4nEj4xX7Z_8dSx83g.png")
152
 
153
  # Create a sidebar menu to choose between models
154
- model_name = st.sidebar.selectbox("Choose OpenAI Model", ["gpt-4o-mini", "gpt-4o"])
155
  if "user_id" not in st.session_state:
156
  st.session_state.user_id = None
157
 
@@ -189,7 +189,7 @@ def main():
189
  st.write({
190
  "Data factura": bill.get("Data factura"),
191
  "Serie numar factura": bill.get("Serie numar factura"),
192
- "De plata": bill.get("De plata"),
193
  "Costuri suplimentare": bill.get("Costuri suplimentare")
194
  })
195
  if not st.session_state.user_data:
 
84
  user_data = load_user_data(user_id)
85
  categories = set()
86
  for bill in user_data.get("bills", []):
87
+ categories.update(bill.get("Entities", []))
88
+ #st.write(f"Entities: {categories}")
89
  return [category for category in categories if any(word.lower() in question.lower() for word in category.split())]
90
 
91
  def process_query(query, user_id, model_name):
 
96
 
97
  if related_keys_str != "N/A":
98
  context = (
99
+ f"Citeste informatiile despre costurile in lei facturate din json: {bill_info}"
100
+ f"si raspunde la intrebarea sau afirmatia: '{query}' dar mai ales cu info legate de: {related_keys_str}. Pentru orice alt subiect raspunde ca nu poti oferi decat informatii despre facturi."
101
  )
102
  else:
103
  context = (
104
+ f"Citeste informatiile despre costurile in lei facturate din json: {bill_info}"
105
+ f"si raspunde la intrebarea sau afirmatia: '{query}' mai ales cu info din factura. Pentru orice alt subiect raspunde ca nu poti oferi decat informatii despre facturi."
106
  )
107
 
108
+ max_input_length = 7550
109
  #st.write(f"Context:\n{context}")
110
  st.write(f"Context size: {len(context)} characters")
111
 
 
151
  st.image("https://miro.medium.com/v2/resize:fit:100/format:webp/1*NfE0G4nEj4xX7Z_8dSx83g.png")
152
 
153
  # Create a sidebar menu to choose between models
154
+ #model_name = st.sidebar.selectbox("Choose OpenAI Model", ["gpt-4o-mini", "gpt-4o"])
155
  if "user_id" not in st.session_state:
156
  st.session_state.user_id = None
157
 
 
189
  st.write({
190
  "Data factura": bill.get("Data factura"),
191
  "Serie numar factura": bill.get("Serie numar factura"),
192
+ "Total de plata": bill.get("Total de plata"),
193
  "Costuri suplimentare": bill.get("Costuri suplimentare")
194
  })
195
  if not st.session_state.user_data: