55 lines
2.0 KiB
Bash
55 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# hermes-observe.sh - Web research utility using Hermes Agent tools
|
|
# Usage: hermes-observe.sh <query> <output_file>
|
|
#
|
|
# Demonstrates: web_search, web_extract tool usage
|
|
# Output: JSON file with search results and extracted content
|
|
|
|
set -euo pipefail
|
|
|
|
QUERY="${1:-Hermes Agent tools}"
|
|
OUTPUT_FILE="${2:-$HOME/.hermes/wizard-outputs/spark/research-$(date +%s).json}"
|
|
|
|
# Ensure output directory exists
|
|
mkdir -p "$(dirname "$OUTPUT_FILE")"
|
|
|
|
# Use the built-in web_search tool (via tool_call bridge in actual sessions)
|
|
# For demonstration, we'll use curl with a simple search API
|
|
|
|
# Check if we're in a Hermes agent context with tools available
|
|
if command -v hermes &>/dev/null; then
|
|
# Use hermes-web-search if available in the profile
|
|
echo "{\"status\":\"starting\",\"query\":\"$QUERY\"}" > "$OUTPUT_FILE"
|
|
|
|
# Perform search using hermes chat in single-query mode
|
|
hermes chat -q "Search for current information about: $QUERY. Extract key facts and URLs. Return as JSON with 'results' array containing 'title', 'url', 'summary' fields." 2>> "${OUTPUT_FILE}.log" >> "$OUTPUT_FILE" || true
|
|
else
|
|
# Fallback: direct web research using available tools
|
|
echo "{\"status\":\"direct_research\",\"query\":\"$QUERY\",\"results\":[]" > "$OUTPUT_FILE"
|
|
|
|
# Use web search through tool_call mechanism
|
|
python3 << 'SCRIPT' >> "$OUTPUT_FILE" 2>> "${OUTPUT_FILE}.log"
|
|
import sys
|
|
import json
|
|
|
|
# Try to use hermes tools if available
|
|
try:
|
|
# Check if we're in a Hermes runtime
|
|
from model_tools import handle_function_call
|
|
from hermes_tools import web_search, web_extract
|
|
|
|
# Perform the search
|
|
result = web_search("Hermes Agent tools", limit=5)
|
|
print(result)
|
|
except ImportError:
|
|
# Not in Hermes context, provide fallback info
|
|
print(json.dumps({
|
|
"status": "fallback",
|
|
"note": "hermes_tools not available in this context",
|
|
"docs_url": "https://hermes-agent.nousresearch.com/docs"
|
|
}))
|
|
SCRIPT
|
|
fi
|
|
|
|
echo "Research complete. Output: $OUTPUT_FILE"
|
|
cat "$OUTPUT_FILE" |