trashchenkov commited on
Commit
8e7534c
·
verified ·
1 Parent(s): d0e88b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -6,9 +6,18 @@ from langchain_community.chat_models.gigachat import GigaChat
6
  from langchain_community.vectorstores import FAISS
7
  from langchain_community.embeddings import HuggingFaceEmbeddings
8
  import os
 
 
9
  #import telebot
10
 
11
 
 
 
 
 
 
 
 
12
  def get_yt_links(contexts):
13
  html = '''
14
  <iframe width="100%" height="200" src="{}?start={}" \
@@ -43,6 +52,7 @@ def get_context(contexts):
43
 
44
  def process_input(text):
45
  response = retrieval_chain.invoke({"input": text})
 
46
  #bot.send_message(user_id, resp2msg(response))
47
  youtube_links = get_yt_links(response['context'])
48
  context = get_context(response['context'])
 
6
  from langchain_community.vectorstores import FAISS
7
  from langchain_community.embeddings import HuggingFaceEmbeddings
8
  import os
9
+ import time
10
+ import json
11
  #import telebot
12
 
13
 
14
+ def save_json(data):
15
+ timestamp = int(time.time())
16
+ filename = f"{timestamp}.json"
17
+ filepath = f"./requests_from_users/{filename}"
18
+ with open(filepath, 'w') as json_file:
19
+ json.dump(data, json_file)
20
+
21
  def get_yt_links(contexts):
22
  html = '''
23
  <iframe width="100%" height="200" src="{}?start={}" \
 
52
 
53
  def process_input(text):
54
  response = retrieval_chain.invoke({"input": text})
55
+ save_json(response)
56
  #bot.send_message(user_id, resp2msg(response))
57
  youtube_links = get_yt_links(response['context'])
58
  context = get_context(response['context'])