Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Massive Front End Update and Optimizations #78

Merged
merged 44 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
226a15c
In-progress double-sided popout;
JamesonRGrieve Apr 24, 2023
fb3d122
Updated UI in preparation for chains and prompts;
JamesonRGrieve Apr 24, 2023
e90bfc5
Update provider endpoint
Josh-XT Apr 25, 2023
af816a1
Replace on prompts to get rid of .txt
Josh-XT Apr 25, 2023
06937ff
Updated GUI;
JamesonRGrieve Apr 25, 2023
4b1d899
Fixed markdown file refs;
JamesonRGrieve Apr 25, 2023
12b37ed
Fixed markdown file folder;
JamesonRGrieve Apr 25, 2023
8b69d44
yarn lock
Josh-XT Apr 25, 2023
d2ec8e4
Pointed docs back to main branch;
JamesonRGrieve Apr 25, 2023
f7fbbf3
Updated README;
JamesonRGrieve Apr 25, 2023
f717169
Merge branch 'nextjs-2' of https://github.com/Josh-XT/Agent-LLM into …
JamesonRGrieve Apr 25, 2023
6f194cc
Added contact email to README;
JamesonRGrieve Apr 25, 2023
8596672
Added Facebook group;
JamesonRGrieve Apr 25, 2023
857518b
Added Twitter;
JamesonRGrieve Apr 25, 2023
0cb1daa
Reordered links;
JamesonRGrieve Apr 25, 2023
47a7328
Modifying task output
Josh-XT Apr 25, 2023
1e6bd06
Merge branch 'nextjs-2' of https://github.com/Josh-XT/AgentLLM into n…
Josh-XT Apr 25, 2023
725c5bd
naming
Josh-XT Apr 25, 2023
222bf8e
Fixed per Josh request;
JamesonRGrieve Apr 25, 2023
82667fd
Merge branch 'nextjs-2' of https://github.com/Josh-XT/Agent-LLM into …
JamesonRGrieve Apr 25, 2023
ac6d776
Changed a couple lines of README;
JamesonRGrieve Apr 25, 2023
a4080db
README updates;
JamesonRGrieve Apr 25, 2023
4b32fda
Still broken but less
Josh-XT Apr 25, 2023
8c23ef9
Merge branch 'nextjs-2' of https://github.com/Josh-XT/AgentLLM into n…
Josh-XT Apr 25, 2023
9ebab95
Fixed objective return;
JamesonRGrieve Apr 25, 2023
593a7e8
Add output list back
Josh-XT Apr 25, 2023
70f88e3
Updates
Josh-XT Apr 25, 2023
d11bd11
Added todo;
JamesonRGrieve Apr 25, 2023
026d1c8
super kill that task!
Josh-XT Apr 25, 2023
ed5f265
Merge branch 'nextjs-2' of https://github.com/Josh-XT/AgentLLM into n…
Josh-XT Apr 25, 2023
994591f
Reorg task agent
Josh-XT Apr 25, 2023
8e54ca6
Updates
Josh-XT Apr 25, 2023
f323436
Attempt to fix threading;
JamesonRGrieve Apr 25, 2023
1b9f625
Attempted fix;
JamesonRGrieve Apr 25, 2023
681308f
Attempted fix 2;
JamesonRGrieve Apr 25, 2023
28739a3
Partial rewrite of BabyAGI engine;
JamesonRGrieve Apr 25, 2023
2fbcc9d
A couple more fixes;
JamesonRGrieve Apr 25, 2023
ae31acd
maybe?
Josh-XT Apr 25, 2023
42e2f5a
cleanup
Josh-XT Apr 25, 2023
9c2bc7f
Fixed, hopefully;
JamesonRGrieve Apr 25, 2023
1e13093
Cleaned up prints;
JamesonRGrieve Apr 25, 2023
fc980e0
Demoved dequeue;
JamesonRGrieve Apr 25, 2023
ab90e64
Spacing;
JamesonRGrieve Apr 25, 2023
8e0c66f
Spacing again;
JamesonRGrieve Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AgentLLM.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def get_status(self):
def initialize_task_list(self):
self.task_list = deque([])

def update_output_list(self, output, task_id=None):
self.CFG.save_task_output(self.agent_name, output, task_id)
def update_output_list(self, output):
self.CFG.save_task_output(self.agent_name, output, self.primary_objective)

def display_objective_and_initial_task(self):
self.update_output_list(f"Objective: {self.primary_objective}")
Expand Down
33 changes: 20 additions & 13 deletions Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,26 +280,33 @@ def update_agent_config(self, agent_name, config):
with open(os.path.join("agents", agent_name, "config.json"), "w") as agent_config:
json.dump(config, agent_config)

def get_task_output(self, agent_name, task_id=None):
if task_id is None:
# Get the latest task
task_id = sorted(os.listdir(os.path.join("agents", agent_name, "tasks")))[-1].replace(".txt", "")
task_output_file = os.path.join("agents", agent_name, "tasks", f"{task_id}.txt")
def get_task_output(self, agent_name, primary_objective=None):
if primary_objective is None:
primary_objective = str(uuid.uuid4())
task_output_file = os.path.join("agents", agent_name, "tasks", f"{primary_objective}.txt")
if os.path.exists(task_output_file):
with open(task_output_file, "r") as f:
task_output = f.read()
else:
task_output = ""
return task_output
return task_output

def save_task_output(self, agent_name, task_output, task_id=None):
if task_id is None:
task_id = str(uuid.uuid4())
if not os.path.exists(os.path.join("agents", agent_name, "tasks")):
def save_task_output(self, agent_name, task_output, primary_objective=None):
# Check if agents/{agent_name}/tasks/task_name.txt exists
# If it does, append to it
# If it doesn't, create it
if "tasks" not in os.listdir(os.path.join("agents", agent_name)):
os.makedirs(os.path.join("agents", agent_name, "tasks"))
task_output_file = os.path.join("agents", agent_name, "tasks", f"{task_id}.txt")
with open(task_output_file, "w") as f:
f.write(task_output)
if primary_objective is None:
primary_objective = str(uuid.uuid4())
task_output_file = os.path.join("agents", agent_name, "tasks", f"{primary_objective}.txt")
if os.path.exists(task_output_file):
with open(task_output_file, "a") as f:
f.write(task_output)
else:
with open(task_output_file, "w") as f:
f.write(task_output)
return task_output

def get_chains(self):
chains = os.listdir("chains")
Expand Down
7 changes: 2 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ async def toggle_command(agent_name: str, payload: ToggleCommandPayload) -> Resp
@app.post("/api/agent/{agent_name}/task", tags=["Agent"])
async def toggle_task_agent(agent_name: str, objective: Objective) -> ResponseMessage:
if agent_name not in agent_instances:
if agent_name not in agent_instances:
agent_instances[agent_name] = AgentLLM(agent_name)
agent_instance = agent_instances[agent_name]
agent_instance.set_agent_name(agent_name)
agent_instance.set_objective(objective.objective)
agent_thread = threading.Thread(target=agent_instance.run_task)
agent_thread.start()
Expand All @@ -170,11 +167,11 @@ async def toggle_task_agent(agent_name: str, objective: Objective) -> ResponseMe
agent_instance.stop_running()

@app.get("/api/agent/{agent_name}/task", tags=["Agent"])
async def get_task_output(agent_name: str) -> TaskOutput:
async def get_task_output(agent_name: str, objective: str = None) -> TaskOutput:
if agent_name not in agent_instances:
raise HTTPException(status_code=404, detail="Task agent not found")
agent_instance = agent_instances[agent_name]
output = CFG.get_task_output(agent_name, agent_instance)
output = CFG.get_task_output(agent_name, primary_objective=objective)
if agent_instance.get_status():
return TaskOutput(output=output, message="Task agent is still running")
return TaskOutput(output=output)
Expand Down
42 changes: 15 additions & 27 deletions notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -107,14 +107,18 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'detail': 'Agent file /home/josh/josh/Repos/Agent-LLM/agents/new_test_agent.yaml not found.'}\n"
"ename": "NameError",
"evalue": "name 'new_name' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[13], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[39m# Test: Delete agent\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m delete_agent_endpoint \u001b[39m=\u001b[39m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mbase_uri\u001b[39m}\u001b[39;00m\u001b[39m/api/agent/\u001b[39m\u001b[39m{\u001b[39;00mnew_name\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m response \u001b[39m=\u001b[39m requests\u001b[39m.\u001b[39mdelete(delete_agent_endpoint)\n\u001b[1;32m 4\u001b[0m \u001b[39mprint\u001b[39m(response\u001b[39m.\u001b[39mjson())\n",
"\u001b[0;31mNameError\u001b[0m: name 'new_name' is not defined"
]
}
],
Expand All @@ -127,7 +131,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 14,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -251,17 +255,9 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'message': 'Task agent started'}\n"
]
}
],
"outputs": [],
"source": [
"# Test: Toggle task agent\n",
"# If it is running and you hit this endpoint, it should stop.\n",
Expand All @@ -273,17 +269,9 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'detail': 'Task agent not found'}\n"
]
}
],
"outputs": [],
"source": [
"# Test: Get task output\n",
"get_task_output_endpoint = f\"{base_uri}/api/agent/{agent_name}/task\"\n",
Expand Down