Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import os
|
2 |
import json
|
3 |
import time
|
@@ -15,7 +17,7 @@ import subprocess
|
|
15 |
import threading
|
16 |
|
17 |
# --- Constants ---
|
18 |
-
MODEL_NAME = "bigscience/bloom-1b7"
|
19 |
MAX_NEW_TOKENS = 1024
|
20 |
TEMPERATURE = 0.7
|
21 |
TOP_P = 0.95
|
@@ -27,41 +29,41 @@ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
|
27 |
|
28 |
# --- Agents ---
|
29 |
agents = {
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
}
|
66 |
|
67 |
# --- Session State ---
|
@@ -86,56 +88,30 @@ if "repo_name" not in st.session_state:
|
|
86 |
if "selected_model" not in st.session_state:
|
87 |
st.session_state.selected_model = None
|
88 |
|
89 |
-
def add_code_to_workspace(project_name: str, code: str, file_name: str)
|
90 |
if project_name in st.session_state.workspace_projects:
|
91 |
-
|
92 |
-
|
93 |
-
return f"Code added to project {project_name}"
|
94 |
else:
|
95 |
-
return f"Project {project_name} does not exist
|
96 |
-
|
97 |
-
def terminal_interface(command: str, project_name: str)
|
98 |
-
|
99 |
-
|
100 |
-
workspace_dir = os.path.join("workspace", project_name)
|
101 |
-
os.makedirs(workspace_dir, exist_ok=True)
|
102 |
-
result = subprocess.run(command, shell=True, cwd=workspace_dir, capture_output=True, text=True)
|
103 |
return result.stdout + result.stderr
|
104 |
-
|
105 |
-
return
|
106 |
|
107 |
-
def chat_interface(message: str, selected_agents: List[str])
|
108 |
responses = {}
|
109 |
-
for
|
110 |
-
|
111 |
-
responses[
|
112 |
-
return
|
113 |
-
|
114 |
-
def
|
115 |
-
|
116 |
-
|
117 |
-
chat_history = st.session_state.chat_history
|
118 |
-
workspace_projects = st.session_state.workspace_projects
|
119 |
-
summary, next_step = agent.autonomous_build(chat_history, workspace_projects)
|
120 |
-
rprint(Panel(summary, title="[bold blue]Current State[/bold blue]"))
|
121 |
-
rprint(Panel(next_step, title="[bold blue]Next Step[/bold blue]"))
|
122 |
-
# Implement logic for autonomous build based on the current state
|
123 |
-
|
124 |
-
def display_agent_info(agent_name: str):
|
125 |
-
agent = agents[agent_name]
|
126 |
-
st.sidebar.subheader(f"Agent: {agent_name}")
|
127 |
-
st.sidebar.write(agent['description'])
|
128 |
-
st.sidebar.write("Skills: " + ", ".join(agent['skills']))
|
129 |
-
st.sidebar.write("System Prompt: " + agent['system_prompt'])
|
130 |
-
|
131 |
-
def display_workspace_projects():
|
132 |
-
st.sidebar.subheader("Workspace Projects")
|
133 |
-
for project_name, details in st.session_state.workspace_projects.items():
|
134 |
-
st.sidebar.write(f"{project_name}: {details}")
|
135 |
-
|
136 |
-
def display_chat_history():
|
137 |
-
st.sidebar.subheader("Chat History")
|
138 |
-
st.sidebar.json(st.session_state.chat_history)
|
139 |
|
140 |
# --- Streamlit UI ---
|
141 |
st.title("DevToolKit: AI-Powered Development Environment")
|
|
|
1 |
+
|
2 |
+
Copy
|
3 |
import os
|
4 |
import json
|
5 |
import time
|
|
|
17 |
import threading
|
18 |
|
19 |
# --- Constants ---
|
20 |
+
MODEL_NAME = "bigscience/bloom-1b7"
|
21 |
MAX_NEW_TOKENS = 1024
|
22 |
TEMPERATURE = 0.7
|
23 |
TOP_P = 0.95
|
|
|
29 |
|
30 |
# --- Agents ---
|
31 |
agents = {
|
32 |
+
"WEB_DEV": {
|
33 |
+
"description": "Expert in web development technologies and frameworks.",
|
34 |
+
"skills": ["HTML", "CSS", "JavaScript", "React", "Vue.js", "Flask", "Django", "Node.js", "Express.js"],
|
35 |
+
"system_prompt": "You are a web development expert. Your goal is to assist the user in building and deploying web applications. Provide code snippets, explanations, and guidance on best practices.",
|
36 |
+
},
|
37 |
+
"AI_SYSTEM_PROMPT": {
|
38 |
+
"description": "Expert in designing and implementing AI systems.",
|
39 |
+
"skills": ["Machine Learning", "Deep Learning", "Natural Language Processing", "Computer Vision", "Reinforcement Learning"],
|
40 |
+
"system_prompt": "You are an AI system expert. Your goal is to assist the user in designing and implementing AI systems. Provide code snippets, explanations, and guidance on best practices.",
|
41 |
+
},
|
42 |
+
"PYTHON_CODE_DEV": {
|
43 |
+
"description": "Expert in Python programming and development.",
|
44 |
+
"skills": ["Python", "Data Structures", "Algorithms", "Object-Oriented Programming", "Functional Programming"],
|
45 |
+
"system_prompt": "You are a Python code development expert. Your goal is to assist the user in writing and debugging Python code. Provide code snippets, explanations, and guidance on best practices.",
|
46 |
+
},
|
47 |
+
"CODE_REVIEW_ASSISTANT": {
|
48 |
+
"description": "Expert in code review and quality assurance.",
|
49 |
+
"skills": ["Code Style", "Best Practices", "Security", "Performance", "Maintainability"],
|
50 |
+
"system_prompt": "You are a code review assistant. Your goal is to assist the user in reviewing code for quality and efficiency. Provide feedback on code style, best practices, security, performance, and maintainability.",
|
51 |
+
},
|
52 |
+
"CONTENT_WRITER_EDITOR": {
|
53 |
+
"description": "Expert in content writing and editing.",
|
54 |
+
"skills": ["Grammar", "Style", "Clarity", "Conciseness", "SEO"],
|
55 |
+
"system_prompt": "You are a content writer and editor. Your goal is to assist the user in creating high-quality content. Provide suggestions on grammar, style, clarity, conciseness, and SEO.",
|
56 |
+
},
|
57 |
+
"QUESTION_GENERATOR": {
|
58 |
+
"description": "Expert in generating questions for learning and assessment.",
|
59 |
+
"skills": ["Question Types", "Cognitive Levels", "Assessment Design"],
|
60 |
+
"system_prompt": "You are a question generator. Your goal is to assist the user in generating questions for learning and assessment. Provide questions that are relevant to the topic and aligned with the cognitive levels.",
|
61 |
+
},
|
62 |
+
"HUGGINGFACE_FILE_DEV": {
|
63 |
+
"description": "Expert in developing Hugging Face files for machine learning models.",
|
64 |
+
"skills": ["Transformers", "Datasets", "Model Training", "Model Deployment"],
|
65 |
+
"system_prompt": "You are a Hugging Face file development expert. Your goal is to assist the user in creating and deploying Hugging Face files for machine learning models. Provide code snippets, explanations, and guidance on best practices.",
|
66 |
+
},
|
67 |
}
|
68 |
|
69 |
# --- Session State ---
|
|
|
88 |
if "selected_model" not in st.session_state:
|
89 |
st.session_state.selected_model = None
|
90 |
|
91 |
+
def add_code_to_workspace(project_name: str, code: str, file_name: str):
|
92 |
if project_name in st.session_state.workspace_projects:
|
93 |
+
st.session_state.workspace_projects[project_name]['files'].append({'file_name': file_name, 'code': code})
|
94 |
+
return f"Added code to {file_name} in project {project_name}"
|
|
|
95 |
else:
|
96 |
+
return f"Project {project_name} does not exist"
|
97 |
+
|
98 |
+
def terminal_interface(command: str, project_name: str):
|
99 |
+
if project_name in st.session_state.workspace_projects:
|
100 |
+
result = subprocess.run(command, cwd=project_name, shell=True, capture_output=True, text=True)
|
|
|
|
|
|
|
101 |
return result.stdout + result.stderr
|
102 |
+
else:
|
103 |
+
return f"Project {project_name} does not exist"
|
104 |
|
105 |
+
def chat_interface(message: str, selected_agents: List[str]):
|
106 |
responses = {}
|
107 |
+
for agent in selected_agents:
|
108 |
+
# Assuming a function `get_agent_response` that fetches the response from the agent
|
109 |
+
responses[agent] = get_agent_response(message, agents[agent]['system_prompt'])
|
110 |
+
return responses
|
111 |
+
|
112 |
+
def get_agent_response(message: str, system_prompt: str):
|
113 |
+
# This function should implement how to get the response from the agent
|
114 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
# --- Streamlit UI ---
|
117 |
st.title("DevToolKit: AI-Powered Development Environment")
|