SavirD commited on
Commit
492e26e
·
verified ·
1 Parent(s): c70333a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -5,10 +5,9 @@ client = MongoClient("mongodb+srv://Savir:savir2010@m0-savir.8iqdy.mongodb.net/?
5
 
6
  db = client['sentiment-db']
7
  collection = db['sentiment-collection']
8
- results = collection.find({"name":'savir'})
9
- for result in results:
10
- st.markdown(f"{result}")
11
- exit()
12
  from peft import PeftModel, PeftConfig
13
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
14
  import torch
@@ -37,4 +36,6 @@ predictions = torch.max(logits,1).indices
37
  if st.button("Calculate Sentiment"):
38
  with st.chat_message("assistant"):
39
  response = "The Following Text " + f'"{review}" is ' + id2label[predictions.tolist()[0]]
 
 
40
  st.markdown(response)
 
5
 
6
  db = client['sentiment-db']
7
  collection = db['sentiment-collection']
8
+ # results = collection.find({"name":'savir'})
9
+ # for result in results:
10
+ # st.markdown(f"{result}")
 
11
  from peft import PeftModel, PeftConfig
12
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
13
  import torch
 
36
  if st.button("Calculate Sentiment"):
37
  with st.chat_message("assistant"):
38
  response = "The Following Text " + f'"{review}" is ' + id2label[predictions.tolist()[0]]
39
+ response_dict = {review:id2label[predictions.tolist()[0]]}
40
+ response_db = collection.insert_one(response_dict)
41
  st.markdown(response)