Aleksey Khlopkov commited on
Commit
99bafa0
·
1 Parent(s): 74d4655

replying to msg

Browse files
Files changed (3) hide show
  1. .gitignore +1 -1
  2. main.py +5 -4
  3. requirements.txt +22 -0
.gitignore CHANGED
@@ -173,7 +173,7 @@ cython_debug/
173
  # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
  # and can be added to the global gitignore or merged into this file. For a more nuclear
175
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
- #.idea/
177
 
178
  # Abstra
179
  # Abstra is an AI-powered process automation framework.
 
173
  # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
  # and can be added to the global gitignore or merged into this file. For a more nuclear
175
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ .idea/
177
 
178
  # Abstra
179
  # Abstra is an AI-powered process automation framework.
main.py CHANGED
@@ -8,7 +8,6 @@ from dotenv import load_dotenv
8
  from models.seq2seq.model import Seq2SeqChatbot
9
  import torch
10
 
11
-
12
  load_dotenv()
13
 
14
  TOKEN: Final = os.environ.get("TOKEN")
@@ -20,10 +19,11 @@ CHECKPOINT_PATH: Final = "models/seq2seq/checkpoint/150_checkpoint.tar"
20
  torch.manual_seed(0)
21
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
22
 
23
- chatbot = Seq2SeqChatbot(500, 2, 2, 0.1, device)
24
  chatbot.load_checkpoint(CHECKPOINT_PATH)
25
  chatbot.eval_mode()
26
 
 
27
  def handle_response(text: str) -> Optional[str]:
28
  response_chance = 1.0
29
  if random.random() < response_chance:
@@ -36,7 +36,7 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
36
  text: str = update.message.text.replace(BOT_USERNAME, '').strip().lower()
37
  response: Optional[str] = handle_response(text)
38
  if response:
39
- await context.bot.sendMessage(update.message.chat_id, response)
40
 
41
 
42
  async def error(update: Update, context: ContextTypes.DEFAULT_TYPE):
@@ -44,6 +44,7 @@ async def error(update: Update, context: ContextTypes.DEFAULT_TYPE):
44
  f"chat caused error \"{context.error}\"\n"
45
  f"{update}\"")
46
 
 
47
  def main() -> None:
48
  """Run the bot."""
49
  application = Application.builder().token(TOKEN).build()
@@ -57,4 +58,4 @@ def main() -> None:
57
  if __name__ == '__main__':
58
  print("Running main...")
59
  # print(chatbot("test"))
60
- main()
 
8
  from models.seq2seq.model import Seq2SeqChatbot
9
  import torch
10
 
 
11
  load_dotenv()
12
 
13
  TOKEN: Final = os.environ.get("TOKEN")
 
19
  torch.manual_seed(0)
20
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
21
 
22
+ chatbot = Seq2SeqChatbot(500, 8856, 2, 2, 0.1, device)
23
  chatbot.load_checkpoint(CHECKPOINT_PATH)
24
  chatbot.eval_mode()
25
 
26
+
27
  def handle_response(text: str) -> Optional[str]:
28
  response_chance = 1.0
29
  if random.random() < response_chance:
 
36
  text: str = update.message.text.replace(BOT_USERNAME, '').strip().lower()
37
  response: Optional[str] = handle_response(text)
38
  if response:
39
+ await context.bot.sendMessage(update.message.chat_id, response, reply_to_message_id=update.message.id)
40
 
41
 
42
  async def error(update: Update, context: ContextTypes.DEFAULT_TYPE):
 
44
  f"chat caused error \"{context.error}\"\n"
45
  f"{update}\"")
46
 
47
+
48
  def main() -> None:
49
  """Run the bot."""
50
  application = Application.builder().token(TOKEN).build()
 
58
  if __name__ == '__main__':
59
  print("Running main...")
60
  # print(chatbot("test"))
61
+ main()
requirements.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ anyio==4.9.0
2
+ certifi==2025.7.14
3
+ colorama==0.4.6
4
+ filelock==3.18.0
5
+ fsspec==2025.7.0
6
+ h11==0.16.0
7
+ httpcore==1.0.9
8
+ httpx==0.28.1
9
+ idna==3.10
10
+ Jinja2==3.1.6
11
+ MarkupSafe==3.0.2
12
+ mpmath==1.3.0
13
+ networkx==3.5
14
+ numpy==2.3.1
15
+ python-dotenv==1.1.1
16
+ python-telegram-bot==22.3
17
+ setuptools==80.9.0
18
+ sniffio==1.3.1
19
+ sympy==1.14.0
20
+ torch==2.7.1
21
+ tqdm==4.67.1
22
+ typing_extensions==4.14.1