Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import numpy as np
|
2 |
import pandas as pd
|
3 |
|
@@ -19,33 +21,6 @@ import gradio as gr
|
|
19 |
import asyncio
|
20 |
from telegram import Bot
|
21 |
|
22 |
-
import os
|
23 |
-
import requests
|
24 |
-
from requests.adapters import HTTPAdapter
|
25 |
-
from requests.packages.urllib3.util.retry import Retry
|
26 |
-
|
27 |
-
|
28 |
-
def send_telegram_message(token, chat_id, message):
|
29 |
-
bot = Bot(token=token)
|
30 |
-
retries = Retry(total=5, backoff_factor=0.5, status_forcelist=[500, 502, 503, 504])
|
31 |
-
adapter = HTTPAdapter(max_retries=retries)
|
32 |
-
http = requests.Session()
|
33 |
-
http.mount("https://", adapter)
|
34 |
-
|
35 |
-
try:
|
36 |
-
response = bot.send_message(chat_id=chat_id, text=message)
|
37 |
-
print("Message sent successfully:", response)
|
38 |
-
except telegram.error.TelegramError as e:
|
39 |
-
print(f"Failed to send message: {e}")
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
def load_resolv_conf():
|
44 |
-
with open('/etc/resolv.conf', 'r') as resolv_conf:
|
45 |
-
return resolv_conf.readlines()
|
46 |
-
|
47 |
-
load_resolv_conf()
|
48 |
-
|
49 |
token = '7370905765:AAHvmlw68cW7RxWzsJE1yxTzgf3xQFiokDo'
|
50 |
chat_id = '7431171535'
|
51 |
pd.set_option('display.max_colwidth', None)
|
@@ -55,6 +30,24 @@ print(df_resume.head())
|
|
55 |
model = SentenceTransformer("all-MiniLM-L6-v2")
|
56 |
# file_name = 'questions.txt'
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
|
60 |
def savevectorstore():
|
@@ -108,7 +101,8 @@ def rag_chain(question,name):
|
|
108 |
# with open('questions.txt', 'a',encoding='utf-8') as file:
|
109 |
# file.write(f"\n\n{question}\n\n{country}\n\n{whatsapp}\n\n{name}||{sales}||{profit}||{product}")
|
110 |
message = f"{name}\n\n{question}\n\n{ans}"
|
111 |
-
send_telegram_message(token, chat_id, message)
|
|
|
112 |
return que,ans
|
113 |
# rag_chain('I am very hungry.')
|
114 |
|
|
|
1 |
+
import time
|
2 |
+
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
5 |
|
|
|
21 |
import asyncio
|
22 |
from telegram import Bot
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
token = '7370905765:AAHvmlw68cW7RxWzsJE1yxTzgf3xQFiokDo'
|
25 |
chat_id = '7431171535'
|
26 |
pd.set_option('display.max_colwidth', None)
|
|
|
30 |
model = SentenceTransformer("all-MiniLM-L6-v2")
|
31 |
# file_name = 'questions.txt'
|
32 |
|
33 |
+
import os
|
34 |
+
|
35 |
+
import http.client, urllib
|
36 |
+
def send_message(message):
|
37 |
+
conn = http.client.HTTPSConnection("api.pushover.net:443")
|
38 |
+
conn.request("POST", "/1/messages.json",
|
39 |
+
urllib.parse.urlencode({
|
40 |
+
"token": "ar2zh3pd82ujvjdmn27kdn5axapsjm",
|
41 |
+
"user": "ucvqife229ek8qiymrircodezw2vm2",
|
42 |
+
"message": message,
|
43 |
+
}), { "Content-type": "application/x-www-form-urlencoded" })
|
44 |
+
conn.getresponse()
|
45 |
+
|
46 |
+
|
47 |
+
async def send_telegram_message(token, chat_id, message):
|
48 |
+
bot = Bot(token=token)
|
49 |
+
await bot.send_message(chat_id=chat_id, text=message)
|
50 |
+
print("Message sent successfully.")
|
51 |
|
52 |
|
53 |
def savevectorstore():
|
|
|
101 |
# with open('questions.txt', 'a',encoding='utf-8') as file:
|
102 |
# file.write(f"\n\n{question}\n\n{country}\n\n{whatsapp}\n\n{name}||{sales}||{profit}||{product}")
|
103 |
message = f"{name}\n\n{question}\n\n{ans}"
|
104 |
+
# asyncio.run(send_telegram_message(token, chat_id, message))
|
105 |
+
send_message(message)
|
106 |
return que,ans
|
107 |
# rag_chain('I am very hungry.')
|
108 |
|