Spaces:
Sleeping
Sleeping
ishworrsubedii
commited on
Commit
•
ba4a6fd
1
Parent(s):
f4ddd80
.gitignore + updated login + signup
Browse files- .gitignore +145 -0
- app.py +100 -7
.gitignore
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
pip-wheel-metadata/
|
24 |
+
share/python-wheels/
|
25 |
+
*.egg-info/
|
26 |
+
.installed.cfg
|
27 |
+
*.egg
|
28 |
+
MANIFEST
|
29 |
+
|
30 |
+
# PyInstaller
|
31 |
+
# Usually these files are written by a python script from a template
|
32 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33 |
+
*.manifest
|
34 |
+
*.spec
|
35 |
+
|
36 |
+
# Installer logs
|
37 |
+
pip-log.txt
|
38 |
+
pip-delete-this-directory.txt
|
39 |
+
|
40 |
+
# Unit test / coverage reports
|
41 |
+
htmlcov/
|
42 |
+
.tox/
|
43 |
+
.nox/
|
44 |
+
.coverage
|
45 |
+
.coverage.*
|
46 |
+
.cache
|
47 |
+
nosetests.xml
|
48 |
+
coverage.xml
|
49 |
+
*.cover
|
50 |
+
*.py,cover
|
51 |
+
.hypothesis/
|
52 |
+
.pytest_cache/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
target/
|
76 |
+
|
77 |
+
# Jupyter Notebook
|
78 |
+
.ipynb_checkpoints
|
79 |
+
|
80 |
+
# IPython
|
81 |
+
profile_default/
|
82 |
+
ipython_config.py
|
83 |
+
|
84 |
+
# pyenv
|
85 |
+
.python-version
|
86 |
+
|
87 |
+
# pipenv
|
88 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
89 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
90 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
91 |
+
# install all needed dependencies.
|
92 |
+
#Pipfile.lock
|
93 |
+
|
94 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
95 |
+
__pypackages__/
|
96 |
+
|
97 |
+
# Celery stuff
|
98 |
+
celerybeat-schedule
|
99 |
+
celerybeat.pid
|
100 |
+
|
101 |
+
# SageMath parsed files
|
102 |
+
*.sage.py
|
103 |
+
|
104 |
+
# Environments
|
105 |
+
.env
|
106 |
+
.venv
|
107 |
+
env/
|
108 |
+
venv/
|
109 |
+
ENV/
|
110 |
+
env.bak/
|
111 |
+
venv.bak/
|
112 |
+
|
113 |
+
# Spyder project settings
|
114 |
+
.spyderproject
|
115 |
+
.spyproject
|
116 |
+
|
117 |
+
# Rope project settings
|
118 |
+
.ropeproject
|
119 |
+
|
120 |
+
# mkdocs documentation
|
121 |
+
/site
|
122 |
+
|
123 |
+
# mypy
|
124 |
+
.mypy_cache/
|
125 |
+
.dmypy.json
|
126 |
+
dmypy.json
|
127 |
+
|
128 |
+
# Pyre type checker
|
129 |
+
.pyre/
|
130 |
+
|
131 |
+
# Machine Learning and Speech Libraries
|
132 |
+
# TensorFlow
|
133 |
+
*.ckpt*
|
134 |
+
*.pbtxt
|
135 |
+
*.tfevents*
|
136 |
+
# PyTorch
|
137 |
+
*.pt
|
138 |
+
# Keras
|
139 |
+
*.h5
|
140 |
+
# Scikit-learn
|
141 |
+
*.pkl
|
142 |
+
# Speech Recognition
|
143 |
+
*.wav
|
144 |
+
*.mp3
|
145 |
+
.idea/
|
app.py
CHANGED
@@ -7,6 +7,8 @@ from pydantic import BaseModel
|
|
7 |
from fastapi.middleware.cors import CORSMiddleware
|
8 |
from langchain_community.document_loaders import UnstructuredURLLoader
|
9 |
from src.api.speech_api import speech_translator_router
|
|
|
|
|
10 |
|
11 |
app = FastAPI(title="ConversAI", root_path="/api/v1")
|
12 |
|
@@ -22,15 +24,106 @@ app.include_router(speech_translator_router, prefix="/speech")
|
|
22 |
|
23 |
|
24 |
@app.post("/signup")
|
25 |
-
async def
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
|
30 |
@app.post("/login")
|
31 |
-
async def
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
@app.post("/newChatbot")
|
@@ -180,7 +273,7 @@ async def getCount(vectorstore: str):
|
|
180 |
async def getYTTranscript(urls: str):
|
181 |
return {
|
182 |
"transcript": getTranscript(urls=urls)
|
183 |
-
|
184 |
|
185 |
|
186 |
@app.post("/analyzeData")
|
|
|
7 |
from fastapi.middleware.cors import CORSMiddleware
|
8 |
from langchain_community.document_loaders import UnstructuredURLLoader
|
9 |
from src.api.speech_api import speech_translator_router
|
10 |
+
from functions import client as supabase
|
11 |
+
from fastapi.exception_handlers import HTTPException
|
12 |
|
13 |
app = FastAPI(title="ConversAI", root_path="/api/v1")
|
14 |
|
|
|
24 |
|
25 |
|
26 |
@app.post("/signup")
|
27 |
+
async def sign_up(email, password):
|
28 |
+
try:
|
29 |
+
res, _ = supabase.auth.sign_up(
|
30 |
+
{"email": email, "password": password, "role": "user"}
|
31 |
+
)
|
32 |
+
response = {
|
33 |
+
"status": "success",
|
34 |
+
"code": 200,
|
35 |
+
"message": "Please check you email address for email verification",
|
36 |
+
}
|
37 |
+
|
38 |
+
return response
|
39 |
+
except Exception as e:
|
40 |
+
raise HTTPException(status_code=400, detail="Sign-up failed")
|
41 |
+
|
42 |
+
|
43 |
+
@app.post("/session-check")
|
44 |
+
async def check_session():
|
45 |
+
res = supabase.auth.get_session()
|
46 |
+
|
47 |
+
return res
|
48 |
|
49 |
|
50 |
@app.post("/login")
|
51 |
+
async def sign_in(email, password):
|
52 |
+
try:
|
53 |
+
res = supabase.auth.sign_in_with_password(
|
54 |
+
{"email": email, "password": password}
|
55 |
+
)
|
56 |
+
user_id = res.user.id
|
57 |
+
access_token = res.session.access_token
|
58 |
+
refresh_token = res.session.refresh_token
|
59 |
+
store_session_check = supabase.table("Stores").select("*").filter("StoreID", "eq", user_id).execute()
|
60 |
+
try:
|
61 |
+
store_id = store_session_check[1][0]["StoreID"]
|
62 |
+
except:
|
63 |
+
store_id = None
|
64 |
+
|
65 |
+
if not store_id:
|
66 |
+
|
67 |
+
response, _ = (
|
68 |
+
supabase.table("Stores").insert(
|
69 |
+
{"AccessToken": access_token, "StoreID": user_id, "RefreshToken": refresh_token, }).execute())
|
70 |
+
|
71 |
+
message = {
|
72 |
+
"message": "success",
|
73 |
+
"code": 200,
|
74 |
+
"store_id": user_id,
|
75 |
+
"access_token": access_token,
|
76 |
+
"refresh_token": refresh_token}
|
77 |
+
|
78 |
+
return message
|
79 |
+
|
80 |
+
|
81 |
+
elif store_id == user_id:
|
82 |
+
message = {
|
83 |
+
"message": "You are already signed in please sign out first to sign in again",
|
84 |
+
"code": 400,
|
85 |
+
|
86 |
+
}
|
87 |
+
return message
|
88 |
+
|
89 |
+
else:
|
90 |
+
message = {
|
91 |
+
"message": "failed",
|
92 |
+
"code": 400,
|
93 |
+
"error": "Failed to sign in please check your credentials",
|
94 |
+
}
|
95 |
+
|
96 |
+
return message
|
97 |
+
|
98 |
+
except:
|
99 |
+
message = {
|
100 |
+
"message": "You are already signed in please sign out first to sign in again",
|
101 |
+
"code": 400,
|
102 |
+
"error": "Failed to sign in please check your credentials",
|
103 |
+
}
|
104 |
+
|
105 |
+
return message
|
106 |
+
|
107 |
+
|
108 |
+
@app.post("/set-session-data")
|
109 |
+
async def set_session_data(access_token, refresh_token):
|
110 |
+
res = supabase.auth.set_session(access_token, refresh_token)
|
111 |
+
|
112 |
+
return res
|
113 |
+
|
114 |
+
|
115 |
+
@app.post("/logout")
|
116 |
+
async def sign_out():
|
117 |
+
res = supabase.auth.sign_out()
|
118 |
+
|
119 |
+
return res
|
120 |
+
|
121 |
+
|
122 |
+
@app.post("/oauth")
|
123 |
+
async def oauth(provider):
|
124 |
+
res = supabase.auth.sign_in_with_oauth(provider)
|
125 |
+
|
126 |
+
return res
|
127 |
|
128 |
|
129 |
@app.post("/newChatbot")
|
|
|
273 |
async def getYTTranscript(urls: str):
|
274 |
return {
|
275 |
"transcript": getTranscript(urls=urls)
|
276 |
+
}
|
277 |
|
278 |
|
279 |
@app.post("/analyzeData")
|