Spaces:
Runtime error
Runtime error
acecalisto3
commited on
Commit
•
27dcdec
1
Parent(s):
d6e7b65
Update app.py
Browse files
app.py
CHANGED
@@ -43,11 +43,18 @@ I am confident that I can leverage my expertise to assist you in developing and
|
|
43 |
return agent_prompt
|
44 |
|
45 |
def autonomous_build(self, chat_history, workspace_projects):
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
# Use a Hugging Face model for more advanced logic (e.g., a summarization model)
|
53 |
summarizer = pipeline("summarization")
|
@@ -58,14 +65,19 @@ I am confident that I can leverage my expertise to assist you in developing and
|
|
58 |
# Function to save an agent's prompt to a file and commit to the Hugging Face repository
|
59 |
def save_agent_to_file(agent):
|
60 |
"""Saves the agent's prompt to a file locally and then commits to the Hugging Face repository."""
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
66 |
file.write(agent.create_agent_prompt())
|
67 |
-
|
|
|
68 |
file.write(f"Agent Name: {agent.name}\nDescription: {agent.description}")
|
|
|
69 |
st.session_state.available_agents.append(agent.name)
|
70 |
|
71 |
commit_and_push_changes(f"Add agent {agent.name}")
|
@@ -73,9 +85,9 @@ def save_agent_to_file(agent):
|
|
73 |
# Function to load an agent's prompt from a file
|
74 |
def load_agent_prompt(agent_name):
|
75 |
"""Loads an agent prompt from a file."""
|
76 |
-
|
77 |
-
if os.path.exists(
|
78 |
-
with open(
|
79 |
agent_prompt = file.read()
|
80 |
return agent_prompt
|
81 |
else:
|
@@ -113,11 +125,8 @@ def chat_interface_with_agent(input_text, agent_name):
|
|
113 |
input_ids = input_ids[:, :max_input_length]
|
114 |
|
115 |
# Generate chatbot response
|
116 |
-
|
117 |
-
|
118 |
-
)
|
119 |
-
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
120 |
-
return response
|
121 |
|
122 |
# Workspace interface for creating projects
|
123 |
def workspace_interface(project_name):
|
@@ -125,8 +134,7 @@ def workspace_interface(project_name):
|
|
125 |
if not os.path.exists(PROJECT_ROOT):
|
126 |
os.makedirs(PROJECT_ROOT)
|
127 |
if not os.path.exists(project_path):
|
128 |
-
os.
|
129 |
-
st.session_state.workspace_projects[project_name] = {"files": []}
|
130 |
st.session_state.current_state['workspace_chat']['project_name'] = project_name
|
131 |
commit_and_push_changes(f"Create project {project_name}")
|
132 |
return f"Project {project_name} created successfully."
|
|
|
43 |
return agent_prompt
|
44 |
|
45 |
def autonomous_build(self, chat_history, workspace_projects):
|
46 |
+
"""
|
47 |
+
Autonomous build logic based on chat history and workspace projects.
|
48 |
+
"""
|
49 |
+
summary = "Chat History:\n" + "\n".join([f"User: {u}\nAgent: {a}" for u, a in chat_history])
|
50 |
+
summary += "\n\nWorkspace Projects:\n" + '\n'.join([f"{p}: {', '.join(details.keys())}" for p, details in workspace_projects.items()])
|
51 |
+
|
52 |
+
# Use Hugging Face models for advanced logic
|
53 |
+
summarizer = pipeline("summarization")
|
54 |
+
summary_output = summarizer(summary, max_length=100, min_length=50, do_sample=False)[0]['summary_text']
|
55 |
+
|
56 |
+
sentiment_analyzer = pipeline("sentiment-analysis")
|
57 |
+
sentiment_output = sentiment_analyzer(summary)[0]
|
58 |
|
59 |
# Use a Hugging Face model for more advanced logic (e.g., a summarization model)
|
60 |
summarizer = pipeline("summarization")
|
|
|
65 |
# Function to save an agent's prompt to a file and commit to the Hugging Face repository
|
66 |
def save_agent_to_file(agent):
|
67 |
"""Saves the agent's prompt to a file locally and then commits to the Hugging Face repository."""
|
68 |
+
agents_path = os.path.join(PROJECT_ROOT, AGENT_DIRECTORY)
|
69 |
+
if not os.path.exists(agents_path):
|
70 |
+
os.makedirs(agents_path)
|
71 |
+
|
72 |
+
agent_file = os.path.join(agents_path, f"{agent.name}.txt")
|
73 |
+
config_file = os.path.join(agents_path, f"{agent.name}Config.txt")
|
74 |
+
|
75 |
+
with open(agent_file, "w") as file:
|
76 |
file.write(agent.create_agent_prompt())
|
77 |
+
|
78 |
+
with open(config_file, "w") as file:
|
79 |
file.write(f"Agent Name: {agent.name}\nDescription: {agent.description}")
|
80 |
+
|
81 |
st.session_state.available_agents.append(agent.name)
|
82 |
|
83 |
commit_and_push_changes(f"Add agent {agent.name}")
|
|
|
85 |
# Function to load an agent's prompt from a file
|
86 |
def load_agent_prompt(agent_name):
|
87 |
"""Loads an agent prompt from a file."""
|
88 |
+
agent_file = os.path.join(AGENT_DIRECTORY, f"{agent_name}.txt")
|
89 |
+
if os.path.exists(agent_file):
|
90 |
+
with open(agent_file, "r") as file:
|
91 |
agent_prompt = file.read()
|
92 |
return agent_prompt
|
93 |
else:
|
|
|
125 |
input_ids = input_ids[:, :max_input_length]
|
126 |
|
127 |
# Generate chatbot response
|
128 |
+
chatbot_response = generator(input_ids, max_length=150, min_length=30, do_sample=True)[0]['generated_text']
|
129 |
+
return chatbot_response
|
|
|
|
|
|
|
130 |
|
131 |
# Workspace interface for creating projects
|
132 |
def workspace_interface(project_name):
|
|
|
134 |
if not os.path.exists(PROJECT_ROOT):
|
135 |
os.makedirs(PROJECT_ROOT)
|
136 |
if not os.path.exists(project_path):
|
137 |
+
os topscorer.session_state.workspace_projects[project_name] = {"files": []}
|
|
|
138 |
st.session_state.current_state['workspace_chat']['project_name'] = project_name
|
139 |
commit_and_push_changes(f"Create project {project_name}")
|
140 |
return f"Project {project_name} created successfully."
|