Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,248 +1,317 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
def
|
29 |
-
|
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 |
-
def
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
)
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
if
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
chat_response = chat_interface(chat_input)
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
#
|
120 |
-
st.subheader("
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
st.
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
st.
|
133 |
-
st.
|
134 |
-
|
135 |
-
|
136 |
-
st.
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
st.
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
st.code(translated_code, language=target_language.lower())
|
157 |
-
|
158 |
-
# Code Generation
|
159 |
-
st.subheader("Code Generation")
|
160 |
-
code_idea = st.text_input("Enter your code idea:")
|
161 |
-
if st.button("Generate Code"):
|
162 |
-
generated_code = generate_code(code_idea)
|
163 |
-
st.code(generated_code, language="python")
|
164 |
-
|
165 |
-
# Display Preset Commands
|
166 |
-
st.subheader("Preset Commands")
|
167 |
-
preset_commands = {
|
168 |
-
"Create a new project": "create_project('project_name')",
|
169 |
-
"Add code to workspace": "add_code_to_workspace('project_name', 'code', 'file_name')",
|
170 |
-
"Run terminal command": "terminal_interface('command', 'project_name')",
|
171 |
-
"Generate code": "generate_code('code_idea')",
|
172 |
-
"Summarize text": "summarize_text('text')",
|
173 |
-
"Analyze sentiment": "sentiment_analysis('text')",
|
174 |
-
"Translate code": "translate_code('code', 'source_language', 'target_language')",
|
175 |
-
}
|
176 |
-
for command_name, command in preset_commands.items():
|
177 |
-
st.write(f"{command_name}: `{command}`")
|
178 |
-
elif app_mode == "Workspace Chat App":
# Workspace Chat App
st.header("Workspace Chat App")
|
179 |
-
|
180 |
-
# Project Workspace Creation
|
181 |
-
st.subheader("Create a New Project")
|
182 |
-
project_name = st.text_input("Enter project name:")
|
183 |
-
if st.button("Create Project"):
|
184 |
-
workspace_status = workspace_interface(project_name)
|
185 |
-
st.success(workspace_status)
|
186 |
-
|
187 |
-
# Add Code to Workspace
|
188 |
-
st.subheader("Add Code to Workspace")
|
189 |
-
code_to_add = st.text_area("Enter code to add to workspace:")
|
190 |
-
file_name = st.text_input("Enter file name (e.g. 'app.py'):")
|
191 |
-
if st.button("Add Code"):
|
192 |
-
add_code_status = add_code_to_workspace(project_name, code_to_add, file_name)
|
193 |
-
st.success(add_code_status)
|
194 |
-
|
195 |
-
# Terminal Interface with Project Context
|
196 |
-
st.subheader("Terminal (Workspace Context)")
|
197 |
-
terminal_input = st.text_input("Enter a command within the workspace:")
|
198 |
-
if st.button("Run Command"):
|
199 |
-
terminal_output = terminal_interface(terminal_input, project_name)
|
200 |
-
st.code(terminal_output, language="bash")
|
201 |
-
|
202 |
-
# Chat Interface for Guidance
|
203 |
-
st.subheader("Chat with CodeCraft for Guidance")
|
204 |
-
chat_input = st.text_area("Enter your message for guidance:")
|
205 |
-
if st.button("Get Guidance"):
|
206 |
-
chat_response = chat_interface(chat_input)
|
207 |
-
st.session_state.chat_history.append((chat_input, chat_response))
|
208 |
-
st.write(f"CodeCraft: {chat_response}")
|
209 |
-
|
210 |
-
# Display Chat History
|
211 |
-
st.subheader("Chat History")
|
212 |
-
for user_input, response in st.session_state.chat_history:
|
213 |
-
st.write(f"User: {user_input}")
|
214 |
-
st.write(f"CodeCraft: {response}")
|
215 |
-
|
216 |
-
# Display Terminal History
|
217 |
-
st.subheader("Terminal History")
|
218 |
-
for command, output in st.session_state.terminal_history:
|
219 |
-
st.write(f"Command: {command}")
|
220 |
-
st.code(output, language="bash")
|
221 |
-
|
222 |
-
# Display Projects and Files
|
223 |
-
st.subheader("Workspace Projects")
|
224 |
-
for project, details in st.session_state.workspace_projects.items():
|
225 |
-
st.write(f"Project: {project}")
|
226 |
-
for file in details['files']:
|
227 |
-
st.write(f" - {file}")
|
228 |
-
|
229 |
-
# Chat with AI Agents
|
230 |
-
st.subheader("Chat with AI Agents")
|
231 |
-
selected_agent = st.selectbox("Select an AI agent", st.session_state.available_agents)
|
232 |
-
agent_chat_input = st.text_area("Enter your message for the agent:")
|
233 |
-
if st.button("Send to Agent"):
|
234 |
-
agent_chat_response = chat_interface_with_agent(agent_chat_input, selected_agent)
|
235 |
-
st.session_state.chat_history.append((agent_chat_input, agent_chat_response))
|
236 |
-
st.write(f"{selected_agent}: {agent_chat_response}")
|
237 |
-
|
238 |
-
# Automate Build Process
|
239 |
-
st.subheader("Automate Build Process")
|
240 |
-
if st.button("Automate"):
|
241 |
-
agent = AIAgent(selected_agent, "", []) # Load the agent without skills for now
|
242 |
-
summary, next_step = agent.autonomous_build(st.session_state.chat_history, st.session_state.workspace_projects)
|
243 |
-
st.write("Autonomous Build Summary:")
|
244 |
-
st.write(summary)
|
245 |
-
st.write("Next Step:")
|
246 |
-
st.write(next_step)
|
247 |
-
Display current state for debugging
|
248 |
-
st.sidebar.subheader("Current State")
st.sidebar.json(st.session_state.current_state)
|
|
|
1 |
+
import
|
2 |
+
import
|
3 |
+
import subprocess
|
4 |
+
from transformers import pipeline,
|
5 |
+
import
|
6 |
+
from pylint import lint
|
7 |
+
from io import StringIO
|
8 |
+
# import openai # We're not using OpenAI anymore
|
9 |
+
import sys
|
10 |
+
|
11 |
+
# Set your Hugging Face API key
|
12 |
+
HF_API_KEY =
|
13 |
+
|
14 |
+
PROJECT_ROOT = "projects"
|
15 |
+
AGENT_DIRECTORY = "agents"
|
16 |
+
|
17 |
+
# Global state to manage communication between Tool Box and Workspace Chat App
|
18 |
+
if 'chat_history' not in st.session_state:
|
19 |
+
st.session_state.chat_history = []
|
20 |
+
if 'terminal_history' not in st.session_state:
|
21 |
+
st.session_state.terminal_history = []
|
22 |
+
if 'workspace_projects' not in st.session_state:
|
23 |
+
st.session_state.workspace_projects = {}
|
24 |
+
if
|
25 |
+
st.session_state.available_agents = []
|
26 |
+
|
27 |
+
class AIAgent:
|
28 |
+
def __init__(self,
|
29 |
+
self.name = name
|
30 |
+
self.description
|
31 |
+
self.skills = skills
|
32 |
+
|
33 |
+
def create_agent_prompt(self):
|
34 |
+
skills_str = '\n'.join([f"* {skill}" for skill in self.skills])
|
35 |
+
agent_prompt = f"""
|
36 |
+
As an elite expert developer, my name is {self.name}. I possess a comprehensive understanding of the following areas:
|
37 |
+
{skills_str}
|
38 |
+
|
39 |
+
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.
|
40 |
+
"""
|
41 |
+
return agent_prompt
|
42 |
+
|
43 |
+
def autonomous_build(self, chat_history, workspace_projects):
|
44 |
+
"""
|
45 |
+
Autonomous build logic that continues based on the state of chat history and workspace projects.
|
46 |
+
"""
|
47 |
+
# Example logic: Generate a summary of chat history and workspace state
|
48 |
+
summary = "Chat History:\n" + "\n".join([f"User: {u}\nAgent: {a}" for u, a in chat_history])
|
49 |
+
summary += "\n\nWorkspace Projects:\n" + "\n".join([f"{p}: {details}" for p, details in workspace_projects.items()])
|
50 |
+
|
51 |
+
# Example: Generate the next logical step in the project
|
52 |
+
next_step = "Based on the current state, the next logical step is to implement the main application logic."
|
53 |
+
|
54 |
+
return summary, next_step
|
55 |
+
|
56 |
+
def save_agent_to_file(agent):
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
file_path
|
61 |
+
with open(
|
62 |
+
file.write(agent.create_agent_prompt()
|
63 |
+
st.session_state.available_agents.append(agent.name)
|
64 |
+
|
65 |
+
def load_agent_prompt(agent_name):
|
66 |
+
"""Loads an agent prompt from a file."""
|
67 |
+
file_path = os.path.join(AGENT_DIRECTORY, f"{agent_name}.txt")
|
68 |
+
if os.path.exists(file_path):
|
69 |
+
with open(file_path, "r") as file:
|
70 |
+
agent_prompt = file.read()
|
71 |
+
return agent_prompt
|
72 |
+
else:
|
73 |
+
return None
|
74 |
+
|
75 |
+
def create_agent_from_text(name, text):
|
76 |
+
skills = text.split('\n')
|
77 |
+
agent = AIAgent(name, "AI agent created from text input.", skills)
|
78 |
+
save_agent_to_file(agent)
|
79 |
+
return agent.create_agent_prompt()
|
80 |
+
|
81 |
+
# Chat interface using a selected agent (Hugging Face version)
|
82 |
+
def chat_interface_with_agent(input_text, agent_name):
|
83 |
+
agent_prompt = load_agent_prompt(agent_name)
|
84 |
+
if agent_prompt is None:
|
85 |
+
return f"Agent {agent_name} not found."
|
86 |
+
|
87 |
+
# Use a Hugging Face model for chat with the agent
|
88 |
+
# Example: Using the 'google/flan-t5-xl' model
|
89 |
+
generator
|
90 |
+
|
91 |
+
# Combine the agent prompt with user input
|
92 |
+
combined_input = f"{agent_prompt}\n\nUser: {input_text}\nAgent:"
|
93 |
+
|
94 |
+
|
95 |
+
response =
|
96 |
+
return response[0]['generated_text']
|
97 |
+
|
98 |
+
# Terminal interface
|
99 |
+
def terminal_interface(command, project_name=None):
|
100 |
+
if project_name:
|
101 |
+
project_path = os.path.join(PROJECT_ROOT, project_name)
|
102 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True, cwd=project_path)
|
103 |
+
else:
|
104 |
+
result = subprocess.run(command, shell=True,
|
105 |
+
return result.stdout
|
106 |
+
|
107 |
+
# Code editor interface
|
108 |
+
def code_editor_interface(code):
|
109 |
+
formatted_code = black.format_str(code, mode=black.FileMode())
|
110 |
+
pylint_output = lint.Run([formatted_code], do_exit=False)
|
111 |
+
pylint_output_str = StringIO()
|
112 |
+
pylint_output.linter.reporter.write_messages(pylint_output_str)
|
113 |
+
return formatted_code, pylint_output_str.getvalue()
|
114 |
+
|
115 |
+
# Text summarization tool
|
116 |
+
def summarize_text(text):
|
117 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn", use_auth_token=HF_API_KEY)
|
118 |
+
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
|
119 |
+
return summary[0]['summary_text']
|
120 |
+
|
121 |
+
# Sentiment analysis tool
|
122 |
+
def sentiment_analysis(text):
|
123 |
+
analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-3-literal", use_auth_token=HF_API_KEY)
|
124 |
+
result = analyzer(text)
|
125 |
+
return result[0]['label']
|
126 |
+
|
127 |
+
# Text translation tool (code translation)
|
128 |
+
def translate_code(code, source_language, target_language):
|
129 |
+
# Placeholder for translation logic
|
130 |
+
return f"Translated {source_language} code to {target_language}."
|
131 |
+
|
132 |
+
# Code generation tool
|
133 |
+
def generate_code(idea):
|
134 |
+
# Use a Hugging Face model for code generation
|
135 |
+
# Example: Using the 'Salesforce/codet5-base' model
|
136 |
+
generator = pipeline("text-generation", model="Salesforce/codet5-base", use_auth_token=HF_API_KEY)
|
137 |
+
response = generator(idea, max_length=150, num_return_sequences=1, do_sample=True)
|
138 |
+
return response[0]['generated_text']
|
139 |
+
|
140 |
+
# Workspace interface
|
141 |
+
def workspace_interface(project_name):
|
142 |
+
project_path = os.path.join(PROJECT_ROOT, project_name)
|
143 |
+
if not os.path.exists(project_path):
|
144 |
+
os.makedirs(project_path)
|
145 |
+
st.session_state.workspace_projects[project_name] = {'files': []}
|
146 |
+
return f"Project '{project_name}' created successfully."
|
147 |
else:
|
148 |
+
return f"Project '{project_name}' already exists."
|
149 |
+
|
150 |
+
# Add code to workspace
|
151 |
+
def add_code_to_workspace(project_name, code, file_name):
|
152 |
+
project_path = os.path.join(PROJECT_ROOT, project_name)
|
153 |
+
if not os.path.exists(project_path):
|
154 |
+
return f"Project '{project_name}' does not exist."
|
155 |
+
|
156 |
+
file_path = os.path.join(project_path, file_name)
|
157 |
+
with open(file_path, "w") as file:
|
158 |
+
file.write(code)
|
159 |
+
st.session_state.workspace_projects[project_name]['files'].append(file_name)
|
160 |
+
return f"Code added to '{file_name}' in project '{project_name}'."
|
161 |
+
|
162 |
+
# Chat interface (Hugging Face version)
|
163 |
+
def chat_interface(input_text):
|
164 |
+
# Use a Hugging Face model for chat
|
165 |
+
# Example: Using the 'google/flan-t5-xl' model
|
166 |
+
generator = pipeline("text-generation", model="google/flan-t5-xl", use_auth_token=HF_API_KEY)
|
167 |
+
response = generator(input_text, max_length=150, num_return_sequences=1, do_sample=True)
|
168 |
+
return response[0]['generated_text']
|
169 |
+
|
170 |
+
# Streamlit App
|
171 |
+
st.title("AI Agent Creator")
|
172 |
+
|
173 |
+
# Sidebar navigation
|
174 |
+
st.sidebar.title("Navigation")
|
175 |
+
app_mode = st.sidebar.selectbox("Choose the app mode", ["AI Agent Creator", "Tool Box", "Workspace Chat App"])
|
176 |
+
|
177 |
+
if app_mode == "AI Agent Creator":
|
178 |
+
# AI Agent Creator
|
179 |
+
st.header("Create an AI Agent from Text")
|
180 |
+
|
181 |
+
st.subheader("From Text")
|
182 |
+
agent_name = st.text_input("Enter agent name:")
|
183 |
+
text_input = st.text_area("Enter skills (one per line):")
|
184 |
+
if st.button("Create Agent"):
|
185 |
+
agent_prompt = create_agent_from_text(agent_name, text_input)
|
186 |
+
st.success(f"Agent '{agent_name}' created and saved successfully.")
|
187 |
+
st.session_state.available_agents.append(agent_name)
|
188 |
+
|
189 |
+
elif app_mode == "Tool Box":
|
190 |
+
# Tool Box
|
191 |
+
st.header("AI-Powered Tools")
|
192 |
+
|
193 |
+
# Chat Interface
|
194 |
+
st.subheader("Chat with CodeCraft")
|
195 |
+
chat_input = st.text_area("Enter your message:")
|
196 |
+
if st.button("Send"):
|
197 |
+
chat_response = chat_interface(chat_input)
|
198 |
+
st.session_state.chat_history.append((chat_input, chat_response))
|
199 |
+
st.write(f"CodeCraft: {chat_response}")
|
200 |
+
|
201 |
+
# Terminal Interface
|
202 |
+
st.subheader("Terminal")
|
203 |
+
terminal_input = st.text_input("Enter a command:")
|
204 |
+
if st.button("Run"):
|
205 |
+
terminal_output = terminal_interface(terminal_input)
|
206 |
+
st.session_state.terminal_history.append((terminal_input, terminal_output))
|
207 |
+
st.code(terminal_output, language="bash")
|
208 |
+
|
209 |
+
# Code Editor Interface
|
210 |
+
st.subheader("Code Editor")
|
211 |
+
code_editor = st.text_area("Write your code:", height=300)
|
212 |
+
if st.button("Format & Lint"):
|
213 |
+
formatted_code, lint_message = code_editor_interface(code_editor)
|
214 |
+
st.code(formatted_code, language="python")
|
215 |
+
st.info(lint_message)
|
216 |
+
|
217 |
+
# Text Summarization Tool
|
218 |
+
st.subheader("Summarize Text")
|
219 |
+
text_to_summarize = st.text_area("Enter text to summarize:")
|
220 |
+
if st.button("Summarize"):
|
221 |
+
summary = summarize_text(text_to_summarize)
|
222 |
+
st.write(f"Summary: {summary}")
|
223 |
+
|
224 |
+
# Sentiment Analysis Tool
|
225 |
+
st.subheader("Sentiment Analysis")
|
226 |
+
sentiment_text = st.text_area("Enter text for sentiment analysis:")
|
227 |
+
if st.button("Analyze Sentiment"):
|
228 |
+
sentiment = sentiment_analysis(sentiment_text)
|
229 |
+
st.write(f"Sentiment: {sentiment}")
|
230 |
+
|
231 |
+
# Text Translation Tool (Code Translation)
|
232 |
+
st.subheader("Translate Code")
|
233 |
+
code_to_translate = st.text_area("Enter code to translate:")
|
234 |
+
source_language = st.text_input("Enter source language (e.g., 'Python'):")
|
235 |
+
target_language = st.text_input("Enter target language (e.g., 'JavaScript'):")
|
236 |
+
if st.button("Translate Code"):
|
237 |
+
translated_code = translate_code(code_to_translate, source_language, target_language)
|
238 |
+
st.code(translated_code, language=target_language.lower())
|
239 |
+
|
240 |
+
# Code Generation
|
241 |
+
st.subheader("Code Generation")
|
242 |
+
code_idea = st.text_input("Enter your code idea:")
|
243 |
+
if st.button("Generate Code"):
|
244 |
+
generated_code = generate_code(code_idea)
|
245 |
+
st.code(generated_code, language="python")
|
246 |
+
|
247 |
+
elif app_mode == "Workspace Chat App":
|
248 |
+
# Workspace Chat App
|
249 |
+
st.header("Workspace Chat App")
|
250 |
+
|
251 |
+
# Project Workspace Creation
|
252 |
+
st.subheader("Create a New Project")
|
253 |
+
project_name = st.text_input("Enter project name:")
|
254 |
+
if st.button("Create Project"):
|
255 |
+
workspace_status = workspace_interface(project_name)
|
256 |
+
st.success(workspace_status)
|
257 |
+
|
258 |
+
# Add Code to Workspace
|
259 |
+
st.subheader("Add Code to Workspace")
|
260 |
+
code_to_add = st.text_area("Enter code to add to workspace:")
|
261 |
+
file_name = st.text_input("Enter file name (e.g., 'app.py'):")
|
262 |
+
if st.button("Add Code"):
|
263 |
+
add_code_status = add_code_to_workspace(project_name, code_to_add, file_name)
|
264 |
+
st.success(add_code_status)
|
265 |
+
|
266 |
+
# Terminal Interface with Project Context
|
267 |
+
st.subheader("Terminal (Workspace Context)")
|
268 |
+
terminal_input = st.text_input("Enter a command within the workspace:")
|
269 |
+
if st.button("Run Command"):
|
270 |
+
terminal_output = terminal_interface(terminal_input, project_name)
|
271 |
+
st.code(terminal_output, language="bash")
|
272 |
+
|
273 |
+
# Chat Interface for Guidance
|
274 |
+
st.subheader("Chat with CodeCraft for Guidance")
|
275 |
+
chat_input = st.text_area("Enter your message for guidance:")
|
276 |
+
if st.button("Get Guidance"):
|
277 |
chat_response = chat_interface(chat_input)
|
278 |
+
st.session_state.chat_history.append((chat_input, chat_response))
|
279 |
+
st.write(f"CodeCraft: {chat_response}")
|
280 |
+
|
281 |
+
# Display Chat History
|
282 |
+
st.subheader("Chat History")
|
283 |
+
for user_input, response in st.session_state.chat_history:
|
284 |
+
st.write(f"User: {user_input}")
|
285 |
+
st.write(f"CodeCraft: {response}")
|
286 |
+
|
287 |
+
# Display Terminal History
|
288 |
+
st.subheader("Terminal History")
|
289 |
+
for command, output in st.session_state.terminal_history:
|
290 |
+
st.write(f"Command: {command}")
|
291 |
+
st.code(output, language="bash")
|
292 |
+
|
293 |
+
# Display Projects and Files
|
294 |
+
st.subheader("Workspace Projects")
|
295 |
+
for project, details in st.session_state.workspace_projects.items():
|
296 |
+
st.write(f"Project: {project}")
|
297 |
+
for file in details['files']:
|
298 |
+
st.write(f" - {file}")
|
299 |
+
|
300 |
+
# Chat with AI Agents
|
301 |
+
st.subheader("Chat with AI Agents")
|
302 |
+
selected_agent = st.selectbox("Select an AI agent", st.session_state.available_agents)
|
303 |
+
agent_chat_input = st.text_area("Enter your message for the agent:")
|
304 |
+
if st.button("Send to Agent"):
|
305 |
+
agent_chat_response = chat_interface_with_agent(agent_chat_input, selected_agent)
|
306 |
+
st.session_state.chat_history.append((agent_chat_input, agent_chat_response))
|
307 |
+
st.write(f"{selected_agent}: {agent_chat_response}")
|
308 |
+
|
309 |
+
# Automate Build Process
|
310 |
+
st.subheader("Automate Build Process")
|
311 |
+
if st.button("Automate"):
|
312 |
+
agent = AIAgent(selected_agent, "", []) # Load the agent without skills for now
|
313 |
+
summary, next_step = agent.autonomous_build(st.session_state.chat_history, st.session_state.workspace_projects)
|
314 |
+
st.write("Autonomous Build Summary:")
|
315 |
+
st.write(summary)
|
316 |
+
st.write("Next Step:")
|
317 |
+
st.write(next_step)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|