Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,8 +13,8 @@ except Exception as e:
|
|
| 13 |
st.error(f"Unable to load secrets: {str(e)}")
|
| 14 |
raise
|
| 15 |
|
| 16 |
-
PROJECT_ROOT = "
|
| 17 |
-
AGENT_DIRECTORY = "
|
| 18 |
AVAILABLE_CODE_GENERATIVE_MODELS = ["bigcode/starcoder", "Salesforce/codegen-350M-mono", "microsoft/CodeGPT-small"]
|
| 19 |
|
| 20 |
# Global state to manage communication between Tool Box and Workspace Chat App
|
|
@@ -42,7 +42,6 @@ class AIAgent:
|
|
| 42 |
agent_prompt = f"""
|
| 43 |
As an elite expert developer, my name is {self.name}. I possess a comprehensive understanding of the following areas:
|
| 44 |
{skills_str}
|
| 45 |
-
|
| 46 |
I am confident that I can leverage my expertise to assist you in developing and deploying cutting-edge web applications. Please feel free to ask any questions or present any challenges you may encounter.
|
| 47 |
"""
|
| 48 |
return agent_prompt
|
|
@@ -55,13 +54,6 @@ I am confident that I can leverage my expertise to assist you in developing and
|
|
| 55 |
|
| 56 |
def deploy_built_space_to_hf(self):
|
| 57 |
# Implement logic to deploy the built space to Hugging Face Spaces
|
| 58 |
-
# This could involve creating a new Space, uploading files, and configuring the Space
|
| 59 |
-
# Use the HfApi to interact with the Hugging Face API
|
| 60 |
-
# Example:
|
| 61 |
-
# repository = self._hf_api.create_repo(repo_id="my-new-space", private=False)
|
| 62 |
-
# ... upload files to the repository
|
| 63 |
-
# ... configure the Space
|
| 64 |
-
# return repository
|
| 65 |
pass
|
| 66 |
|
| 67 |
def has_valid_hf_token(self):
|
|
@@ -134,7 +126,7 @@ if __name__ == "__main__":
|
|
| 134 |
st.sidebar.subheader("Terminal")
|
| 135 |
command = st.sidebar.text_input("Enter a command:")
|
| 136 |
if command:
|
| 137 |
-
output, error =
|
| 138 |
if error:
|
| 139 |
st.sidebar.error(f"Error executing command: {error}")
|
| 140 |
else:
|
|
@@ -184,7 +176,7 @@ if __name__ == "__main__":
|
|
| 184 |
st.write(next_step)
|
| 185 |
if agent._hf_api and agent.has_valid_hf_token():
|
| 186 |
repository = agent.deploy_built_space_to_hf()
|
| 187 |
-
st.markdown("## Congratulations! Successfully deployed Space
|
| 188 |
st.markdown("[Check out your new Space here](hf.co/" + repository.name + ")")
|
| 189 |
|
| 190 |
# CSS for styling
|
|
@@ -198,17 +190,14 @@ if __name__ == "__main__":
|
|
| 198 |
margin: 0;
|
| 199 |
padding: 0;
|
| 200 |
}
|
| 201 |
-
|
| 202 |
h1, h2, h3, h4, h5, h6 {
|
| 203 |
color: #333;
|
| 204 |
}
|
| 205 |
-
|
| 206 |
.container {
|
| 207 |
width: 90%;
|
| 208 |
margin: 0 auto;
|
| 209 |
padding: 20px;
|
| 210 |
}
|
| 211 |
-
|
| 212 |
/* Navigation Sidebar */
|
| 213 |
.sidebar {
|
| 214 |
background-color: #2c3e50;
|
|
@@ -221,25 +210,21 @@ if __name__ == "__main__":
|
|
| 221 |
width: 250px;
|
| 222 |
overflow-y: auto;
|
| 223 |
}
|
| 224 |
-
|
| 225 |
.sidebar a {
|
| 226 |
color: #ecf0f1;
|
| 227 |
text-decoration: none;
|
| 228 |
display: block;
|
| 229 |
padding: 10px 0;
|
| 230 |
}
|
| 231 |
-
|
| 232 |
.sidebar a:hover {
|
| 233 |
background-color: #34495e;
|
| 234 |
border-radius: 5px;
|
| 235 |
}
|
| 236 |
-
|
| 237 |
/* Main Content */
|
| 238 |
.main-content {
|
| 239 |
margin-left: 270px;
|
| 240 |
padding: 20px;
|
| 241 |
}
|
| 242 |
-
|
| 243 |
/* Buttons */
|
| 244 |
button {
|
| 245 |
background-color: #3498db;
|
|
@@ -250,11 +235,9 @@ if __name__ == "__main__":
|
|
| 250 |
cursor: pointer;
|
| 251 |
font-size: 16px;
|
| 252 |
}
|
| 253 |
-
|
| 254 |
button:hover {
|
| 255 |
background-color: #2980b9;
|
| 256 |
}
|
| 257 |
-
|
| 258 |
/* Text Areas and Inputs */
|
| 259 |
textarea, input[type="text"] {
|
| 260 |
width: 100%;
|
|
@@ -264,12 +247,10 @@ if __name__ == "__main__":
|
|
| 264 |
border-radius: 5px;
|
| 265 |
box-sizing: border-box;
|
| 266 |
}
|
| 267 |
-
|
| 268 |
textarea:focus, input[type="text"]:focus {
|
| 269 |
border-color: #3498db;
|
| 270 |
outline: none;
|
| 271 |
}
|
| 272 |
-
|
| 273 |
/* Terminal Output */
|
| 274 |
.code-output {
|
| 275 |
background-color: #1e1e1e;
|
|
@@ -278,7 +259,6 @@ if __name__ == "__main__":
|
|
| 278 |
border-radius: 5px;
|
| 279 |
font-family: 'Courier New', Courier, monospace;
|
| 280 |
}
|
| 281 |
-
|
| 282 |
/* Chat History */
|
| 283 |
.chat-history {
|
| 284 |
background-color: #ecf0f1;
|
|
@@ -287,21 +267,17 @@ if __name__ == "__main__":
|
|
| 287 |
max-height: 300px;
|
| 288 |
overflow-y: auto;
|
| 289 |
}
|
| 290 |
-
|
| 291 |
.chat-message {
|
| 292 |
margin-bottom: 10px;
|
| 293 |
}
|
| 294 |
-
|
| 295 |
.chat-message.user {
|
| 296 |
text-align: right;
|
| 297 |
color: #3498db;
|
| 298 |
}
|
| 299 |
-
|
| 300 |
.chat-message.agent {
|
| 301 |
text-align: left;
|
| 302 |
color: #e74c3c;
|
| 303 |
}
|
| 304 |
-
|
| 305 |
/* Project Management */
|
| 306 |
.project-list {
|
| 307 |
background-color: #ecf0f1;
|
|
@@ -310,18 +286,15 @@ if __name__ == "__main__":
|
|
| 310 |
max-height: 300px;
|
| 311 |
overflow-y: auto;
|
| 312 |
}
|
| 313 |
-
|
| 314 |
.project-item {
|
| 315 |
margin-bottom: 10px;
|
| 316 |
}
|
| 317 |
-
|
| 318 |
.project-item a {
|
| 319 |
color: #3498db;
|
| 320 |
text-decoration: none;
|
| 321 |
}
|
| 322 |
-
|
| 323 |
.project-item a:hover {
|
| 324 |
text-decoration: underline;
|
| 325 |
}
|
| 326 |
</style>
|
| 327 |
-
""", unsafe_allow_html=True)
|
|
|
|
| 13 |
st.error(f"Unable to load secrets: {str(e)}")
|
| 14 |
raise
|
| 15 |
|
| 16 |
+
PROJECT_ROOT = "projects"
|
| 17 |
+
AGENT_DIRECTORY = "agents"
|
| 18 |
AVAILABLE_CODE_GENERATIVE_MODELS = ["bigcode/starcoder", "Salesforce/codegen-350M-mono", "microsoft/CodeGPT-small"]
|
| 19 |
|
| 20 |
# Global state to manage communication between Tool Box and Workspace Chat App
|
|
|
|
| 42 |
agent_prompt = f"""
|
| 43 |
As an elite expert developer, my name is {self.name}. I possess a comprehensive understanding of the following areas:
|
| 44 |
{skills_str}
|
|
|
|
| 45 |
I am confident that I can leverage my expertise to assist you in developing and deploying cutting-edge web applications. Please feel free to ask any questions or present any challenges you may encounter.
|
| 46 |
"""
|
| 47 |
return agent_prompt
|
|
|
|
| 54 |
|
| 55 |
def deploy_built_space_to_hf(self):
|
| 56 |
# Implement logic to deploy the built space to Hugging Face Spaces
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
pass
|
| 58 |
|
| 59 |
def has_valid_hf_token(self):
|
|
|
|
| 126 |
st.sidebar.subheader("Terminal")
|
| 127 |
command = st.sidebar.text_input("Enter a command:")
|
| 128 |
if command:
|
| 129 |
+
output, error = run_code(command)
|
| 130 |
if error:
|
| 131 |
st.sidebar.error(f"Error executing command: {error}")
|
| 132 |
else:
|
|
|
|
| 176 |
st.write(next_step)
|
| 177 |
if agent._hf_api and agent.has_valid_hf_token():
|
| 178 |
repository = agent.deploy_built_space_to_hf()
|
| 179 |
+
st.markdown("## Congratulations! Successfully deployed Space �� ##")
|
| 180 |
st.markdown("[Check out your new Space here](hf.co/" + repository.name + ")")
|
| 181 |
|
| 182 |
# CSS for styling
|
|
|
|
| 190 |
margin: 0;
|
| 191 |
padding: 0;
|
| 192 |
}
|
|
|
|
| 193 |
h1, h2, h3, h4, h5, h6 {
|
| 194 |
color: #333;
|
| 195 |
}
|
|
|
|
| 196 |
.container {
|
| 197 |
width: 90%;
|
| 198 |
margin: 0 auto;
|
| 199 |
padding: 20px;
|
| 200 |
}
|
|
|
|
| 201 |
/* Navigation Sidebar */
|
| 202 |
.sidebar {
|
| 203 |
background-color: #2c3e50;
|
|
|
|
| 210 |
width: 250px;
|
| 211 |
overflow-y: auto;
|
| 212 |
}
|
|
|
|
| 213 |
.sidebar a {
|
| 214 |
color: #ecf0f1;
|
| 215 |
text-decoration: none;
|
| 216 |
display: block;
|
| 217 |
padding: 10px 0;
|
| 218 |
}
|
|
|
|
| 219 |
.sidebar a:hover {
|
| 220 |
background-color: #34495e;
|
| 221 |
border-radius: 5px;
|
| 222 |
}
|
|
|
|
| 223 |
/* Main Content */
|
| 224 |
.main-content {
|
| 225 |
margin-left: 270px;
|
| 226 |
padding: 20px;
|
| 227 |
}
|
|
|
|
| 228 |
/* Buttons */
|
| 229 |
button {
|
| 230 |
background-color: #3498db;
|
|
|
|
| 235 |
cursor: pointer;
|
| 236 |
font-size: 16px;
|
| 237 |
}
|
|
|
|
| 238 |
button:hover {
|
| 239 |
background-color: #2980b9;
|
| 240 |
}
|
|
|
|
| 241 |
/* Text Areas and Inputs */
|
| 242 |
textarea, input[type="text"] {
|
| 243 |
width: 100%;
|
|
|
|
| 247 |
border-radius: 5px;
|
| 248 |
box-sizing: border-box;
|
| 249 |
}
|
|
|
|
| 250 |
textarea:focus, input[type="text"]:focus {
|
| 251 |
border-color: #3498db;
|
| 252 |
outline: none;
|
| 253 |
}
|
|
|
|
| 254 |
/* Terminal Output */
|
| 255 |
.code-output {
|
| 256 |
background-color: #1e1e1e;
|
|
|
|
| 259 |
border-radius: 5px;
|
| 260 |
font-family: 'Courier New', Courier, monospace;
|
| 261 |
}
|
|
|
|
| 262 |
/* Chat History */
|
| 263 |
.chat-history {
|
| 264 |
background-color: #ecf0f1;
|
|
|
|
| 267 |
max-height: 300px;
|
| 268 |
overflow-y: auto;
|
| 269 |
}
|
|
|
|
| 270 |
.chat-message {
|
| 271 |
margin-bottom: 10px;
|
| 272 |
}
|
|
|
|
| 273 |
.chat-message.user {
|
| 274 |
text-align: right;
|
| 275 |
color: #3498db;
|
| 276 |
}
|
|
|
|
| 277 |
.chat-message.agent {
|
| 278 |
text-align: left;
|
| 279 |
color: #e74c3c;
|
| 280 |
}
|
|
|
|
| 281 |
/* Project Management */
|
| 282 |
.project-list {
|
| 283 |
background-color: #ecf0f1;
|
|
|
|
| 286 |
max-height: 300px;
|
| 287 |
overflow-y: auto;
|
| 288 |
}
|
|
|
|
| 289 |
.project-item {
|
| 290 |
margin-bottom: 10px;
|
| 291 |
}
|
|
|
|
| 292 |
.project-item a {
|
| 293 |
color: #3498db;
|
| 294 |
text-decoration: none;
|
| 295 |
}
|
|
|
|
| 296 |
.project-item a:hover {
|
| 297 |
text-decoration: underline;
|
| 298 |
}
|
| 299 |
</style>
|
| 300 |
+
""", unsafe_allow_html=True)
|