Spaces:
Running
Running
acecalisto3
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import streamlit as st
|
3 |
+
import os
|
4 |
+
|
5 |
+
# Import components and pages
|
6 |
+
from components import home, refactor_page, style_page, test_page, \
|
7 |
+
lang_page, code_documentation_page, database_page, optimize_page, \
|
8 |
+
model_trainer_page, notebook_integration_page, xai_page, \
|
9 |
+
versioning_tracker_page, nlp_nlg_page, devops_page, api_doc_page, \
|
10 |
+
code_review_page, version_control_page, recommendation_system_page, \
|
11 |
+
code_security_scanner_page, code_diagram_page
|
12 |
+
|
13 |
+
# Initialize the app
|
14 |
+
st.set_page_config(
|
15 |
+
page_title="Codecrafter GPT: A Comprehensive Code Enhancement Platform",
|
16 |
+
page_icon="🚀",
|
17 |
+
layout="wide"
|
18 |
+
)
|
19 |
+
|
20 |
+
# Initialize the sidebar
|
21 |
+
st.sidebar.title("OpenAI API Key")
|
22 |
+
api_key = st.sidebar.text_input("Enter your OpenAI API key:", type='password')
|
23 |
+
|
24 |
+
if not api_key:
|
25 |
+
st.warning("Please enter your OpenAI API key to access pages.")
|
26 |
+
else:
|
27 |
+
# Instantiate the ChatOpenAI object
|
28 |
+
from langchain.chat_models import ChatOpenAI
|
29 |
+
chat = ChatOpenAI(
|
30 |
+
model="gpt-3.5-turbo-16k",
|
31 |
+
temperature=0,
|
32 |
+
api_key=api_key
|
33 |
+
)
|
34 |
+
|
35 |
+
# Show the navigation menu
|
36 |
+
selected = option_menu(
|
37 |
+
menu_title="CodeCraftGPT",
|
38 |
+
options=[
|
39 |
+
"Home", "RefactorRite", "StyleSculpt",
|
40 |
+
"TestGenius", "LangLink", "CodeDocGenius", "Database", "AutoOptimizer",
|
41 |
+
"ModelTrainer", "NotebookIntegration", "ExplainableAI", "DataVersioning",
|
42 |
+
"NLPandNLG", "DevOps", "APIDocGen", "CodeReviewAssistant",
|
43 |
+
"VersionControl", "RecommendationSystem", "CodeSecurityScanner",
|
44 |
+
"CodeDiagramConverter"
|
45 |
+
],
|
46 |
+
icons=[
|
47 |
+
'house', 'gear', 'palette', 'clipboard2-pulse',
|
48 |
+
'code-slash', 'file-text', 'database', 'diagram-3',
|
49 |
+
'diagram-project', 'diagram-3', 'diagram-3', 'diagram-3',
|
50 |
+
'diagram-3', 'gear', 'file-text', 'file-code',
|
51 |
+
'screwdriver-wrench', 'file-text', 'diagram-3', 'diagram-3',
|
52 |
+
'code-fork'
|
53 |
+
],
|
54 |
+
default_index=0
|
55 |
+
)
|
56 |
+
|
57 |
+
# Define a dictionary mapping page names to their corresponding functions
|
58 |
+
pages = {
|
59 |
+
"Home": home.show_home_page,
|
60 |
+
"RefactorRite": refactor_page.show_refactor_page,
|
61 |
+
"StyleSculpt": style_page.show_style_page,
|
62 |
+
"TestGenius": test_page.show_test_page,
|
63 |
+
"LangLink": lang_page.show_lang_page,
|
64 |
+
"CodeDocGenius": code_documentation_page.show_doc_page,
|
65 |
+
"Database": database_page.show_database_page,
|
66 |
+
"AutoOptimizer": optimize_page.show_optimize_page,
|
67 |
+
"ModelTrainer": model_trainer_page.show_model_trainer_page,
|
68 |
+
"NotebookIntegration": notebook_integration_page.show_notebook_integration_page,
|
69 |
+
"ExplainableAI": xai_page.show_xai_page,
|
70 |
+
"DataVersioning": versioning_tracker_page.show_versioning_page,
|
71 |
+
"NLPandNLG": nlp_nlg_page.show_nlp_nlg_page,
|
72 |
+
"DevOps": devops_page.show_devops_page,
|
73 |
+
"APIDocGen": api_doc_page.show_api_doc_page,
|
74 |
+
"CodeReviewAssistant": code_review_page.show_code_review_page,
|
75 |
+
"VersionControl": version_control_page.show_version_control_page,
|
76 |
+
"RecommendationSystem": recommendation_system_page.show_recommendation_system_page,
|
77 |
+
"CodeSecurityScanner": code_security_scanner_page.show_code_security_page,
|
78 |
+
"CodeDiagramConverter": code_diagram_page.show_code_diagram_page
|
79 |
+
}
|
80 |
+
|
81 |
+
# Call the function for the selected page
|
82 |
+
if selected in pages:
|
83 |
+
pages[selected](chat)
|
84 |
+
else:
|
85 |
+
st.error("Page not found!")
|