Spaces:
Runtime error
Runtime error
Sandeep03edu
commited on
Commit
•
7880eaa
1
Parent(s):
fd52c5f
Upload 6 files
Browse files- Dockerfile +11 -0
- app.py +64 -0
- data/app.txt +34 -0
- requirements.txt +8 -0
Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
|
5 |
+
COPY ./requirements.txt /code/requirements.txt
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
+
|
9 |
+
COPY . .
|
10 |
+
|
11 |
+
CMD ["gunicorn","-b", "0.0.0.0:7860", "app:app"]
|
app.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, jsonify
|
2 |
+
from langchain_community.document_loaders import TextLoader
|
3 |
+
from langchain.text_splitter import CharacterTextSplitter
|
4 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
5 |
+
from langchain_community.vectorstores import FAISS
|
6 |
+
from langchain.chains.question_answering import load_qa_chain
|
7 |
+
from langchain_community.llms.huggingface_endpoint import HuggingFaceEndpoint
|
8 |
+
|
9 |
+
# To comment in production usage
|
10 |
+
# import Constants
|
11 |
+
# import os
|
12 |
+
# os.environ["HUGGINGFACEHUB_API_TOKEN"] = Constants.TOKEN
|
13 |
+
|
14 |
+
|
15 |
+
app = Flask(__name__)
|
16 |
+
|
17 |
+
|
18 |
+
try:
|
19 |
+
loader = TextLoader("./data/app.txt")
|
20 |
+
document = loader.load()
|
21 |
+
|
22 |
+
# Split the document into chunks
|
23 |
+
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
|
24 |
+
docs = text_splitter.split_documents(document)
|
25 |
+
|
26 |
+
# Create embeddings
|
27 |
+
embedding = HuggingFaceEmbeddings(model_name = "sentence-transformers/all-mpnet-base-v2")
|
28 |
+
db = FAISS.from_documents(docs, embedding)
|
29 |
+
|
30 |
+
# Load the Question-Answering chain
|
31 |
+
llm = HuggingFaceEndpoint(repo_id="google/flan-t5-xxl", temperature=0.8, model_kwargs={"max_length": 512})
|
32 |
+
chain = load_qa_chain(llm, chain_type="stuff")
|
33 |
+
|
34 |
+
except Exception as e:
|
35 |
+
print("Recived Setup error: ", e)
|
36 |
+
|
37 |
+
def process_query(query):
|
38 |
+
# os.system("cls")
|
39 |
+
|
40 |
+
try:
|
41 |
+
querySimilarDocs = db.similarity_search(query)
|
42 |
+
|
43 |
+
res = chain.run(input_documents = querySimilarDocs, question = query)
|
44 |
+
|
45 |
+
return res
|
46 |
+
except Exception as e:
|
47 |
+
print("Received process error: ", e)
|
48 |
+
return "An Error occurred!!"
|
49 |
+
|
50 |
+
@app.route('/query', methods=['POST'])
|
51 |
+
def process_request():
|
52 |
+
|
53 |
+
try:
|
54 |
+
data = request.get_json()
|
55 |
+
user_input = data['query']
|
56 |
+
response = process_query(user_input)
|
57 |
+
return jsonify({"response": response})
|
58 |
+
except Exception as e:
|
59 |
+
print("Received Process request error: ", e)
|
60 |
+
return jsonify({"response": e})
|
61 |
+
|
62 |
+
## Development phase use case only
|
63 |
+
# if __name__ == '__main__':
|
64 |
+
# app.run(debug=True)
|
data/app.txt
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
App Name is Password Manager
|
2 |
+
App creater is Sandeep Mishra also known as sandeep03edu
|
3 |
+
App Play store link is https://play.google.com/store/apps/details?id=com.sandeep03edu.passwordmanager.android
|
4 |
+
App Website is https://password-manager-sandeep03edu.onrender.com/
|
5 |
+
|
6 |
+
Description
|
7 |
+
Password manager is an app which can be used to securely save users credentials in user's mobile and website
|
8 |
+
App uses double authentication principle with one 4 digit login pin and one 6 digit app pin
|
9 |
+
App also contains encryption algorithms to securely save credentials in encrypted form
|
10 |
+
App can be used to save any website/url passwords or any card details like credit card, debit card, etc
|
11 |
+
|
12 |
+
Functionality
|
13 |
+
App uses an email id authentication to signup along with two keys, app pin and login pin
|
14 |
+
Un-Registered users need to fill up a form with their name, login pin and app pin for registeration process
|
15 |
+
Registered users can login to their account by entering app pin and login pin
|
16 |
+
|
17 |
+
Once successful authenticated, user can save their card and password details in the app
|
18 |
+
|
19 |
+
Saving Card
|
20 |
+
User can save their credit, debit and other cards with their card holder name, card number, card issuer name, card bank name, card CVV, card PIN which is stored in encrypted manner in user's local device
|
21 |
+
|
22 |
+
Once card is saved
|
23 |
+
User also have a option to sync their card details to server, once synced, the card details will be uploaded securely to the web server and user can login into another device, app's web page to access the same credential anywhere
|
24 |
+
User also have a option to unsync their card, so only that device will have that card details stored locally and no other device will have that card details
|
25 |
+
User also have a option to delete their card, By deleting user can delete their card from all of the places, from locally stored data to server stored database
|
26 |
+
|
27 |
+
Saving Password
|
28 |
+
User can save their website/url passwords where user can provide url, username, emailid, password, pin, tags which is stored in encrypted manner in user's local device
|
29 |
+
|
30 |
+
Once Password is saved
|
31 |
+
User also have a option to sync their Password details to server, once synced, the card details will be uploaded securely to the web server and user can login into another device, app's web page to access the same credential anywhere
|
32 |
+
User also have a option to unsync their Password, so only that device will have that Password details stored locally and no other device will have that card details
|
33 |
+
User also have a option to delete their Password, By deleting user can delete their Password from all of the places, from locally stored data to server stored database
|
34 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain==0.1.12
|
2 |
+
langchain_community==0.0.28
|
3 |
+
flask==3.0.2
|
4 |
+
sentence-transformers==2.6.0
|
5 |
+
waitress==3.0.0
|
6 |
+
gunicorn ==21.2.0
|
7 |
+
gevent==24.2.1
|
8 |
+
huggingface_hub==0.22.1
|