Spaces:
Runtime error
Runtime error
G.Hemanth Sai
commited on
Commit
Β·
44df0dd
1
Parent(s):
e1a2c1d
Updated Streamlit frontend
Browse files- backend/__init__.py +10 -1
- backend/services/auth/ops.py +0 -1
- backend/utils/__init__.py +1 -0
- frontend/Login.py +22 -21
- frontend/pages/Code.py +1 -2
- frontend/π‘ Home.py +2 -5
backend/__init__.py
CHANGED
@@ -7,15 +7,18 @@ from fastapi.exceptions import HTTPException
|
|
7 |
from backend.utils import DBConnection
|
8 |
from backend.core.ConfigEnv import config
|
9 |
|
10 |
-
from langchain.llms import
|
11 |
from langchain.chains import LLMChain
|
12 |
from langchain.prompts import PromptTemplate
|
13 |
|
|
|
|
|
14 |
app = FastAPI(title="Techdocs",
|
15 |
version="V0.0.1",
|
16 |
description="API for automatic code documentation generation!"
|
17 |
)
|
18 |
|
|
|
19 |
from backend import router
|
20 |
|
21 |
try:
|
@@ -36,13 +39,19 @@ try:
|
|
36 |
model_version_id=config.MODEL_VERSION_ID,
|
37 |
)
|
38 |
|
|
|
|
|
39 |
llmchain = LLMChain(
|
40 |
prompt=prompt,
|
41 |
llm=llm
|
42 |
)
|
43 |
|
|
|
|
|
44 |
app.state.llmchain = llmchain
|
45 |
|
|
|
|
|
46 |
except mysql.connector.Error as err:
|
47 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(err))
|
48 |
|
|
|
7 |
from backend.utils import DBConnection
|
8 |
from backend.core.ConfigEnv import config
|
9 |
|
10 |
+
from langchain.llms import Clarifai
|
11 |
from langchain.chains import LLMChain
|
12 |
from langchain.prompts import PromptTemplate
|
13 |
|
14 |
+
import sys
|
15 |
+
|
16 |
app = FastAPI(title="Techdocs",
|
17 |
version="V0.0.1",
|
18 |
description="API for automatic code documentation generation!"
|
19 |
)
|
20 |
|
21 |
+
print(sys.getsizeof(app))
|
22 |
from backend import router
|
23 |
|
24 |
try:
|
|
|
39 |
model_version_id=config.MODEL_VERSION_ID,
|
40 |
)
|
41 |
|
42 |
+
print(sys.getsizeof(llm))
|
43 |
+
|
44 |
llmchain = LLMChain(
|
45 |
prompt=prompt,
|
46 |
llm=llm
|
47 |
)
|
48 |
|
49 |
+
print(sys.getsizeof(llmchain))
|
50 |
+
|
51 |
app.state.llmchain = llmchain
|
52 |
|
53 |
+
print(sys.getsizeof(app))
|
54 |
+
|
55 |
except mysql.connector.Error as err:
|
56 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(err))
|
57 |
|
backend/services/auth/ops.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from .utils.auth_funcs import *
|
2 |
from .utils.JWTBearer import *
|
3 |
-
from backend.services import parser
|
4 |
from backend.models import *
|
5 |
from backend.services.db.utils.DBQueries import DBQueries
|
6 |
from backend.core.Exceptions import *
|
|
|
1 |
from .utils.auth_funcs import *
|
2 |
from .utils.JWTBearer import *
|
|
|
3 |
from backend.models import *
|
4 |
from backend.services.db.utils.DBQueries import DBQueries
|
5 |
from backend.core.Exceptions import *
|
backend/utils/__init__.py
CHANGED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
from .DBConnection import DBConnection
|
frontend/Login.py
CHANGED
@@ -11,29 +11,9 @@ def auth_page():
|
|
11 |
|
12 |
headers={"accept":"application/json"}
|
13 |
|
14 |
-
tab1, tab2 = st.tabs(["
|
15 |
|
16 |
with tab1:
|
17 |
-
with st.form(key="myform1"):
|
18 |
-
username = st.text_input(label="Username", label_visibility="collapsed", placeholder="Username")
|
19 |
-
password = st.text_input(label="Password", label_visibility="collapsed", placeholder="Password", type="password")
|
20 |
-
email = st.text_input(label="Email", label_visibility="collapsed", placeholder="Email")
|
21 |
-
signup_button = st.form_submit_button(label="Signup")
|
22 |
-
|
23 |
-
with st.spinner("Signing up..."):
|
24 |
-
if signup_button:
|
25 |
-
try:
|
26 |
-
credentials = {"username":username, "password":password, "email":email}
|
27 |
-
response = requests.post(url=base_url + "/auth/signup", headers=headers, data=json.dumps(credentials))
|
28 |
-
if (response.status_code!=200):
|
29 |
-
raise Exception("Signup Failed")
|
30 |
-
|
31 |
-
st.success("Signed up successfully")
|
32 |
-
except:
|
33 |
-
st.error("Signup Failed")
|
34 |
-
|
35 |
-
|
36 |
-
with tab2:
|
37 |
with st.form(key="myform2"):
|
38 |
username = st.text_input(label="Username", label_visibility="collapsed", placeholder="Username")
|
39 |
password = st.text_input(label="Password", label_visibility="collapsed", placeholder="Password", type="password")
|
@@ -56,4 +36,25 @@ def auth_page():
|
|
56 |
except Exception as e:
|
57 |
st.error(e)
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
|
|
11 |
|
12 |
headers={"accept":"application/json"}
|
13 |
|
14 |
+
tab1, tab2 = st.tabs(["Login", "Signup"])
|
15 |
|
16 |
with tab1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
with st.form(key="myform2"):
|
18 |
username = st.text_input(label="Username", label_visibility="collapsed", placeholder="Username")
|
19 |
password = st.text_input(label="Password", label_visibility="collapsed", placeholder="Password", type="password")
|
|
|
36 |
except Exception as e:
|
37 |
st.error(e)
|
38 |
|
39 |
+
with tab2:
|
40 |
+
with st.form(key="myform1"):
|
41 |
+
username = st.text_input(label="Username", label_visibility="collapsed", placeholder="Username")
|
42 |
+
password = st.text_input(label="Password", label_visibility="collapsed", placeholder="Password", type="password")
|
43 |
+
email = st.text_input(label="Email", label_visibility="collapsed", placeholder="Email")
|
44 |
+
signup_button = st.form_submit_button(label="Signup")
|
45 |
+
|
46 |
+
with st.spinner("Signing up..."):
|
47 |
+
if signup_button:
|
48 |
+
try:
|
49 |
+
credentials = {"username":username, "password":password, "email":email}
|
50 |
+
response = requests.post(url=base_url + "/auth/signup", headers=headers, data=json.dumps(credentials))
|
51 |
+
if (response.status_code!=200):
|
52 |
+
raise Exception("Signup Failed")
|
53 |
+
|
54 |
+
st.success("Signed up successfully")
|
55 |
+
except:
|
56 |
+
st.error("Signup Failed")
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
|
frontend/pages/Code.py
CHANGED
@@ -69,9 +69,8 @@ def code_page():
|
|
69 |
if st.button("Generate Comment"):
|
70 |
if code_input:
|
71 |
headers['Authorization'] = f"Bearer {st.session_state.access_token}"
|
72 |
-
response = query_post(base_url + '/api/inference', headers=headers, params={'code_block':
|
73 |
docstr = response.json()["docstr"]
|
74 |
-
print(docstr)
|
75 |
comment_placeholder.subheader("Generated Comment:")
|
76 |
comment_placeholder.markdown(f"<pre><code>{docstr}</code></pre>", unsafe_allow_html=True)
|
77 |
# Scroll to the comment section
|
|
|
69 |
if st.button("Generate Comment"):
|
70 |
if code_input:
|
71 |
headers['Authorization'] = f"Bearer {st.session_state.access_token}"
|
72 |
+
response = query_post(base_url + '/api/inference', headers=headers, params={'code_block':code_input, 'api_key':API_KEY})
|
73 |
docstr = response.json()["docstr"]
|
|
|
74 |
comment_placeholder.subheader("Generated Comment:")
|
75 |
comment_placeholder.markdown(f"<pre><code>{docstr}</code></pre>", unsafe_allow_html=True)
|
76 |
# Scroll to the comment section
|
frontend/π‘ Home.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from Login import auth_page
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
import base64
|
6 |
|
@@ -18,11 +19,7 @@ def get_base64_bin_file(bin_file):
|
|
18 |
data = f.read()
|
19 |
return base64.b64encode(data).decode()
|
20 |
|
21 |
-
|
22 |
-
# image = Image.open('assets/poster.jpg')
|
23 |
-
# st.image(image, caption='ELIGILOAN')
|
24 |
-
|
25 |
-
st.markdown("# :DocGup-tea: AI based Documentation Generator π")
|
26 |
|
27 |
def logout():
|
28 |
del st.session_state["access_token"]
|
|
|
1 |
import streamlit as st
|
2 |
from Login import auth_page
|
3 |
from PIL import Image
|
4 |
+
import textwrap
|
5 |
|
6 |
import base64
|
7 |
|
|
|
19 |
data = f.read()
|
20 |
return base64.b64encode(data).decode()
|
21 |
|
22 |
+
st.markdown("# DocGup-tea: AI based Documentation Generator π")
|
|
|
|
|
|
|
|
|
23 |
|
24 |
def logout():
|
25 |
del st.session_state["access_token"]
|