Spaces:
Sleeping
Sleeping
Added xlsx file
Browse files- .gitattributes +1 -0
- app.py +92 -18
- db/6966de50-965b-4c9b-8067-c3848e3184b4/data_level0.bin +3 -0
- db/6966de50-965b-4c9b-8067-c3848e3184b4/header.bin +3 -0
- db/6966de50-965b-4c9b-8067-c3848e3184b4/length.bin +3 -0
- db/6966de50-965b-4c9b-8067-c3848e3184b4/link_lists.bin +0 -0
- db/chroma.sqlite3 +0 -0
- negative_reviews.txt +69 -0
- pie_chart.jpg +0 -0
- tweets.xlsx +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.xlsx filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -9,30 +9,40 @@ import google.generativeai as genai
|
|
9 |
from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
10 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
11 |
from dotenv import load_dotenv
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
# # Define the model and feature extractor globally
|
20 |
-
# model = AutoModelForImageClassification.from_pretrained('carbon225/vit-base-patch16-224-hentai')
|
21 |
-
# feature_extractor = AutoFeatureExtractor.from_pretrained('carbon225/vit-base-patch16-224-hentai')
|
22 |
|
23 |
def load_model():
|
24 |
api_key=os.getenv("GOOGLE_API_KEY")
|
25 |
genai.configure(api_key=api_key)
|
26 |
model = ChatGoogleGenerativeAI(model="gemini-pro",
|
27 |
temperature=0.3)
|
28 |
-
|
29 |
return model
|
30 |
|
|
|
31 |
def load_embeddings():
|
32 |
embeddings = GoogleGenerativeAIEmbeddings(model = "models/embedding-001")
|
33 |
|
34 |
return embeddings
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
@app.route("/", methods=["GET"])
|
37 |
def default():
|
38 |
return json.dumps({"Server": "Working"})
|
@@ -58,13 +68,77 @@ genai.configure(api_key=api_key)
|
|
58 |
model=genai.GenerativeModel('gemini-pro')
|
59 |
sentiment_analysis = pipeline("sentiment-analysis",model="siebert/sentiment-roberta-large-english")
|
60 |
|
61 |
-
@app.route('/sentiment',methods=['
|
62 |
def sentiment():
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
|
70 |
# @app.route("/predict", methods=["GET"])
|
@@ -110,4 +184,4 @@ def answer():
|
|
110 |
return json.dumps({"message":response.text})
|
111 |
|
112 |
if __name__ == "__main__":
|
113 |
-
app.run(debug=True)
|
|
|
9 |
from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
10 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
11 |
from dotenv import load_dotenv
|
12 |
+
from langchain_community.document_loaders import TextLoader
|
13 |
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
14 |
+
from langchain.vectorstores import Chroma
|
15 |
+
from langchain.chains.question_answering import load_qa_chain
|
16 |
+
from langchain import PromptTemplate
|
17 |
+
import pandas as pd
|
|
|
|
|
|
|
|
|
18 |
|
19 |
def load_model():
|
20 |
api_key=os.getenv("GOOGLE_API_KEY")
|
21 |
genai.configure(api_key=api_key)
|
22 |
model = ChatGoogleGenerativeAI(model="gemini-pro",
|
23 |
temperature=0.3)
|
|
|
24 |
return model
|
25 |
|
26 |
+
|
27 |
def load_embeddings():
|
28 |
embeddings = GoogleGenerativeAIEmbeddings(model = "models/embedding-001")
|
29 |
|
30 |
return embeddings
|
31 |
|
32 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
33 |
+
|
34 |
+
app = Flask(__name__)
|
35 |
+
cors = CORS(app)
|
36 |
+
load_dotenv()
|
37 |
+
|
38 |
+
pdf_model=load_model()
|
39 |
+
embeddings=load_embeddings()
|
40 |
+
|
41 |
+
# # Define the model and feature extractor globally
|
42 |
+
# model = AutoModelForImageClassification.from_pretrained('carbon225/vit-base-patch16-224-hentai')
|
43 |
+
# feature_extractor = AutoFeatureExtractor.from_pretrained('carbon225/vit-base-patch16-224-hentai')
|
44 |
+
|
45 |
+
|
46 |
@app.route("/", methods=["GET"])
|
47 |
def default():
|
48 |
return json.dumps({"Server": "Working"})
|
|
|
68 |
model=genai.GenerativeModel('gemini-pro')
|
69 |
sentiment_analysis = pipeline("sentiment-analysis",model="siebert/sentiment-roberta-large-english")
|
70 |
|
71 |
+
@app.route('/sentiment',methods=['GET'])
|
72 |
def sentiment():
|
73 |
+
df=pd.read_excel('./tweets.xlsx')
|
74 |
+
reviews=df['text'][:100].tolist()
|
75 |
+
pos_count=0
|
76 |
+
neg_count=0
|
77 |
+
positive_reviews=[]
|
78 |
+
negative_reviews=[]
|
79 |
+
for i in range(len(reviews)):
|
80 |
+
if sentiment_analysis(reviews[i])[0]['label']=='POSITIVE':
|
81 |
+
positive_reviews.append(reviews[i])
|
82 |
+
pos_count+=1
|
83 |
+
else:
|
84 |
+
negative_reviews.append(reviews[i])
|
85 |
+
neg_count+=1
|
86 |
+
|
87 |
+
file_path = "negative_reviews.txt"
|
88 |
+
|
89 |
+
with open(file_path, "w") as txt_file:
|
90 |
+
for review in negative_reviews:
|
91 |
+
txt_file.write(review + "\n")
|
92 |
+
|
93 |
+
import matplotlib.pyplot as plt
|
94 |
+
activities=['positive','negative']
|
95 |
+
slices=[pos_count,neg_count]
|
96 |
+
colors=['g','r']
|
97 |
+
plt.pie(slices, labels = activities, colors=colors,
|
98 |
+
startangle=90, shadow = True, explode = (0, 0),
|
99 |
+
radius = 1.2, autopct = '%1.1f%%')
|
100 |
+
|
101 |
+
plt.legend()
|
102 |
+
plt.savefig('pie_chart.jpg', format='jpg')
|
103 |
+
|
104 |
+
return json.dumps({"message":1})
|
105 |
+
|
106 |
+
# Getting key issues from customer feedback
|
107 |
+
@app.route('/process_txt',methods=['GET'])
|
108 |
+
def process_txt():
|
109 |
+
loader = TextLoader("./negative_reviews.txt", encoding = 'UTF-8')
|
110 |
+
documents=loader.load()
|
111 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
|
112 |
+
texts = text_splitter.split_documents(documents)
|
113 |
+
persist_directory = 'db'
|
114 |
+
vectordb = Chroma.from_documents(documents=texts,
|
115 |
+
embedding=embeddings,
|
116 |
+
persist_directory=persist_directory)
|
117 |
+
vectordb.persist()
|
118 |
+
vectordb = None
|
119 |
+
vectordb = Chroma(persist_directory=persist_directory,
|
120 |
+
embedding_function=embeddings)
|
121 |
+
retriever = vectordb.as_retriever()
|
122 |
+
query="Suggest what are the key issues from the following customer tweets"
|
123 |
+
|
124 |
+
prompt_template="""
|
125 |
+
Answer the question
|
126 |
+
Context:\n {context}?\n
|
127 |
+
Question:\n{question}?\n
|
128 |
+
|
129 |
+
Answer:
|
130 |
+
"""
|
131 |
+
|
132 |
+
prompt = PromptTemplate(template = prompt_template, input_variables = ["context", "question"])
|
133 |
+
chain = load_qa_chain(pdf_model, chain_type="stuff", prompt=prompt)
|
134 |
+
|
135 |
+
docs = retriever.get_relevant_documents(query)
|
136 |
+
response = chain(
|
137 |
+
{"input_documents":docs, "question": query}
|
138 |
+
, return_only_outputs=True)
|
139 |
+
|
140 |
+
return json.dumps({"response":response['output_text']})
|
141 |
+
|
142 |
|
143 |
|
144 |
# @app.route("/predict", methods=["GET"])
|
|
|
184 |
return json.dumps({"message":response.text})
|
185 |
|
186 |
if __name__ == "__main__":
|
187 |
+
app.run(debug=True)
|
db/6966de50-965b-4c9b-8067-c3848e3184b4/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a13e72541800c513c73dccea69f79e39cf4baef4fa23f7e117c0d6b0f5f99670
|
3 |
+
size 3212000
|
db/6966de50-965b-4c9b-8067-c3848e3184b4/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
|
3 |
+
size 100
|
db/6966de50-965b-4c9b-8067-c3848e3184b4/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc19b1997119425765295aeab72d76faa6927d4f83985d328c26f20468d6cc76
|
3 |
+
size 4000
|
db/6966de50-965b-4c9b-8067-c3848e3184b4/link_lists.bin
ADDED
File without changes
|
db/chroma.sqlite3
ADDED
Binary file (573 kB). View file
|
|
negative_reviews.txt
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Never use @Zomato food service, they deliver worst quality food and there help desk executive had no politness.… https://t.co/0vM6OJadjP
|
2 |
+
@zomatocare @ZomatoIN Hi, I want a refund for my Zomato gold membership, I bought it at a separate set of T&C's we… https://t.co/SV7lyOfZI6
|
3 |
+
@SwiggyCares horrible experience with swiggy today. Received bad quality food from subway, Had a word with custome… https://t.co/AzD70AKYWd
|
4 |
+
Very bad service.
|
5 |
+
Is the policy change even allowed after PPL buy Zomato Gold membership? @ZomatoIN https://t.co/aEULlvQEIc
|
6 |
+
In those situations, I usually open the Swiggy app at 1am and order something that I'll regret the next morning.
|
7 |
+
Was scrolling through foodpanda, but couldn't decide what to eat so I closed the app. Dia keluar notification ni ay… https://t.co/U3Er9gbs8a
|
8 |
+
@CatchDoon @Zomato @ZomatoIN @zomatocare Hi AD, We are sorry to hear this. We would like to assure you that we have… https://t.co/cAmwecsZVf
|
9 |
+
@SwiggyCares @harshamjty you guys are really good at spoiling some ones occassion.I have been cheated by you If you… https://t.co/AHCwR7AVYO
|
10 |
+
RT @AkashVe51269968: @SwiggyCares @harshamjty you guys are really good at spoiling some ones occassion.I have been cheated by you If you ar…
|
11 |
+
I don’t know why I choose swiggy for spoiling my Birth Day
|
12 |
+
Always knew that @ZomatoIN
|
13 |
+
@Zomato sucks! Fucking up their delivery boys by not paying them appropriately as promis… https://t.co/oXITmvlxI7
|
14 |
+
@foodpandaIndia Still NO RESPONSE!!!
|
15 |
+
I sent my order ID as asked but nothing!!
|
16 |
+
After being a loyal customer for mor… https://t.co/A1p7urrwJe
|
17 |
+
Good bye @FoodPandapk
|
18 |
+
Worst customer support.
|
19 |
+
My last few orders were delivered after 90 mins, upon inquiry I got… https://t.co/STlmkMZMDs
|
20 |
+
No response till now
|
21 |
+
Worst experience with @Zomato @ZomatoIN
|
22 |
+
@foodpandaIndia I ordered from my fav restaurant, order was placed 90 mins ago, driver has been 1 minute away pe… https://t.co/cYqYLViQ9B
|
23 |
+
There is no number to contact @zomato
|
24 |
+
@zomatocare @ZomatoIN @Zomato @swiggy_in @zomatocare your ASAP .. and its more than 2hrs.. Zomato monkeys! @ZomatoIN @Zomato
|
25 |
+
@hansaraman @ZomatoIN @Zomato @zomatocare We should lawyer up
|
26 |
+
@hansaraman @ZomatoIN @Zomato @zomatocare Invoke arbitration for unfair enrichment, damages, loss of food, and mental agony
|
27 |
+
@foodpandaIndia #craveparty is such a #cheatoffer.Tried ordering using the code. During payments,got failed. Now ca… https://t.co/nwxxDhwBlS
|
28 |
+
@ZomatoIN waiting for my my order for almost 2 hours not received the order yet . Talked to the zomato guys no supp… https://t.co/7rxEA9UMU6
|
29 |
+
Swiggy/zomato delivery atrocity Vadivelu troll video | Chennai – Chennai Video https://t.co/HH536LSGEa https://t.co/RFa22FaB4p
|
30 |
+
@neil_shroff @ZomatoIN @Zomato @zomatocare Essentially everything thst sounds good on a Twitter bio?
|
31 |
+
Perfect way to ruin your Sunday is to use @SwiggyCares. Every order is a struggle followed by random pathetic peopl… https://t.co/RZBGnt4IHp
|
32 |
+
FoodPanda Loot- Get Rs 200 Food Order at just Rs 50 only https://t.co/Fnf13i05YU https://t.co/BvQzXjqNo4
|
33 |
+
@inconsumerforum complaint number #905673 is raised against @SwiggyCares Order number #1955858170.
|
34 |
+
Thanks for del… https://t.co/vegEhCvh7W
|
35 |
+
Freaking pissed with foodpanda. Experienced TWO order cancelled today, one for lunch and another for dinner now. Ev… https://t.co/f2QVC7O5lU
|
36 |
+
https://t.co/BDLe6Vma4e
|
37 |
+
You guys are millionaire because we ....And treating these guys like this won't make you ma… https://t.co/PeX1hzO85m
|
38 |
+
https://t.co/BDLe6Vma4e
|
39 |
+
|
40 |
+
@ZomatoIN @Zomato
|
41 |
+
Look into this matter ...pretty serious and shameful for you guys😐😐
|
42 |
+
@ankurkulkarni27 @Zomato Zomato delivers very poor quality food. We get good quality in same restaurant if we visit there insted
|
43 |
+
@Zomato @ZomatoIN @zomatocare @zomato This is not done. You can not change conditions with which we have subscribed… https://t.co/TRtj36LccM
|
44 |
+
RT @deep__sanghvi: @Zomato @ZomatoIN @zomatocare @zomato This is not done. You can not change conditions with which we have subscribed post…
|
45 |
+
@deepigoyal @Zomato Order no- 1168485461
|
46 |
+
this is horrible.. the butter chikhen is really nice and upto the mark.. b… https://t.co/rDp7NHBlJX
|
47 |
+
@ZomatoIN @Zomato Order no- 1168485461
|
48 |
+
this is horrible.. the butter chikhen is really nice and upto the mark.. but… https://t.co/RNk4Q6FaAC
|
49 |
+
@prabirkumarhal9 @deepigoyal @Zomato Kebab instead of tikka ? There's a catch.
|
50 |
+
|
51 |
+
We are getting this checked and we'… https://t.co/zcV070dyRj
|
52 |
+
@swiggy_in @SwiggyCares
|
53 |
+
Hi Swiggy, wrong items were delivered twice in a single day. First time I didn't complain… https://t.co/S3XmvxntSO
|
54 |
+
.@ZomatoIN What a pathetic services? Got a call from restaurant saying the delivery boy is unavailable!
|
55 |
+
|
56 |
+
Ph: 78350… https://t.co/DodcOhG1sa
|
57 |
+
.@ZomatoIN @Zomato Order booked at 17:25, and its been 40 minutes!
|
58 |
+
|
59 |
+
Is #Zomato seriously an online food app?
|
60 |
+
@foodpandaIndia ORDER ID- b4ck-47qt. Order confirmed at 5.20pm, 30 minutes was expected time but till now order has… https://t.co/gGFwmgKtCT
|
61 |
+
@zomatocare @deepigoyal @Zomato When!?... It's already 2 hours gone
|
62 |
+
@krishanbajaj13 We believe you have contacted foodpanda Pakistan and would request you to contact your desired coun… https://t.co/4JT3g2DZvy
|
63 |
+
.@Zomato @ZomatoIN This is seroius now! Even after 60 minutes no information on the food ordered.
|
64 |
+
|
65 |
+
Please shut shops!
|
66 |
+
@dominos_india Does the picture not speak. Check my order number 155.
|
67 |
+
35546928130213222. Order placed with Swiggy… https://t.co/z6KQXstm9x
|
68 |
+
RT @vilegenius: So @Zomato now that we can only use 1 gold per couple, are you planning to refund my membership? I don't need it as my hus…
|
69 |
+
How many minutes do you want from me, foodpanda? https://t.co/bhPq2Nzvh2
|
pie_chart.jpg
ADDED
![]() |
tweets.xlsx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7649f2dc78142f309f2de95ef07b125d72fc09681b47add847240a0ef51b701e
|
3 |
+
size 8143378
|