Skip to content

Agent Zero AI framework

minor context window fixes

frdelea9c8bf63bd6
diff --git a/agent.py b/agent.py
index b59516aa0..0b8a09666 100644
--- a/agent.py
+++ b/agent.py
@@ -404,9 +404,11 @@ class Agent:
): # if agent has custom folder, use it and use default as backup
prompt_dir = files.get_abs_path("prompts", self.config.prompts_subdir)
backup_dir.append(files.get_abs_path("prompts/default"))
- return files.read_file(
+ prompt = files.read_file(
files.get_abs_path(prompt_dir, file), _backup_dirs=backup_dir, **kwargs
)
+ prompt = files.remove_code_fences(prompt)
+ return prompt
def get_data(self, field: str):
return self.data.get(field, None)
diff --git a/python/helpers/history.py b/python/helpers/history.py
index 5617bc480..e2e9231f2 100644
--- a/python/helpers/history.py
+++ b/python/helpers/history.py
@@ -145,7 +145,7 @@ class Topic(Record):
for msg, tok, leng, out in large_msgs:
trim_to_chars = leng * (msg_max_size / tok)
trunc = messages.truncate_dict_by_ratio(
- self.history.agent, out, trim_to_chars * 1.15, trim_to_chars * 0.85
+ self.history.agent, out["content"], trim_to_chars * 1.15, trim_to_chars * 0.85
)
msg.summary = trunc
diff --git a/python/helpers/settings.py b/python/helpers/settings.py
index 5672befa3..fe18528c4 100644
--- a/python/helpers/settings.py
+++ b/python/helpers/settings.py
@@ -112,16 +112,6 @@ def convert_out(settings: Settings) -> SettingsOutput:
}
)
- chat_model_fields.append(
- {
- "id": "chat_model_kwargs",
- "title": "Chat model additional parameters",
- "description": "Any other parameters supported by the model. Format is KEY=VALUE on individual lines, just like .env file.",
- "type": "textarea",
- "value": _dict_to_env(settings["chat_model_kwargs"]),
- }
- )
-
chat_model_fields.append(
{
"id": "chat_model_ctx_length",
@@ -129,7 +119,8 @@ def convert_out(settings: Settings) -> SettingsOutput:
"description": "Maximum number of tokens in the context window for LLM. System prompt, chat history, RAG and response all count towards this limit.",
"type": "input",
"value": settings["chat_model_ctx_length"],
- })
+ }
+ )
chat_model_fields.append(
{
@@ -141,8 +132,18 @@ def convert_out(settings: Settings) -> SettingsOutput:
"max": 1,
"step": 0.01,
"value": settings["chat_model_ctx_history"],
- })
-
+ }
+ )
+
+ chat_model_fields.append(
+ {
+ "id": "chat_model_kwargs",
+ "title": "Chat model additional parameters",
+ "description": "Any other parameters supported by the model. Format is KEY=VALUE on individual lines, just like .env file.",
+ "type": "textarea",
+ "value": _dict_to_env(settings["chat_model_kwargs"]),
+ }
+ )
chat_model_section: SettingsSection = {
"title": "Chat Model",
@@ -483,7 +484,6 @@ def normalize_settings(settings: Settings) -> Settings:
return copy
-
def get_chat_model(settings: Settings | None = None) -> BaseChatModel:
if not settings:
settings = get_settings()
diff --git a/webui/history.js b/webui/history.js
index 5332e11ab..27f83e5fd 100644
--- a/webui/history.js
+++ b/webui/history.js
@@ -11,7 +11,7 @@ export async function openCtxWindowModal() {
const win = await window.sendJsonData("/ctx_window_get", { context: getContext() });
const data = win.content
const size = win.tokens
- await showEditorModal(data, "text", `Context window ~${size} tokens`,"Data passed to the LLM during last interaction. Contains system message, conversation history and RAG.");
+ await showEditorModal(data, "markdown", `Context window ~${size} tokens`,"Data passed to the LLM during last interaction. Contains system message, conversation history and RAG.");
}
async function showEditorModal(data, type = "json", title, description="") {
@@ -33,6 +33,7 @@ async function showEditorModal(data, type = "json", title, description="") {
editor.session.setMode("ace/mode/" + type);
editor.setValue(data);
+ editor.clearSelection();
// editor.session.$toggleFoldWidget(5, {})
}
}