A bit of restructuring for simplicity and organization

This commit is contained in:
teknium
2025-10-01 23:29:25 +00:00
parent 0411ca1880
commit a7ff4d49e9
8 changed files with 2005 additions and 1945 deletions

28
pyproject.toml Normal file
View File

@@ -0,0 +1,28 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "hermes-agent"
version = "0.1.0"
description = "AI agent with advanced tool-calling and toolsets"
readme = "README.md"
requires-python = ">=3.10"
authors = [{ name = "Hermes Agent" }]
license = { text = "MIT" }
dependencies = [
"firecrawl-py",
"openai",
"fal-client",
"python-dotenv",
"fire"
]
[project.scripts]
hermes-agent = "run_agent:main"
[tool.setuptools]
py-modules = ["run_agent", "model_tools", "toolsets"]
[tool.setuptools.packages.find]
include = ["tools"]

View File

@@ -13,6 +13,16 @@ PROMPT="$1"
# Set debug mode for web tools
export WEB_TOOLS_DEBUG=true
# Resolve repository root relative to this script and run from there
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$REPO_ROOT"
# Prefer local venv if present
if [ -f "venv/bin/activate" ]; then
source venv/bin/activate
fi
# Run the agent with the provided prompt
python run_agent.py \
--query "$PROMPT" \

0
tests/__init__.py Normal file
View File

View File

@@ -23,8 +23,8 @@ import argparse
from datetime import datetime
from typing import List, Dict, Any
# Import the web tools to test
from web_tools import (
# Import the web tools to test (updated path after moving tools/)
from tools.web_tools import (
web_search_tool,
web_extract_tool,
web_crawl_tool,

View File

@@ -22,8 +22,6 @@ Usage:
import json
import os
from typing import Optional, Dict, Any
from hecate import run_tool_with_lifecycle_management
from morphcloud._llm import ToolCall
# Detailed description for the terminal tool based on Hermes Terminal system prompt
TERMINAL_TOOL_DESCRIPTION = """Execute commands on a secure, persistent Linux VM environment with full interactive application support.
@@ -114,6 +112,22 @@ def terminal_tool(
>>> result = terminal_tool(command="sleep 60", background=True)
"""
try:
# Import hecate and ToolCall lazily so this module can be imported
# even when hecate is not installed. If unavailable, gracefully
# indicate that the terminal tool is disabled.
try:
from hecate import run_tool_with_lifecycle_management
from morphcloud._llm import ToolCall
except ImportError:
return json.dumps({
"output": "",
"screen": "",
"session_id": None,
"exit_code": -1,
"error": "Terminal tool is disabled: 'hecate' is not installed. Install with: pip install hecate",
"status": "disabled"
})
# Build tool input based on provided parameters
tool_input = {}

View File

@@ -574,11 +574,15 @@ async def web_extract_tool(
{
"title": r.get("title", ""),
"content": r.get("content", ""),
"error": r.get("error")
"error": r.get("error"),
**({"llm_model": model} if use_llm_processing else {})
}
for r in response.get("results", [])
]
trimmed_response = {"results": trimmed_results}
# Include model name used for summarization when LLM processing was requested
if use_llm_processing:
trimmed_response["llm_model"] = model
result_json = json.dumps(trimmed_response, indent=2)
# Clean base64 images from extracted content
@@ -847,11 +851,15 @@ async def web_crawl_tool(
{
"title": r.get("title", ""),
"content": r.get("content", ""),
"error": r.get("error")
"error": r.get("error"),
**({"llm_model": model} if use_llm_processing else {})
}
for r in response.get("results", [])
]
trimmed_response = {"results": trimmed_results}
# Include model name used for summarization when LLM processing was requested
if use_llm_processing:
trimmed_response["llm_model"] = model
result_json = json.dumps(trimmed_response, indent=2)
# Clean base64 images from crawled content