Nah_kagz1092 commited on
Commit
10ebdb4
·
verified ·
1 Parent(s): 1f1e697

Create interact.py

Browse files
Files changed (1) hide show
  1. interact.py +35 -0
interact.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from model import TransformerModel
2
+ from data import load_data, save_data
3
+ import utils
4
+
5
+ def main():
6
+ # Load config từ file JSON
7
+ config = load_data('config.json')
8
+
9
+ # Tạo mô hình dựa trên config
10
+ model = TransformerModel(config)
11
+
12
+ # Load dữ liệu tương tác
13
+ interaction_data = load_data('interaction_data.json')
14
+
15
+ # Code để tương tác với người dùng
16
+ while True:
17
+ user_input = input("Bạn: ")
18
+ if user_input.lower() == 'quit':
19
+ break
20
+
21
+ # Xử lý đầu vào
22
+ processed_input = utils.process_string(user_input)
23
+
24
+ # Dự đoán và tạo phản hồi
25
+ response = model.predict(processed_input)
26
+
27
+ # Hiển thị phản hồi cho người dùng
28
+ print("Mô hình: ", response)
29
+
30
+ # Lưu trữ dữ liệu tương tác
31
+ interaction_data.append({"input": user_input, "response": response})
32
+ save_data(interaction_data, "interaction_data.json")
33
+
34
+ if __name__ == "__main__":
35
+ main()