realambuj commited on
Commit
3846949
1 Parent(s): 20c3078

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +19 -7
utils.py CHANGED
@@ -2,13 +2,8 @@ from langchain.chains.question_answering import load_qa_chain
2
  from langchain.prompts import PromptTemplate
3
  import json
4
  from prompts import *
5
-
6
- # from langchain.text_splitter import RecursiveCharacterTextSplitter
7
- # from PyPDF2 import PdfReader
8
- # from langchain_google_genai import GoogleGenerativeAIEmbeddings
9
- # from langchain.vectorstores import FAISS
10
- # import PyPDF2
11
-
12
 
13
  # utils function to generate QA Pairs
14
  def util(context, numPairs, inputPrompt,model):
@@ -46,3 +41,20 @@ def getMcqQAPairs(context, numPairs,model):
46
  template=prompt_template, input_variables=["context", "numPairs"]
47
  )
48
  return util(context, numPairs, prompt,model)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from langchain.prompts import PromptTemplate
3
  import json
4
  from prompts import *
5
+ import streamlit as st
6
+ import os
 
 
 
 
 
7
 
8
  # utils function to generate QA Pairs
9
  def util(context, numPairs, inputPrompt,model):
 
41
  template=prompt_template, input_variables=["context", "numPairs"]
42
  )
43
  return util(context, numPairs, prompt,model)
44
+
45
+ #download file
46
+ def downloadFile(response,FileName):
47
+ with open(FileName, "w") as outfile:
48
+ json.dump(response, outfile, indent=4)
49
+ with open(FileName, "rb") as file:
50
+ st.download_button(
51
+ label="Download File",
52
+ data=file,
53
+ file_name=FileName,
54
+ mime="text/json",
55
+ type='primary'
56
+ )
57
+ os.remove(FileName)
58
+ os.remove('temp.pdf')
59
+
60
+