Spaces:
Sleeping
Sleeping
- Presentation.md +53 -0
- Prezentare.md +52 -0
- README.md +14 -13
- diag.md +39 -0
- diag.plantUML +17 -0
- logs/conversation_logs.json +36 -0
Presentation.md
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# LLM Bill Chat App
|
3 |
+
|
4 |
+
This project is a proof of concept for a chat application utilizing a Large Language Model (LLM) to assist users with their telecom billing inquiries. The application is built using Python and Streamlit, providing an interactive web interface for users to engage with.
|
5 |
+
|
6 |
+
## Features
|
7 |
+
|
8 |
+
- Maintain chat conversation context (history)
|
9 |
+
- Allow users to query their billing information
|
10 |
+
- Compare the last bills and provide insights
|
11 |
+
- Respond exclusively with the user's own billing information
|
12 |
+
- Augment the prompt instructions with user's text recognized entities - NER -> Dynamic prompting# Aplicația LLM Bill Chat
|
13 |
+
|
14 |
+
## Project Structure
|
15 |
+
|
16 |
+
hf-llm-bill-chat/
|
17 |
+
│
|
18 |
+
├── app.py
|
19 |
+
├── pages/
|
20 |
+
│ ├── One_model.py
|
21 |
+
│ ├── Two_models.py
|
22 |
+
│
|
23 |
+
├── data/
|
24 |
+
│ └── user_data/
|
25 |
+
│ └── user_data_724077190.json
|
26 |
+
└── logs/
|
27 |
+
└── conversation_logs.json
|
28 |
+
|
29 |
+
|
30 |
+
## Code Implementation - Main Script
|
31 |
+
|
32 |
+
- Initialize Streamlit app
|
33 |
+
- Load user data and display existing bills
|
34 |
+
- Handle file uploads for new bills
|
35 |
+
- Maintain chat conversation context
|
36 |
+
- Leverage user text entities recognition (NER) for dynamic prompting
|
37 |
+
- Call OpenAI models (GPT-4o and GPT-4o-mini) for responses
|
38 |
+
- Display responses in two parallel columns
|
39 |
+
- Log conversation details
|
40 |
+
|
41 |
+
## Future Improvements
|
42 |
+
|
43 |
+
- Enhance Natural Language Processing (NLP) capabilities for better entity recognition
|
44 |
+
- Implement user authentication for secure access to billing information
|
45 |
+
- Add support for more telecom providers and bill formats
|
46 |
+
- Improve the user interface for better user experience
|
47 |
+
- Integrate with payment gateways for bill payments
|
48 |
+
|
49 |
+
## Conclusion
|
50 |
+
|
51 |
+
- The LLM Bill Chat App demonstrates the potential of using Large Language Models for telecom billing assistance.
|
52 |
+
- The app provides a user-friendly interface for querying billing information and getting insights.
|
53 |
+
- Future improvements can enhance the app's capabilities and user experience.
|
Prezentare.md
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Aplicația LLM Bill Chat
|
2 |
+
|
3 |
+
Acest proiect este un proof of concept pentru o aplicație de chat care utilizează un Model de Limbaj Mare (LLM) pentru a asista utilizatorii cu întrebările lor legate de facturile telecom. Aplicația este construită folosind Python și Streamlit, oferind o interfață web interactivă pentru utilizatori.
|
4 |
+
|
5 |
+
## Funcționalități
|
6 |
+
|
7 |
+
- Menținerea contextului conversației de chat (istoric)
|
8 |
+
- Permite utilizatorilor să își interogheze informațiile de facturare
|
9 |
+
- Compararea ultimelor facturi și oferirea de informații
|
10 |
+
- Răspunde exclusiv cu informațiile de facturare ale utilizatorului
|
11 |
+
- Augmentează instrucțiunile promptului cu entitățile recunoscute din textul utilizatorului - NER -> Prompting dinamic.
|
12 |
+
- Salvează informațiile utilizatorului și istoricul conversațiilor
|
13 |
+
|
14 |
+
## Structura Proiectului
|
15 |
+
|
16 |
+
hf-llm-bill-chat/
|
17 |
+
│
|
18 |
+
├── app.py
|
19 |
+
├── pages/
|
20 |
+
│ ├── One_model.py
|
21 |
+
│ ├── Two_models.py
|
22 |
+
│
|
23 |
+
├── data/
|
24 |
+
│ └── user_data/
|
25 |
+
│ └── user_data_724077190.json
|
26 |
+
└── logs/
|
27 |
+
└── conversation_logs.json
|
28 |
+
|
29 |
+
## Implementarea Codului - Script Principal
|
30 |
+
|
31 |
+
- Inițializează aplicația Streamlit
|
32 |
+
- Încarcă datele utilizatorului și afișează facturile existente
|
33 |
+
- Gestionează încărcările de fișiere pentru facturile noi
|
34 |
+
- Menține contextul conversației de chat
|
35 |
+
- Utilizează recunoașterea entităților din textul utilizatorului (NER) pentru prompting dinamic
|
36 |
+
- Apelează modelele OpenAI (GPT-4o și GPT-4o-mini) pentru răspunsuri
|
37 |
+
- Afișează răspunsurile în două coloane paralele
|
38 |
+
- Înregistrează detaliile conversației
|
39 |
+
|
40 |
+
## Îmbunătățiri Viitoare
|
41 |
+
|
42 |
+
- Îmbunătățirea capacităților de Procesare a Limbajului Natural (NLP) pentru o mai bună recunoaștere a entităților
|
43 |
+
- Implementarea autentificării utilizatorilor pentru accesul securizat la informațiile de facturare
|
44 |
+
- Adăugarea suportului pentru mai mulți furnizori de telecomunicații și formate de facturi
|
45 |
+
- Îmbunătățirea interfeței utilizatorului pentru o experiență mai bună
|
46 |
+
- Integrarea cu gateway-uri de plată pentru plata facturilor
|
47 |
+
|
48 |
+
## Concluzie
|
49 |
+
|
50 |
+
- Aplicația LLM Bill Chat demonstrează potențialul utilizării Modelor de Limbaj Mare pentru asistența în facturarea telecom.
|
51 |
+
- Aplicația oferă o interfață prietenoasă pentru interogarea informațiilor de facturare și obținerea de informații.
|
52 |
+
- Îmbunătățirile viitoare pot spori capacitățile aplicației și experiența utilizatorului.
|
README.md
CHANGED
@@ -17,30 +17,31 @@ This project is a proof of concept for a chat application utilizing a Large Lang
|
|
17 |
|
18 |
## Features
|
19 |
|
20 |
-
- Maintain chat conversation context
|
21 |
- Allow users to query their billing information
|
22 |
-
- Compare the last
|
23 |
- Respond exclusively with the user's own billing information
|
|
|
24 |
- Save user information and conversation history
|
25 |
|
26 |
## Project Structure
|
27 |
|
28 |
-
|
29 |
llm-bill-chat-app
|
30 |
├── src
|
31 |
│ ├── chat
|
32 |
-
│ │ ├── __init__.py
|
33 |
-
│ │ ├── context.py
|
34 |
-
│ │ ├── bill_comparison.py
|
35 |
-
│ │ ├── user_info.py
|
36 |
-
│ │ └── conversation.py
|
37 |
│ └── utils
|
38 |
-
│ └── __init__.py
|
39 |
-
├── bill.py
|
40 |
initialization for utils module
|
41 |
-
├── requirements.txt
|
42 |
-
└── README.md
|
43 |
-
|
44 |
|
45 |
## Installation
|
46 |
|
|
|
17 |
|
18 |
## Features
|
19 |
|
20 |
+
- Maintain chat conversation context (history)
|
21 |
- Allow users to query their billing information
|
22 |
+
- Compare the last bills and provide insights
|
23 |
- Respond exclusively with the user's own billing information
|
24 |
+
- Augment the prompt instructions with user's text recognized entities - NER.
|
25 |
- Save user information and conversation history
|
26 |
|
27 |
## Project Structure
|
28 |
|
29 |
+
|
30 |
llm-bill-chat-app
|
31 |
├── src
|
32 |
│ ├── chat
|
33 |
+
│ │ ├── __init__.py
|
34 |
+
│ │ ├── context.py
|
35 |
+
│ │ ├── bill_comparison.py
|
36 |
+
│ │ ├── user_info.py
|
37 |
+
│ │ └── conversation.py
|
38 |
│ └── utils
|
39 |
+
│ └── __init__.py
|
40 |
+
├── bill.py # Streamlit app
|
41 |
initialization for utils module
|
42 |
+
├── requirements.txt
|
43 |
+
└── README.md
|
44 |
+
|
45 |
|
46 |
## Installation
|
47 |
|
diag.md
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
+---------------------+
|
2 |
+
| hf-llm-bill-chat/ |
|
3 |
+
+---------------------+
|
4 |
+
|
|
5 |
+
+---------------------+
|
6 |
+
| app.py |
|
7 |
+
+---------------------+
|
8 |
+
|
|
9 |
+
+---------------------+
|
10 |
+
| pages/ |
|
11 |
+
+---------------------+
|
12 |
+
| |
|
13 |
+
| +---------------------+
|
14 |
+
| | One_model.py |
|
15 |
+
| +---------------------+
|
16 |
+
| |
|
17 |
+
| +---------------------+
|
18 |
+
| | Two_models.py |
|
19 |
+
| +---------------------+
|
20 |
+
|
|
21 |
+
+---------------------+
|
22 |
+
| data/ |
|
23 |
+
+---------------------+
|
24 |
+
| |
|
25 |
+
| +---------------------+
|
26 |
+
| | user_data/ |
|
27 |
+
| +---------------------+
|
28 |
+
| |
|
29 |
+
| +---------------------+
|
30 |
+
| | user_data_724077190.json |
|
31 |
+
| +---------------------+
|
32 |
+
|
|
33 |
+
+---------------------+
|
34 |
+
| logs/ |
|
35 |
+
+---------------------+
|
36 |
+
|
|
37 |
+
+---------------------+
|
38 |
+
| conversation_logs.json |
|
39 |
+
+---------------------+
|
diag.plantUML
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@startuml
|
2 |
+
package "hf-llm-bill-chat/" {
|
3 |
+
[app.py]
|
4 |
+
package "pages/" {
|
5 |
+
[One_model.py]
|
6 |
+
[Two_models.py]
|
7 |
+
}
|
8 |
+
package "data/" {
|
9 |
+
package "user_data/" {
|
10 |
+
[user_data_724077190.json]
|
11 |
+
}
|
12 |
+
}
|
13 |
+
package "logs/" {
|
14 |
+
[conversation_logs.json]
|
15 |
+
}
|
16 |
+
}
|
17 |
+
@enduml
|
logs/conversation_logs.json
CHANGED
@@ -142,5 +142,41 @@
|
|
142 |
"total_tokens": 2208
|
143 |
},
|
144 |
"cost": 0.06624
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
]
|
|
|
142 |
"total_tokens": 2208
|
143 |
},
|
144 |
"cost": 0.06624
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"timestamp": "2025-01-22T17:36:25.195958",
|
148 |
+
"user_id": "0724077190",
|
149 |
+
"user_query": "total costuri?",
|
150 |
+
"assistant_response": "Pentru a calcula totalul costurilor per num\u0103r de telefon din cele dou\u0103 facturi, voi sumariza costurile a\u0219a cum sunt prezentate \u00een datele furnizate.\n\n### Factura 1 (Data: 2025-01-06)\n1. **Num\u0103r telefon: 724015962**\n - Red 11: 34.08 lei\n - Reducere promo: -8.52 lei\n - Secure Net: 2.99 lei\n - Reducere promotional\u0103 12 luni: -4.26 lei\n - Rate terminal: 70.99 lei\n - **Total costuri:** 34.08 - 8.52 + 2.99 - 4.26 + 70.99 = **95.28 lei**\n\n2. **Num\u0103r telefon: 373920691**\n - Abonament Vodafone WiFi Instant Nelimitat+: 29.82 lei\n - **Total costuri:** 29.82 lei\n\n3. **Num\u0103r telefon: 724077190**\n - RED Start: 38.33 lei\n - Secure Net: 2.99 lei\n - Reducere promotional\u0103 12 luni: -4.26 lei\n - Reducere Secure Net: -2.99 lei\n - Valoare rate r\u0103mase p\u00e2n\u0103 la expirare contract: 5374.54 lei\n - **Total costuri:** 38.33 + 2.99 - 4.26 - 2.99 + 5374.54 = **5408.61 lei**\n\n### Factura 2 (Data: 2024-12-06)\n1. **Num\u0103r telefon: 724015962**\n - Red 11: 34.08 lei\n - Reducere promo: -8.52 lei\n - Secure Net: 2.99 lei\n - Reducere promotional\u0103 12 luni: -4.26 lei\n - Rate terminal: 70.99 lei\n - **Total costuri:** 34.08 - 8.52 + 2.99 - 4.26 + 70.99 = **95.28 lei**\n\n2. **Num\u0103r telefon: 373920691**\n - Abonament Vodafone WiFi Instant Nelimitat+: 29.82 lei\n - **Total costuri:** 29.82 lei\n\n3. **Num\u0103r telefon: 724077190**\n - RED Start: 38.33 lei\n - Secure Net: 2.99 lei\n - Reducere promotional\u0103 12 luni: -4.26 lei\n - Reducere Secure Net: -2.99 lei\n - **Total costuri:** 38.33 + 2.99 - 4.26 - 2.99 = **34.07 lei** (f\u0103r\u0103 rate terminal, deoarece acestea nu sunt incluse \u00een Factura 2)\n\n### Total costuri pe num\u0103r de telefon:\n- **Factura 1:**\n - 724015962: **95.28 lei**\n - 373920691: **29.82 lei**\n - 724077190: **5408.61 lei**\n - **Total factur\u0103 1:** 95.28 + 29.82 + 5408.61 = **5533.71 lei**\n\n- **Factura 2:**\n - 724015962: **95.28 lei**\n - 373920691: **29.82 lei**\n - 724077190: **34.07 lei**\n - **Total factur\u0103 2:** 95.28 + 29.82 + 34.07 = **159.17 lei**\n\n### Total general costuri:\n- **Total general factur\u0103 1:** **5533.71 lei**\n- **Total general factur\u0103 2:** **159.17 lei**\n\nDac\u0103 ai alte \u00eentreb\u0103ri sau vrei s\u0103 analizezi mai \u00een detaliu vreun aspect, te rog s\u0103 \u00eemi spui!",
|
151 |
+
"tokens": {
|
152 |
+
"prompt_tokens": 3498,
|
153 |
+
"completion_tokens": 854,
|
154 |
+
"total_tokens": 4352
|
155 |
+
},
|
156 |
+
"cost": 0.06527999999999999
|
157 |
+
},
|
158 |
+
{
|
159 |
+
"timestamp": "2025-01-22T17:37:46.055914",
|
160 |
+
"user_id": "0724077190",
|
161 |
+
"user_query": "reia raspunsul",
|
162 |
+
"assistant_response": "Desigur, s\u0103 sumariz\u0103m totalul costurilor pentru fiecare num\u0103r de telefon pe baza informa\u021biilor din facturi.\n\n### Factura 1 (Data: 2025-01-06)\n1. **Num\u0103r telefon: 724015962**\n - Red 11: 34.08 lei\n - Reducere promo: -8.52 lei\n - Secure Net: 2.99 lei\n - Reducere promotional\u0103 12 luni: -4.26 lei\n - Rate terminal: 70.99 lei\n - **Total costuri:** 34.08 - 8.52 + 2.99 - 4.26 + 70.99 = **95.28 lei**\n\n2. **Num\u0103r telefon: 373920691**\n - Abonament Vodafone WiFi Instant Nelimitat+: 29.82 lei\n - **Total costuri:** 29.82 lei\n\n3. **Num\u0103r telefon: 724077190**\n - RED Start: 38.33 lei\n - Secure Net: 2.99 lei\n - Reducere promotional\u0103 12 luni: -4.26 lei\n - Reducere Secure Net: -2.99 lei\n - Valoare rate r\u0103mase p\u00e2n\u0103 la expirare contract: 5374.54 lei\n - **Total costuri:** 38.33 + 2.99 - 4.26 - 2.99 + 5374.54 = **5408.61 lei**\n\n### Factura 2 (Data: 2024-12-06)\n1. **Num\u0103r telefon: 724015962**\n - Red 11: 34.08 lei\n - Reducere promo: -8.52 lei\n - Secure Net: 2.99 lei\n - Reducere promotional\u0103 12 luni: -4.26 lei\n - Rate terminal: 70.99 lei\n - **Total costuri:** 34.08 - 8.52 + 2.99 - 4.26 + 70.99 = **95.28 lei**\n\n2. **Num\u0103r telefon: 373920691**\n - Abonament Vodafone WiFi Instant Nelimitat+: 29.82 lei\n - **Total costuri:** 29.82 lei\n\n3. **Num\u0103r telefon: 724077190**\n - RED Start: 38.33 lei\n - Secure Net: 2.99 lei\n - Reducere promotional\u0103 12 luni: -4.26 lei\n - **Total costuri:** 38.33 + 2.99 - 4.26 = **37.06 lei**\n\n### Total costuri pentru fiecare num\u0103r de telefon:\n- **Factura 1:**\n - 724015962: **95.28 lei**\n - 373920691: **29.82 lei**\n - 724077190: **5408.61 lei**\n - **Total general factur\u0103 1:** 95.28 + 29.82 + 5408.61 = **5533.71 lei**\n\n- **Factura 2:**\n - 724015962: **95.28 lei**\n - 373920691: **29.82 lei**\n - 724077190: **37.06 lei**\n - **Total general factur\u0103 2:** 95.28 + 29.82 + 37.06 = **162.16 lei**\n\nDac\u0103 ai nevoie de alte detalii sau clarific\u0103ri, te rog s\u0103 \u00eemi spui!",
|
163 |
+
"tokens": {
|
164 |
+
"prompt_tokens": 4364,
|
165 |
+
"completion_tokens": 763,
|
166 |
+
"total_tokens": 5127
|
167 |
+
},
|
168 |
+
"cost": 0.15380999999999997
|
169 |
+
},
|
170 |
+
{
|
171 |
+
"timestamp": "2025-01-27T13:36:32.266831",
|
172 |
+
"user_id": "0724077190",
|
173 |
+
"user_query": "De ce am asa de mult de plata",
|
174 |
+
"assistant_response": "\u00cen baza informa\u021biilor din facturile prezentate, exist\u0103 c\u00e2teva aspecte importante de remarcat care explic\u0103 motivele pentru care ai un total de plat\u0103 at\u00e2t de mare:\n\n1. **Valoare rate ramase pana la expirare contract**: Acesta este un cost semnificativ care se poate acumula odat\u0103 cu trecerea timpului. \u00cen factura din 2025, valoarea rate ramase este de ***5374.54 lei***. Acest lucru indic\u0103 faptul c\u0103 ai un contract de plat\u0103 \u00een rate care este \u00eenc\u0103 activ \u0219i cu o sum\u0103 considerabil\u0103 de plat\u0103 restant\u0103.\n\n2. **Rest plata**: Aceast\u0103 sum\u0103 poate include plata restant\u0103 de la facturile anterioare. \u00cen factura din 2025, restul de plat\u0103 este de ***-5073.74 lei***, ceea ce sugereaz\u0103 c\u0103 a existat o sum\u0103 de plat\u0103 care trebuia acoperit\u0103 din facturile anterioare.\n\n3. **Promotie Vodafone Smartphone cu plata in rate 12/36**: Aceasta este o promo\u021bie prin care ai achizi\u021bionat un smartphone cu plata \u00een rate. Costurile asociate acestei promo\u021bii se adaug\u0103 totalului de plat\u0103 \u0219i contribuie, astfel, la valoarea total\u0103 pe care trebuie s\u0103 o achi\u021bi. \u00cen facturile men\u021bionate, aceast\u0103 promovare apare ca un cost, iar valoarea ratei este de ***70.99 lei*** pentru perioada facturat\u0103.\n\n4. **Total de plata**: \u00cen ultima factur\u0103, totalul de plat\u0103 este de ***5550.46 lei***, ceea ce reflect\u0103 costurile totale acumulate, inclusiv ratele, costurile suplimentare \u0219i alte taxe.\n\nAceste elemente contribuie la suma total\u0103 pe care trebuie s\u0103 o pl\u0103te\u0219ti \u0219i explic\u0103 de ce factura este at\u00e2t de mare. Dac\u0103 ai nevoie de detalii suplimentare, te pot ajuta cu informa\u021bii din facturile respective.",
|
175 |
+
"tokens": {
|
176 |
+
"prompt_tokens": 1789,
|
177 |
+
"completion_tokens": 422,
|
178 |
+
"total_tokens": 2211
|
179 |
+
},
|
180 |
+
"cost": 0.033165
|
181 |
}
|
182 |
]
|