Spaces:
Runtime error
Runtime error
resolve conflicts
Browse files- README.md +12 -0
- TechdocsAPI/.gitattributes +35 -0
- TechdocsAPI/Dockerfile +11 -0
- TechdocsAPI/README.md +48 -0
- {backend → TechdocsAPI/backend}/__init__.py +2 -2
- {backend → TechdocsAPI/backend}/core/ConfigEnv.py +0 -0
- {backend → TechdocsAPI/backend}/core/ExceptionHandlers.py +0 -0
- {backend → TechdocsAPI/backend}/core/Exceptions.py +0 -0
- {backend → TechdocsAPI/backend}/core/__init__.py +0 -0
- {backend → TechdocsAPI/backend}/models/__init__.py +0 -0
- {backend → TechdocsAPI/backend}/models/auth.py +0 -0
- {backend → TechdocsAPI/backend}/models/generic.py +0 -0
- {backend → TechdocsAPI/backend}/models/inference.py +0 -0
- {backend → TechdocsAPI/backend}/requirements.txt +3 -1
- {backend → TechdocsAPI/backend}/router.py +0 -2
- {backend → TechdocsAPI/backend}/services/__init__.py +0 -0
- {backend → TechdocsAPI/backend}/services/auth/__init__.py +0 -0
- {backend → TechdocsAPI/backend}/services/auth/ops.py +1 -1
- {backend → TechdocsAPI/backend}/services/auth/utils/JWTBearer.py +0 -0
- {backend → TechdocsAPI/backend}/services/auth/utils/auth_funcs.py +0 -0
- {backend → TechdocsAPI/backend}/services/db/__init__.py +0 -0
- {backend → TechdocsAPI/backend}/services/db/utils/DBQueries.py +0 -0
- {backend → TechdocsAPI/backend}/utils/DBConnection.py +0 -0
- TechdocsAPI/backend/utils/__init__.py +1 -0
- {backend → TechdocsAPI/backend}/utils/prompt.txt +0 -0
- {backend → TechdocsAPI/backend}/utils/scopes.py +0 -0
- backend/vercel.json +0 -4
- frontend/Login.py +23 -22
- frontend/__init__.py +0 -1
- frontend/pages/Code.py +6 -10
- frontend/requirements.txt +1 -0
- frontend/{🏡 Home.py → 🏡_Home.py} +21 -20
- {backend/utils → techdocs}/__init__.py +0 -0
- techdocs/execute.py +28 -0
- techdocs/requirements.txt +1 -0
- techdocs/utils/__init__.py +0 -0
- techdocs/utils/functools.py +43 -0
- techdocs/utils/parse.py +35 -0
README.md
CHANGED
@@ -20,6 +20,7 @@ $ pip install -r requirements.txt
|
|
20 |
$ -- Run backend
|
21 |
$ uvicorn app:app --reload # For running the FastAPI server
|
22 |
$ -- Run frontend
|
|
|
23 |
$ streamlit run app.py # For running the Streamlit App
|
24 |
```
|
25 |
|
@@ -30,6 +31,17 @@ $ streamlit run app.py # For running the Streamlit App
|
|
30 |
- Now, you can paste your code in the `Code` field and click on the `Generate Documentation` button.
|
31 |
- The generated documentation will be displayed in the `Documentation` field.
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
## Tech Stack Used
|
34 |

|
35 |

|
|
|
20 |
$ -- Run backend
|
21 |
$ uvicorn app:app --reload # For running the FastAPI server
|
22 |
$ -- Run frontend
|
23 |
+
$ cd frontend
|
24 |
$ streamlit run app.py # For running the Streamlit App
|
25 |
```
|
26 |
|
|
|
31 |
- Now, you can paste your code in the `Code` field and click on the `Generate Documentation` button.
|
32 |
- The generated documentation will be displayed in the `Documentation` field.
|
33 |
|
34 |
+
|
35 |
+
## Demo and Screenshots
|
36 |
+
##### Demo Screenshot 1
|
37 |
+

|
38 |
+
|
39 |
+
##### Demo Screenshot 2
|
40 |
+

|
41 |
+
|
42 |
+
##### Demo Screenshot 3
|
43 |
+

|
44 |
+
|
45 |
## Tech Stack Used
|
46 |

|
47 |

|
TechdocsAPI/.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
TechdocsAPI/Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11
|
2 |
+
|
3 |
+
WORKDIR /backend
|
4 |
+
|
5 |
+
COPY ./requirements.txt /backend/requirements.txt
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /backend/requirements.txt
|
8 |
+
|
9 |
+
COPY . .
|
10 |
+
|
11 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
TechdocsAPI/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: TechdocsAPI
|
3 |
+
emoji: 🐢
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: green
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
---
|
9 |
+
|
10 |
+
# Techdocs: A code documentation generator
|
11 |
+
|
12 |
+
## Introduction
|
13 |
+
|
14 |
+
**Code Documentation Generation** is a tool that generates documentation for your code. It is a simple tool that can be used by anyone who wants to generate documentation for their code. It leverages the power of **OpenAI GPT-3, Huggingface Transformers, Langchain and Clarifai** to generate documentation for your code.
|
15 |
+
|
16 |
+
To use the application, you need to provide your code as input. The tool will analyze your code and generate documentation for it. The documentation will include comments, descriptions, parameters, return values, examples, and more.
|
17 |
+
|
18 |
+
It is a useful tool for developers who want to document their code without spending too much time and effort. It can help you improve the readability, maintainability, and quality of your code. It can also help you share your code with others more easily.
|
19 |
+
|
20 |
+
## Installation
|
21 |
+
> Download zip or Clone the repository and run the following command in the terminal to install the required packages.
|
22 |
+
|
23 |
+
> We recommend using a virtual environment for the installation.
|
24 |
+
|
25 |
+
```bash
|
26 |
+
$ git clone https://github.com/HemanthSai7/Techdocs
|
27 |
+
$ cd Techdocs
|
28 |
+
$ pip install -r requirements.txt
|
29 |
+
$ -- Run backend
|
30 |
+
$ uvicorn app:app --reload
|
31 |
+
```
|
32 |
+
|
33 |
+
## Tech Stack Used
|
34 |
+

|
35 |
+

|
36 |
+

|
37 |
+

|
38 |
+

|
39 |
+

|
40 |
+

|
41 |
+

|
42 |
+

|
43 |
+
|
44 |
+
## Team Members
|
45 |
+
| Name | Github |
|
46 |
+
| --- | --- |
|
47 |
+
| Mayuresh Agashe | [Mayuresh Agashe](https://github.com/mayureshagashe2105) |
|
48 |
+
| Hemanth Sai Garladinne | [Hemanth Sai Garladinne](https://github.com/HemanthSai7) |
|
{backend → TechdocsAPI/backend}/__init__.py
RENAMED
@@ -7,7 +7,7 @@ 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 |
|
@@ -40,9 +40,9 @@ try:
|
|
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 |
|
|
|
40 |
prompt=prompt,
|
41 |
llm=llm
|
42 |
)
|
|
|
43 |
app.state.llmchain = llmchain
|
44 |
|
45 |
+
|
46 |
except mysql.connector.Error as err:
|
47 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(err))
|
48 |
|
{backend → TechdocsAPI/backend}/core/ConfigEnv.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/core/ExceptionHandlers.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/core/Exceptions.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/core/__init__.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/models/__init__.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/models/auth.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/models/generic.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/models/inference.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/requirements.txt
RENAMED
@@ -1,5 +1,7 @@
|
|
1 |
-
fastapi
|
|
|
2 |
requests
|
|
|
3 |
python-jose[cryptography]
|
4 |
passlib[bcrypt]
|
5 |
mysql-connector-python
|
|
|
1 |
+
fastapi==0.99.1
|
2 |
+
uvicorn
|
3 |
requests
|
4 |
+
pydantic==1.10.12
|
5 |
python-jose[cryptography]
|
6 |
passlib[bcrypt]
|
7 |
mysql-connector-python
|
{backend → TechdocsAPI/backend}/router.py
RENAMED
@@ -64,7 +64,5 @@ async def regenerate_api_key(access_token: str = Depends(JWTBearer())):
|
|
64 |
async def inference(code_block:str, api_key: str,access_token:str=Depends(JWTBearer())):
|
65 |
print("inference")
|
66 |
user_sub=Auth.get_user_credentials(access_token)
|
67 |
-
|
68 |
-
print("after res")
|
69 |
|
70 |
return ops_inference(code_block,api_key,user_sub)
|
|
|
64 |
async def inference(code_block:str, api_key: str,access_token:str=Depends(JWTBearer())):
|
65 |
print("inference")
|
66 |
user_sub=Auth.get_user_credentials(access_token)
|
|
|
|
|
67 |
|
68 |
return ops_inference(code_block,api_key,user_sub)
|
{backend → TechdocsAPI/backend}/services/__init__.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/services/auth/__init__.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/services/auth/ops.py
RENAMED
@@ -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 *
|
@@ -103,6 +102,7 @@ def ops_inference(source_code:str,api_key:str,username:str):
|
|
103 |
llm_response = app.state.llmchain.run({"instruction": source_code_message})
|
104 |
|
105 |
docstring = Inference(docstr=llm_response)
|
|
|
106 |
|
107 |
|
108 |
return docstring
|
|
|
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 *
|
|
|
102 |
llm_response = app.state.llmchain.run({"instruction": source_code_message})
|
103 |
|
104 |
docstring = Inference(docstr=llm_response)
|
105 |
+
print(docstring)
|
106 |
|
107 |
|
108 |
return docstring
|
{backend → TechdocsAPI/backend}/services/auth/utils/JWTBearer.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/services/auth/utils/auth_funcs.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/services/db/__init__.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/services/db/utils/DBQueries.py
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/utils/DBConnection.py
RENAMED
File without changes
|
TechdocsAPI/backend/utils/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
from .DBConnection import DBConnection
|
{backend → TechdocsAPI/backend}/utils/prompt.txt
RENAMED
File without changes
|
{backend → TechdocsAPI/backend}/utils/scopes.py
RENAMED
File without changes
|
backend/vercel.json
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"builds": [{ "src": "__init__.py", "use": "@vercel/python" }],
|
3 |
-
"routes": [{ "src": "/(.*)", "dest": "__init__.py" }]
|
4 |
-
}
|
|
|
|
|
|
|
|
|
|
frontend/Login.py
CHANGED
@@ -6,34 +6,14 @@ import streamlit as st
|
|
6 |
|
7 |
def auth_page():
|
8 |
|
9 |
-
base_url = 'http://
|
10 |
|
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 |
|
|
|
6 |
|
7 |
def auth_page():
|
8 |
|
9 |
+
base_url = 'http://localhost:8000'
|
10 |
|
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/__init__.py
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
|
|
|
|
frontend/pages/Code.py
CHANGED
@@ -4,8 +4,6 @@ from PIL import Image
|
|
4 |
|
5 |
import streamlit as st
|
6 |
from Login import auth_page
|
7 |
-
# frontend.Login import auth_pageom from streamlit_extras import
|
8 |
-
|
9 |
|
10 |
st.set_page_config(
|
11 |
page_title="Welcome",
|
@@ -14,7 +12,7 @@ st.set_page_config(
|
|
14 |
initial_sidebar_state="expanded",
|
15 |
)
|
16 |
|
17 |
-
st.write("#
|
18 |
|
19 |
def logout():
|
20 |
del st.session_state["access_token"]
|
@@ -58,20 +56,18 @@ def code_page():
|
|
58 |
|
59 |
headers={"accept":"application/json"}
|
60 |
|
61 |
-
|
62 |
API_KEY = st.text_input(label="Enter your API key", label_visibility="hidden",placeholder="Enter your API key", type="password")
|
63 |
-
st.
|
64 |
-
st.write("Enter your code and click 'Generate Comment' to get the corresponding comment.")
|
65 |
|
66 |
-
code_input = st.text_area("Code Input", height=
|
67 |
comment_placeholder = st.empty()
|
68 |
|
69 |
-
if st.button("Generate
|
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
|
|
|
4 |
|
5 |
import streamlit as st
|
6 |
from Login import auth_page
|
|
|
|
|
7 |
|
8 |
st.set_page_config(
|
9 |
page_title="Welcome",
|
|
|
12 |
initial_sidebar_state="expanded",
|
13 |
)
|
14 |
|
15 |
+
st.write("# Welcome to Techdocs: Where Code Meets Clarity! 🚀")
|
16 |
|
17 |
def logout():
|
18 |
del st.session_state["access_token"]
|
|
|
56 |
|
57 |
headers={"accept":"application/json"}
|
58 |
|
59 |
+
st.subheader("Enter your API key to generate documentation.")
|
60 |
API_KEY = st.text_input(label="Enter your API key", label_visibility="hidden",placeholder="Enter your API key", type="password")
|
61 |
+
st.subheader("Enter your code and click 'Generate Documentation' to get the corresponding comment.")
|
|
|
62 |
|
63 |
+
code_input = st.text_area("Code Input", height=300)
|
64 |
comment_placeholder = st.empty()
|
65 |
|
66 |
+
if st.button("Generate Documentation"):
|
67 |
if code_input:
|
68 |
headers['Authorization'] = f"Bearer {st.session_state.access_token}"
|
69 |
+
response = query_post(base_url + '/api/inference', headers=headers, params={'code_block':code_input, 'api_key':API_KEY})
|
70 |
docstr = response.json()["docstr"]
|
|
|
71 |
comment_placeholder.subheader("Generated Comment:")
|
72 |
comment_placeholder.markdown(f"<pre><code>{docstr}</code></pre>", unsafe_allow_html=True)
|
73 |
# Scroll to the comment section
|
frontend/requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
streamlit
|
frontend/{🏡 Home.py → 🏡_Home.py}
RENAMED
@@ -1,12 +1,13 @@
|
|
1 |
import streamlit as st
|
2 |
from Login import auth_page
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
import base64
|
6 |
|
7 |
# image2=Image.open('assets/logo2.png')
|
8 |
st.set_page_config(
|
9 |
-
page_title="
|
10 |
layout="wide",
|
11 |
page_icon="🏡",
|
12 |
initial_sidebar_state="expanded",
|
@@ -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"]
|
@@ -56,29 +53,33 @@ def home_page():
|
|
56 |
'''
|
57 |
st.markdown(page_bg_img, unsafe_allow_html=True)
|
58 |
|
59 |
-
set_page_background("../assets/bg.jpg")
|
60 |
|
61 |
st.markdown(
|
62 |
"""
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
The process is quite straightforward. BOB offers loans to eligible applicants with strong financial profiles.
|
67 |
-
Individuals need to provide their basic personal, employment, income and property details to know if you are fit to apply for a loan.
|
68 |
|
69 |
-
### 1 . Login
|
70 |
|
71 |
-
Step one is the login part, you just have to work your way through the following simple steps.
|
72 |
-
- Enter your mobile number
|
73 |
-
- Enter the OTP recieved
|
74 |
-
- accept consent in the Safe portal
|
75 |
|
76 |
-
### 2. Loan page
|
77 |
|
78 |
-
Once you login, you will be redirected to the loan page.
|
79 |
-
- Offer all relevant details such as loan amount, loan history, income, etc.
|
80 |
-
- Click on the submit option once you have filled in all the details.
|
81 |
-
- Our algorithm will assess your eligibility based on the details provided by you and you will be awarded with a `yes` or a `no`.
|
82 |
"""
|
83 |
)
|
84 |
|
|
|
1 |
import streamlit as st
|
2 |
from Login import auth_page
|
3 |
from PIL import Image
|
4 |
+
import textwrap
|
5 |
|
6 |
import base64
|
7 |
|
8 |
# image2=Image.open('assets/logo2.png')
|
9 |
st.set_page_config(
|
10 |
+
page_title="Techdocs",
|
11 |
layout="wide",
|
12 |
page_icon="🏡",
|
13 |
initial_sidebar_state="expanded",
|
|
|
19 |
data = f.read()
|
20 |
return base64.b64encode(data).decode()
|
21 |
|
22 |
+
st.markdown("# Welcome to Techdocs: Where Code Meets Clarity! 🚀")
|
|
|
|
|
|
|
|
|
23 |
|
24 |
def logout():
|
25 |
del st.session_state["access_token"]
|
|
|
53 |
'''
|
54 |
st.markdown(page_bg_img, unsafe_allow_html=True)
|
55 |
|
56 |
+
# set_page_background("../assets/bg.jpg")
|
57 |
|
58 |
st.markdown(
|
59 |
"""
|
60 |
|
61 |
+
##### Unleash the documentation dynamo that is **Techdocs**! Say goodbye to the documentation drudgery that haunts coders' dreams and embrace the effortless power of AI-driven documentation. With **Techdocs**, harness the genius of OpenAI's GPT-3, the magic of WizardCoderLM, the versatility of Huggingface Transformers, and the precision of Langchain and Clarifai.
|
62 |
+
|
63 |
+
## How Does Techdocs Work Its Magic? 🔮
|
64 |
+
|
65 |
+
##### Just feed your code into **Techdocs**, and like a seasoned wizard, it'll conjure up beautifully detailed documentation in an instant. Your code will transform into a masterpiece of clarity, complete with insightful comments, vivid descriptions, crystal-clear parameters, return values, and real-world examples.
|
66 |
+
|
67 |
+
## What Can Techdocs Do for You? 🌟
|
68 |
+
|
69 |
+
- ##### Boost your code quality effortlessly.
|
70 |
+
- ##### Share your brilliance with the world in a snap.
|
71 |
+
- ##### Effortlessly generate documentation for your code.
|
72 |
+
- ##### Include comments, descriptions, parameters, return values, and real-life examples.
|
73 |
+
- ##### Elevate your code's readability, maintainability, and quality.
|
74 |
+
|
75 |
+
##### **Techdocs** is your code's trusty companion, helping you document with ease so you can focus on what you do best: coding!. **Techdocs** is your secret weapon for leveling up your code game. Whether you're a seasoned developer or just starting your coding journey, Techdocs has got your back. Get ready to unlock the future of code documentation today! 🌟
|
76 |
+
|
77 |
+
|
78 |
|
|
|
|
|
79 |
|
|
|
80 |
|
|
|
|
|
|
|
|
|
81 |
|
|
|
82 |
|
|
|
|
|
|
|
|
|
83 |
"""
|
84 |
)
|
85 |
|
{backend/utils → techdocs}/__init__.py
RENAMED
File without changes
|
techdocs/execute.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from utils import parse,functools
|
2 |
+
|
3 |
+
import argparse
|
4 |
+
|
5 |
+
def main():
|
6 |
+
parser = argparse.ArgumentParser(description='Weather Application')
|
7 |
+
parser.add_argument('--api_key','-k',help='API key for Techdocs')
|
8 |
+
parser.add_argument('--username','-u',help='Username for Techdocs')
|
9 |
+
parser.add_argument('--password','-p',help='Password for Techdocs')
|
10 |
+
parser.add_argument('--dir','-d',help='Root directory to be documented')
|
11 |
+
|
12 |
+
args=parser.parse_args()
|
13 |
+
|
14 |
+
config = {
|
15 |
+
arg[0]:arg[1] for arg in args._get_kwargs()
|
16 |
+
}
|
17 |
+
|
18 |
+
data = {
|
19 |
+
"username":config['username'],
|
20 |
+
"password":config['password']
|
21 |
+
}
|
22 |
+
|
23 |
+
config.update({"access_token":functools.get_access_token(data)})
|
24 |
+
|
25 |
+
parse.extract_functions_from_directory(config)
|
26 |
+
|
27 |
+
if __name__ == '__main__':
|
28 |
+
main()
|
techdocs/requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
tqdm
|
techdocs/utils/__init__.py
ADDED
File without changes
|
techdocs/utils/functools.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import requests
|
3 |
+
|
4 |
+
BASE_URL = "http://localhost:8000"
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
def get_access_token(data, return_refresh_token=False):
|
9 |
+
url = BASE_URL + "/auth/login"
|
10 |
+
headers = {
|
11 |
+
"accept": "application/json",
|
12 |
+
}
|
13 |
+
data = json.dumps(data)
|
14 |
+
response = requests.post(url, data=data, headers=headers)
|
15 |
+
access_token = response.json()['access_token']
|
16 |
+
if return_refresh_token:
|
17 |
+
refresh_token = response.json()['refresh_token']
|
18 |
+
return access_token, refresh_token
|
19 |
+
return access_token
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
def request_inference(config, code_block, max_retries=1):
|
25 |
+
|
26 |
+
if max_retries == 0:
|
27 |
+
return ""
|
28 |
+
|
29 |
+
url = BASE_URL+"/api/inference"
|
30 |
+
headers={"accept":"application/json", "Authorization": f"Bearer {config['access_token']}"}
|
31 |
+
code_input = code_block
|
32 |
+
response = requests.post(url=url, headers=headers, params={'code_block':code_input, 'api_key':config['api_key']})
|
33 |
+
if response.status_code == 200:
|
34 |
+
return response.json()["docstr"]
|
35 |
+
else:
|
36 |
+
data = {
|
37 |
+
"username":config['username'],
|
38 |
+
"password":config['password']
|
39 |
+
}
|
40 |
+
print("Encountered error retrying...")
|
41 |
+
config.update({"access_token":get_access_token(data)})
|
42 |
+
|
43 |
+
return request_inference(config,config["access_token"], code_block, max_retries=max_retries-1)
|
techdocs/utils/parse.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import ast
|
2 |
+
import os
|
3 |
+
from tqdm import tqdm
|
4 |
+
import requests
|
5 |
+
|
6 |
+
from utils.functools import *
|
7 |
+
|
8 |
+
|
9 |
+
# Function to extract and print the outermost nested function with line number
|
10 |
+
def extract_outermost_function(node, config, line_number=1,):
|
11 |
+
base_url = "http://localhost:8000"
|
12 |
+
if isinstance(node, ast.FunctionDef):
|
13 |
+
function_def = ast.unparse(node)
|
14 |
+
print(f"Function starting at line {line_number}:\n{function_def}")
|
15 |
+
print("=" * 30)
|
16 |
+
|
17 |
+
response = request_inference(config=config,code_block=function_def)
|
18 |
+
|
19 |
+
|
20 |
+
for child in ast.iter_child_nodes(node):
|
21 |
+
if isinstance(child, ast.FunctionDef):
|
22 |
+
line_number = child.lineno
|
23 |
+
extract_outermost_function(child, line_number)
|
24 |
+
|
25 |
+
# Function to traverse directories recursively and extract functions from Python files
|
26 |
+
def extract_functions_from_directory(config):
|
27 |
+
for root, _, files in os.walk(config["dir"]):
|
28 |
+
for file in files:
|
29 |
+
if file.endswith(".py"):
|
30 |
+
file_path = os.path.join(root, file)
|
31 |
+
print(file_path)
|
32 |
+
with open(file_path, "r",errors='ignore') as file:
|
33 |
+
content = file.read()
|
34 |
+
parsed = ast.parse(content)
|
35 |
+
extract_outermost_function(parsed, config)
|