Skip to content

Agent Zero AI framework

Fixes for v0.6

frdela04ed7f0d719
diff --git a/README.md b/README.md
index d571112c1..d3079086b 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,9 @@
- Agent Zero is fully transparent, readable, comprehensible, customizable and interactive.
- Agent Zero uses the computer as a tool to accomplish its (your) tasks.
+## Now with UI:
+![UI prototype](docs/ui_screen1.png)
+
## Key concepts
1. **General-purpose assistant**
- Agent Zero is not pre-programmed for specific tasks (but can be). It is meant to be a general-purpose personal assistant. Give it a task, and it will gather information, execute commands and code, cooperate with other agent instances, and do its best to accomplish it.
@@ -62,6 +65,7 @@ If your agent fails to communicate properly, use tools, reason, use memory, find
Agent Zero is made to be used in an isolated virtual environment (for safety) with some tools preinstalled and configured.
If you cannot provide all the necessary conditions or API keys, just change the system prompt and tell your agent what operating system and tools are at its disposal. Nothing is hard-coded; if you do not tell your agent about a certain tool, it will not know about it and will not try to use it.
+
[![David Ondrej video](/docs/david_vid.jpg)](https://www.youtube.com/watch?v=_Pionjv4hGc)
## Known problems
@@ -78,6 +82,10 @@ If you cannot provide all the necessary conditions or API keys, just change the
## Setup
+> ⚠️ **Changes to launch files since v0.6:**
+> main.py file has been replaced with run_ui.py (webui) and run_cli.py (terminal) launch files.
+> configuration has been moved to initialize.py for both webui and terminal launch files.
+
Update: [Guide by CheezChat for Windows](./docs/win_installation_guide.txt)
1. **Required API keys:**
@@ -102,11 +110,17 @@ pip install -r requirements.txt
- You can choose between online models (OpenAI, Anthropic, Groq) or offline (Ollama, LMStudio, HuggingFace) for both.
4. **run Docker:**
-- Easiest way is to install Docker Desktop application and just run it. The rest will be handled by the framework itself.
+- Easiest way is to install Docker Desktop application ([Download](https://www.docker.com/products/docker-desktop/)) and just leave it running in the background.
+- You don't need to download and build any images, it will be done automatically by the framework at runtime.
## Run the program
-- Just run the **main.py** file in Python:
+- Just run the **run_ui.py** file in Python:
~~~bash
-python main.py
+python run_ui.py
~~~
+- And open the URL shown in the terminal:
+
+![Flask link](docs/flask_link.png)
+
- Or run it in debug mode in VS Code using the **debug** button in the top right corner of the editor. I have provided config files for VS Code for this purpose.
+- For the original command line interface you can run run_cli.py instead of run_ui.py
\ No newline at end of file
diff --git a/docs/flask_link.png b/docs/flask_link.png
new file mode 100644
index 000000000..1db2c8552
Binary files /dev/null and b/docs/flask_link.png differ
diff --git a/docs/ui_screen1.png b/docs/ui_screen1.png
new file mode 100644
index 000000000..d52340d97
Binary files /dev/null and b/docs/ui_screen1.png differ
diff --git a/initialize.py b/initialize.py
index ff4a42664..5aa904942 100644
--- a/initialize.py
+++ b/initialize.py
@@ -6,7 +6,7 @@ def initialize():
# main chat model used by agents (smarter, more accurate)
chat_llm = models.get_openai_chat(model_name="gpt-4o-mini", temperature=0)
# chat_llm = models.get_ollama_chat(model_name="gemma2:latest", temperature=0)
- chat_llm = models.get_lmstudio_chat(model_name="TheBloke/Mistral-7B-Instruct-v0.2-GGUF", temperature=0)
+ # chat_llm = models.get_lmstudio_chat(model_name="TheBloke/Mistral-7B-Instruct-v0.2-GGUF", temperature=0)
# chat_llm = models.get_openrouter(model_name="meta-llama/llama-3-8b-instruct:free")
# chat_llm = models.get_azure_openai_chat(deployment_name="gpt-4o-mini", temperature=0)
# chat_llm = models.get_anthropic_chat(model_name="claude-3-5-sonnet-20240620", temperature=0)
diff --git a/python/helpers/log.py b/python/helpers/log.py
index 1b6149f91..f3fa316a6 100644
--- a/python/helpers/log.py
+++ b/python/helpers/log.py
@@ -35,8 +35,8 @@ class Log:
def log(type: str, heading: str|None = None, content: str|None = None, kvps: dict|None = None):
item = LogItem(len(Log.logs), type, heading or "", content or "", kvps)
Log.logs.append(item)
- Log.version += 1
Log.last_updated = item.no
+ Log.version += 1
return item
@staticmethod
@@ -52,7 +52,7 @@ class Log:
if kvps is not None:
item.kvps = kvps
- Log.version += 1
Log.last_updated = no
+ Log.version += 1
else:
raise IndexError("Log item number out of range")
diff --git a/python/helpers/shell_ssh.py b/python/helpers/shell_ssh.py
index 0d4e9c177..c6a8886b0 100644
--- a/python/helpers/shell_ssh.py
+++ b/python/helpers/shell_ssh.py
@@ -77,7 +77,9 @@ class SSHInteractiveSession:
if self.last_command and len(self.last_command) > self.trimmed_command_length:
command_to_trim = self.last_command[self.trimmed_command_length:]
- trim_com, trim_out = calculate_valid_match_lengths(command_to_trim, data, deviation_threshold=8, deviation_reset=2, ignore_patterns=[rb'\x1b\[\?\d{4}[a-zA-Z]',rb'\r',rb'>'])
+ trim_com, trim_out = calculate_valid_match_lengths(
+ command_to_trim, data, deviation_threshold=8, deviation_reset=2,
+ ignore_patterns=[rb'\x1b\[\?\d{4}[a-zA-Z](?:> )?', rb'\r', rb'>'])
if(trim_com > 0 and trim_out > 0):
data = data[trim_out:]
self.trimmed_command_length += trim_com
diff --git a/python/tools/memory_tool.py b/python/tools/memory_tool.py
index a2ef0477c..e277521c7 100644
--- a/python/tools/memory_tool.py
+++ b/python/tools/memory_tool.py
@@ -5,7 +5,6 @@ from python.helpers import files
import os, json
from python.helpers.tool import Tool, Response
from python.helpers.print_style import PrintStyle
-from chromadb.errors import InvalidDimensionException
from python.helpers.log import Log
# databases based on subdirectories from agent config
@@ -26,7 +25,7 @@ class Memory(Tool):
result = forget(self.agent, kwargs["forget"])
elif "delete" in kwargs:
result = delete(self.agent, kwargs["delete"])
- except InvalidDimensionException as e:
+ except Exception as e:
# hint about embedding change with existing database
PrintStyle.hint("If you changed your embedding model, you will need to remove contents of /memory directory.")
Log(type="hint", content="If you changed your embedding model, you will need to remove contents of /memory directory.")
diff --git a/run_ui.py b/run_ui.py
index 8d9f39481..10e33153a 100644
--- a/run_ui.py
+++ b/run_ui.py
@@ -58,7 +58,7 @@ async def health_check():
# async def secret_page():
# return Path("./secret_page.html").read_text()
-# send message to agent
+# send message to agent (async UI)
@app.route('/msg', methods=['POST'])
async def handle_message():
try:
@@ -93,6 +93,41 @@ async def handle_message():
#respond with json
return jsonify(response)
+# send message to agent (synchronous API)
[email protected]('/msg_sync', methods=['POST'])
+async def handle_msg_sync():
+ try:
+
+ #agent instance
+ agent = get_agent()
+
+ #data sent to the server
+ input = request.get_json()
+ text = input.get("text", "")
+
+ # print to console and log
+ PrintStyle(background_color="#6C3483", font_color="white", bold=True, padding=True).print(f"User message:")
+ PrintStyle(font_color="white", padding=False).print(f"> {text}")
+ Log.log(type="user", heading="User message", content=text)
+
+ #pass the message to the agent
+ response = agent.communicate(text)
+
+ #data from this server
+ response = {
+ "ok": True,
+ "message": response,
+ }
+
+ except Exception as e:
+ response = {
+ "ok": False,
+ "message": str(e),
+ }
+
+ #respond with json
+ return jsonify(response)
+
# pausing/unpausing the agent
@app.route('/pause', methods=['POST'])
async def pause():
diff --git a/webui/index.css b/webui/index.css
index fde78f239..869f63b83 100644
--- a/webui/index.css
+++ b/webui/index.css
@@ -74,7 +74,7 @@ h4 {
.user-container {
align-self: flex-end;
margin-top: 2em;
- margin-bottom: 1.5em;
+ margin-bottom: 1em;
}
.ai-container {
@@ -184,7 +184,7 @@ h4 {
max-height: 9.375em; /* 150px */
padding: 0.625em 0.9375em; /* 10px 15px */
border: none;
- border-radius: 1.5625em; /* 25px */
+ border-radius: 1em; /* 25px */
background-color: #3d3d3d;
color: #e0e0e0;
font-size: 1em; /* 16px */
@@ -196,6 +196,7 @@ h4 {
}
.chat-button {
color: #1e1e1e;
+ font-size: 1em;
border: none;
border-radius: 50%;
width: 3.125em; /* 50px */
diff --git a/webui/index.html b/webui/index.html
index 4d23c1131..44407be99 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Agent Zero</title>
<link rel="stylesheet" href="index.css">
+
<script>
window.safeCall = function(name,...args){
if (window[name]) window[name](...args)
@@ -23,8 +24,8 @@
<div class="config-section" id="status-section" x-data="{ connected: true }">
<h3>Status</h3>
- <h4 class="connected" x-show="connected">✔ Connected</h4>
- <h4 class="disconnected" x-show="!connected">✖ Disconnected</h4>
+ <h4 class="connected" x-show="connected">&#10004; Connected</h4>
+ <h4 class="disconnected" x-show="!connected">&#10008; Disconnected</h4>
</div>
<div class="config-section" x-data="{ showQuickActions: true }">
@@ -88,9 +89,9 @@
</div>
<div id="input-section" x-data="{ paused: false }">
<textarea id="chat-input" placeholder="Type your message here..." rows="1"></textarea>
- <button class="chat-button" id="send-button">➤</button>
- <button class="chat-button pause-button" id="pause-button" @click="pauseAgent(true)" x-show="!paused">⏸</button>
- <button class="chat-button pause-button" id="unpause-button" @click="pauseAgent(false)" x-show="paused">▶</button>
+ <button class="chat-button" id="send-button">&#10148;</button>
+ <button class="chat-button pause-button" id="pause-button" @click="pauseAgent(true)" x-show="!paused">&#10074;&#10074;</button>
+ <button class="chat-button pause-button" id="unpause-button" @click="pauseAgent(false)" x-show="paused">&#9654;</button>
</div>
</div>
</div>