Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -177,38 +177,33 @@ def insert_data(extracted_details):
|
|
177 |
llm = Llama(model_path='./ggml-model-q8_0.gguf', n_ctx=2048, n_batch=2048, n_threads= 204)
|
178 |
|
179 |
def read_email():
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
extracted_details.update(meta_data)
|
204 |
|
205 |
-
|
206 |
-
|
207 |
|
208 |
-
|
209 |
-
except Exception as e:
|
210 |
-
print(f"Error reading csv emails: {e}")
|
211 |
-
|
212 |
|
213 |
# Global variables
|
214 |
running = False
|
|
|
177 |
llm = Llama(model_path='./ggml-model-q8_0.gguf', n_ctx=2048, n_batch=2048, n_threads= 204)
|
178 |
|
179 |
def read_email():
|
180 |
+
df = pd.read_csv('./emails.csv')
|
181 |
+
for i in df['Body']:
|
182 |
+
prompt_ = f"<s>system:{prompt}<|end|><s>user:{i}<|end|<s>assistant:"
|
183 |
+
output = llm(prompt_, max_tokens=1000, temperature=0.1)
|
184 |
+
print("*"*50)
|
185 |
+
t = output['choices'][0]['text']
|
186 |
+
print('input : ',i)
|
187 |
+
print('output : ',t)
|
188 |
+
# t = t[t.find('json\n')+len('json\n'):]
|
189 |
+
extracted_details = json.loads(t)
|
190 |
+
print(extracted_details)
|
191 |
+
|
192 |
+
# print(extracted_details)
|
193 |
+
print(type(extracted_details))
|
194 |
+
meta_data = {
|
195 |
+
'sender': 'sender',
|
196 |
+
'receiver': 'receiver',
|
197 |
+
'cc': 'cc',
|
198 |
+
'bcc': 'bcc',
|
199 |
+
'subject': 'subject'
|
200 |
+
}
|
201 |
+
# print(type(meta_data))
|
202 |
+
extracted_details.update(meta_data)
|
|
|
203 |
|
204 |
+
print('full data about email ! ...::',extracted_details)
|
205 |
+
insert_data(extracted_details)
|
206 |
|
|
|
|
|
|
|
|
|
207 |
|
208 |
# Global variables
|
209 |
running = False
|