acecalisto3 commited on
Commit
aac2f84
Β·
verified Β·
1 Parent(s): ded6c58

Rename main.py to app.py

Browse files
Files changed (1) hide show
  1. main.py β†’ app.py +40 -12
main.py β†’ app.py RENAMED
@@ -1,6 +1,8 @@
1
  import os
2
  import subprocess
3
- from typing import List, Dict, Tuple
 
 
4
  from huggingface_hub import InferenceClient
5
  import streamlit as st
6
 
@@ -15,11 +17,18 @@ from app.prompts import (
15
  READ_PROMPT,
16
  TASK_PROMPT,
17
  UNDERSTAND_TEST_RESULTS_PROMPT,
 
 
 
 
 
18
  )
19
  from app.utils import (
20
  parse_action,
21
  parse_file_content,
22
  read_python_module_structure,
 
 
23
  )
24
 
25
  # --- Constants ---
@@ -43,15 +52,16 @@ MODEL = "mistralai/Mixtral-8x7B-Instruct-v0.1" # Consider using a smaller model
43
  # --- Initialize Hugging Face client ---
44
  client = InferenceClient(MODEL)
45
 
 
46
  # --- Classes ---
47
  class Agent:
48
  def __init__(self, name: str, agent_type: str, complexity: int):
49
  self.name = name
50
  self.type = agent_type
51
  self.complexity = complexity
52
- self.tools = []
53
 
54
- def add_tool(self, tool):
55
  self.tools.append(tool)
56
 
57
  def __str__(self):
@@ -71,10 +81,10 @@ class Pypelyne:
71
  def __init__(self):
72
  self.agents: List[Agent] = []
73
  self.tools: List[Tool] = []
74
- self.history = ""
75
- self.task = None
76
- self.purpose = None
77
- self.directory = None
78
 
79
  def add_agent(self, agent: Agent):
80
  self.agents.append(agent)
@@ -82,7 +92,7 @@ class Pypelyne:
82
  def add_tool(self, tool: Tool):
83
  self.tools.append(tool)
84
 
85
- def generate_chat_app(self):
86
  time.sleep(2) # Simulate processing time
87
  return f"Chat app generated with {len(self.agents)} agents and {len(self.tools)} tools."
88
 
@@ -334,16 +344,27 @@ def main():
334
 
335
  # --- Sidebar ---
336
  st.sidebar.title("βš™οΈ Settings")
 
 
337
  pypelyne.directory = st.sidebar.text_input(
338
- "Project Directory:", value=".", help="Path to your coding project"
 
 
339
  )
 
 
 
340
  pypelyne.purpose = st.sidebar.text_area(
341
  "Project Purpose:",
 
342
  help="Describe the purpose of your coding project.",
343
  )
 
344
 
345
  # --- Agent and Tool Management ---
346
  st.sidebar.header("πŸ€– Agents")
 
 
347
  show_agent_creation = st.sidebar.expander(
348
  "Create New Agent", expanded=False
349
  )
@@ -353,34 +374,41 @@ def main():
353
  agent_complexity = st.slider("Complexity (1-5):", 1, 5, 3)
354
  if st.button("Add Agent"):
355
  create_agent(agent_name, agent_type, agent_complexity)
 
356
 
357
  st.sidebar.header("πŸ› οΈ Tools")
 
 
358
  show_tool_creation = st.sidebar.expander("Create New Tool", expanded=False)
359
  with show_tool_creation:
360
  tool_name = st.text_input("Tool Name:")
361
  tool_type = st.selectbox("Tool Type:", TOOL_TYPES)
362
  if st.button("Add Tool"):
363
  create_tool(tool_name, tool_type)
 
364
 
365
  # --- Display Agents and Tools ---
366
  st.sidebar.subheader("Active Agents:")
367
- for agent in pypelyne.agents:
368
  st.sidebar.write(f"- {agent}")
369
 
370
  st.sidebar.subheader("Available Tools:")
371
- for tool in pypelyne.tools:
372
  st.sidebar.write(f"- {tool}")
373
 
374
  # --- Main Content Area ---
375
  st.header("πŸ’» Code Interaction")
376
 
 
 
377
  task_input = st.text_area(
378
  "🎯 Task:",
379
- value=pypelyne.task if pypelyne.task else "",
380
  help="Describe the coding task you want to perform.",
381
  )
382
  if task_input:
383
  pypelyne.task = task_input
 
384
 
385
  user_input = st.text_input(
386
  "πŸ’¬ Your Input:", help="Provide instructions or ask questions."
 
1
  import os
2
  import subprocess
3
+ import time
4
+ from typing import List, Dict
5
+
6
  from huggingface_hub import InferenceClient
7
  import streamlit as st
8
 
 
17
  READ_PROMPT,
18
  TASK_PROMPT,
19
  UNDERSTAND_TEST_RESULTS_PROMPT,
20
+ WEB_DEV_SYSTEM_PROMPT,
21
+ AI_SYSTEM_PROMPT,
22
+ WEB_DEV,
23
+ PYTHON_CODE_DEV,
24
+ HUGGINGFACE_FILE_DEV,
25
  )
26
  from app.utils import (
27
  parse_action,
28
  parse_file_content,
29
  read_python_module_structure,
30
+ extract_imports, # Unused import, consider removing or using
31
+ get_file, # Unused import, consider removing or using
32
  )
33
 
34
  # --- Constants ---
 
52
  # --- Initialize Hugging Face client ---
53
  client = InferenceClient(MODEL)
54
 
55
+
56
  # --- Classes ---
57
  class Agent:
58
  def __init__(self, name: str, agent_type: str, complexity: int):
59
  self.name = name
60
  self.type = agent_type
61
  self.complexity = complexity
62
+ self.tools: List[Tool] = []
63
 
64
+ def add_tool(self, tool: "Tool"):
65
  self.tools.append(tool)
66
 
67
  def __str__(self):
 
81
  def __init__(self):
82
  self.agents: List[Agent] = []
83
  self.tools: List[Tool] = []
84
+ self.history: str = ""
85
+ self.task: str = ""
86
+ self.purpose: str = ""
87
+ self.directory: str = ""
88
 
89
  def add_agent(self, agent: Agent):
90
  self.agents.append(agent)
 
92
  def add_tool(self, tool: Tool):
93
  self.tools.append(tool)
94
 
95
+ def generate_chat_app(self) -> str:
96
  time.sleep(2) # Simulate processing time
97
  return f"Chat app generated with {len(self.agents)} agents and {len(self.tools)} tools."
98
 
 
344
 
345
  # --- Sidebar ---
346
  st.sidebar.title("βš™οΈ Settings")
347
+ if "directory" not in st.session_state:
348
+ st.session_state.directory = "."
349
  pypelyne.directory = st.sidebar.text_input(
350
+ "Project Directory:",
351
+ value=st.session_state.directory,
352
+ help="Path to your coding project",
353
  )
354
+ st.session_state.directory = pypelyne.directory # Update session state
355
+ if "purpose" not in st.session_state:
356
+ st.session_state.purpose = ""
357
  pypelyne.purpose = st.sidebar.text_area(
358
  "Project Purpose:",
359
+ value=st.session_state.purpose,
360
  help="Describe the purpose of your coding project.",
361
  )
362
+ st.session_state.purpose = pypelyne.purpose # Update session state
363
 
364
  # --- Agent and Tool Management ---
365
  st.sidebar.header("πŸ€– Agents")
366
+ if "agents" not in st.session_state:
367
+ st.session_state.agents = []
368
  show_agent_creation = st.sidebar.expander(
369
  "Create New Agent", expanded=False
370
  )
 
374
  agent_complexity = st.slider("Complexity (1-5):", 1, 5, 3)
375
  if st.button("Add Agent"):
376
  create_agent(agent_name, agent_type, agent_complexity)
377
+ st.session_state.agents = pypelyne.agents # Update session state
378
 
379
  st.sidebar.header("πŸ› οΈ Tools")
380
+ if "tools" not in st.session_state:
381
+ st.session_state.tools = []
382
  show_tool_creation = st.sidebar.expander("Create New Tool", expanded=False)
383
  with show_tool_creation:
384
  tool_name = st.text_input("Tool Name:")
385
  tool_type = st.selectbox("Tool Type:", TOOL_TYPES)
386
  if st.button("Add Tool"):
387
  create_tool(tool_name, tool_type)
388
+ st.session_state.tools = pypelyne.tools # Update session state
389
 
390
  # --- Display Agents and Tools ---
391
  st.sidebar.subheader("Active Agents:")
392
+ for agent in st.session_state.agents:
393
  st.sidebar.write(f"- {agent}")
394
 
395
  st.sidebar.subheader("Available Tools:")
396
+ for tool in st.session_state.tools:
397
  st.sidebar.write(f"- {tool}")
398
 
399
  # --- Main Content Area ---
400
  st.header("πŸ’» Code Interaction")
401
 
402
+ if "task" not in st.session_state:
403
+ st.session_state.task = ""
404
  task_input = st.text_area(
405
  "🎯 Task:",
406
+ value=st.session_state.task,
407
  help="Describe the coding task you want to perform.",
408
  )
409
  if task_input:
410
  pypelyne.task = task_input
411
+ st.session_state.task = pypelyne.task # Update session state
412
 
413
  user_input = st.text_input(
414
  "πŸ’¬ Your Input:", help="Provide instructions or ask questions."