Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ from langchain.chains.question_answering import load_qa_chain
|
|
21 |
from langchain.text_splitter import CharacterTextSplitter
|
22 |
from langchain_community.document_loaders import TextLoader
|
23 |
from streamlit_ace import st_ace
|
24 |
-
from streamlit_chat import
|
25 |
|
26 |
# --- Constants ---
|
27 |
MODEL_NAME = "google/flan-t5-xl" # Consider using a more powerful model
|
@@ -74,6 +74,8 @@ if "selected_agents" not in st.session_state:
|
|
74 |
st.session_state.selected_agents = []
|
75 |
if "current_project" not in st.session_state:
|
76 |
st.session_state.current_project = None
|
|
|
|
|
77 |
|
78 |
# --- Helper Functions ---
|
79 |
def add_code_to_workspace(project_name: str, code: str, file_name: str):
|
@@ -143,8 +145,43 @@ def combine_and_process_responses(responses: Dict[str, str], task: str) -> str:
|
|
143 |
combined = "\n\n".join([f"{agent}: {response}" for agent, response in responses.items()])
|
144 |
return f"Combined response for task '{task}':\n\n{combined}"
|
145 |
|
146 |
-
# ---
|
147 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
# --- Project Management ---
|
150 |
st.header("Project Management")
|
@@ -191,7 +228,7 @@ else:
|
|
191 |
st.info("No projects created yet. Create a project to use the terminal.")
|
192 |
|
193 |
# --- Chat Interface ---
|
194 |
-
st.subheader("Chat with
|
195 |
selected_agents = st.multiselect("Select AI agents", list(agents.keys()), key="agent_select")
|
196 |
st.session_state.selected_agents = selected_agents
|
197 |
agent_chat_input = st.text_area("Enter your message for the agents:", key="agent_input")
|
@@ -262,4 +299,5 @@ display_chat_history()
|
|
262 |
|
263 |
if __name__ == "__main__":
|
264 |
st.sidebar.title("DevToolKit")
|
265 |
-
st.sidebar.info("This is an AI-powered development environment.")
|
|
|
|
21 |
from langchain.text_splitter import CharacterTextSplitter
|
22 |
from langchain_community.document_loaders import TextLoader
|
23 |
from streamlit_ace import st_ace
|
24 |
+
from streamlit_chat import message
|
25 |
|
26 |
# --- Constants ---
|
27 |
MODEL_NAME = "google/flan-t5-xl" # Consider using a more powerful model
|
|
|
74 |
st.session_state.selected_agents = []
|
75 |
if "current_project" not in st.session_state:
|
76 |
st.session_state.current_project = None
|
77 |
+
if "messages" not in st.session_state:
|
78 |
+
st.session_state.messages = []
|
79 |
|
80 |
# --- Helper Functions ---
|
81 |
def add_code_to_workspace(project_name: str, code: str, file_name: str):
|
|
|
145 |
combined = "\n\n".join([f"{agent}: {response}" for agent, response in responses.items()])
|
146 |
return f"Combined response for task '{task}':\n\n{combined}"
|
147 |
|
148 |
+
# --- Chat Interface ---
|
149 |
+
st.subheader("Chat with AI Agents")
|
150 |
+
|
151 |
+
# Display chat messages from history on app rerun
|
152 |
+
for message in st.session_state.messages:
|
153 |
+
with st.chat_message(message["role"]):
|
154 |
+
st.markdown(message["content"])
|
155 |
+
|
156 |
+
# React to user input
|
157 |
+
if prompt := st.chat_input("What is up?"):
|
158 |
+
# Display user message in chat message container
|
159 |
+
st.chat_message("user").markdown(prompt)
|
160 |
+
# Add user message to chat history
|
161 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
162 |
+
|
163 |
+
# Process the message with selected agents
|
164 |
+
if st.session_state.selected_agents:
|
165 |
+
responses = {}
|
166 |
+
for agent in st.session_state.selected_agents:
|
167 |
+
response = get_agent_response(prompt, agents[agent]['system_prompt'])
|
168 |
+
responses[agent] = response
|
169 |
+
|
170 |
+
# Combine responses (you may want to implement a more sophisticated combination method)
|
171 |
+
combined_response = "\n".join([f"{agent}: {resp}" for agent, resp in responses.items()])
|
172 |
+
|
173 |
+
# Display assistant response in chat message container
|
174 |
+
with st.chat_message("assistant"):
|
175 |
+
st.markdown(combined_response)
|
176 |
+
# Add assistant response to chat history
|
177 |
+
st.session_state.messages.append({"role": "assistant", "content": combined_response})
|
178 |
+
else:
|
179 |
+
st.warning("Please select at least one agent to chat with.")
|
180 |
+
|
181 |
+
# Agent selection
|
182 |
+
st.sidebar.subheader("Select AI Agents")
|
183 |
+
st.session_state.selected_agents = st.sidebar.multiselect("Select AI agents", list(agents.keys()), key="agent_select")
|
184 |
+
|
185 |
|
186 |
# --- Project Management ---
|
187 |
st.header("Project Management")
|
|
|
228 |
st.info("No projects created yet. Create a project to use the terminal.")
|
229 |
|
230 |
# --- Chat Interface ---
|
231 |
+
st.subheader("Chat with ")
|
232 |
selected_agents = st.multiselect("Select AI agents", list(agents.keys()), key="agent_select")
|
233 |
st.session_state.selected_agents = selected_agents
|
234 |
agent_chat_input = st.text_area("Enter your message for the agents:", key="agent_input")
|
|
|
299 |
|
300 |
if __name__ == "__main__":
|
301 |
st.sidebar.title("DevToolKit")
|
302 |
+
st.sidebar.info("This is an AI-powered development environment.")
|
303 |
+
st.run()
|