mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-26 01:01:40 +00:00
* feat: OpenAI-compatible API server platform adapter Salvaged from PR #956, updated for current main. Adds an HTTP API server as a gateway platform adapter that exposes hermes-agent via the OpenAI Chat Completions and Responses APIs. Any OpenAI-compatible frontend (Open WebUI, LobeChat, LibreChat, AnythingLLM, NextChat, ChatBox, etc.) can connect by pointing at http://localhost:8642/v1. Endpoints: - POST /v1/chat/completions — stateless Chat Completions API - POST /v1/responses — stateful Responses API with chaining - GET /v1/responses/{id} — retrieve stored response - DELETE /v1/responses/{id} — delete stored response - GET /v1/models — list hermes-agent as available model - GET /health — health check Features: - Real SSE streaming via stream_delta_callback (uses main's streaming) - In-memory LRU response store for Responses API conversation chaining - Named conversations via 'conversation' parameter - Bearer token auth (optional, via API_SERVER_KEY) - CORS support for browser-based frontends - System prompt layering (frontend system messages on top of core) - Real token usage tracking in responses Integration points: - Platform.API_SERVER in gateway/config.py - _create_adapter() branch in gateway/run.py - API_SERVER_* env vars in hermes_cli/config.py - Env var overrides in gateway/config.py _apply_env_overrides() Changes vs original PR #956: - Removed streaming infrastructure (already on main via stream_consumer.py) - Removed Telegram reply_to_mode (separate feature, not included) - Updated _resolve_model() -> _resolve_gateway_model() - Updated stream_callback -> stream_delta_callback - Updated connect()/disconnect() to use _mark_connected()/_mark_disconnected() - Adapted to current Platform enum (includes MATTERMOST, MATRIX, DINGTALK) Tests: 72 new tests, all passing Docs: API server guide, Open WebUI integration guide, env var reference * feat(whatsapp): make reply prefix configurable via config.yaml Reworked from PR #1764 (ifrederico) to use config.yaml instead of .env. The WhatsApp bridge prepends a header to every outgoing message. This was hardcoded to '⚕ *Hermes Agent*'. Users can now customize or disable it via config.yaml: whatsapp: reply_prefix: '' # disable header reply_prefix: '🤖 *My Bot*\n───\n' # custom prefix How it works: - load_gateway_config() reads whatsapp.reply_prefix from config.yaml and stores it in PlatformConfig.extra['reply_prefix'] - WhatsAppAdapter reads it from config.extra at init - When spawning bridge.js, the adapter passes it as WHATSAPP_REPLY_PREFIX in the subprocess environment - bridge.js handles undefined (default), empty (no header), or custom values with \\n escape support - Self-chat echo suppression uses the configured prefix Also fixes _config_version: was 9 but ENV_VARS_BY_VERSION had a key 10 (TAVILY_API_KEY), so existing users at v9 would never be prompted for Tavily. Bumped to 10 to close the gap. Added a regression test to prevent this from happening again. Credit: ifrederico (PR #1764) for the bridge.js implementation and the config version gap discovery. --------- Co-authored-by: Test <test@test.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_api_server.py | ||
| test_async_memory_flush.py | ||
| test_background_command.py | ||
| test_background_process_notifications.py | ||
| test_base_topic_sessions.py | ||
| test_channel_directory.py | ||
| test_config.py | ||
| test_config_cwd_bridge.py | ||
| test_delivery.py | ||
| test_dingtalk.py | ||
| test_discord_bot_filter.py | ||
| test_discord_free_response.py | ||
| test_discord_imports.py | ||
| test_discord_media_metadata.py | ||
| test_discord_opus.py | ||
| test_discord_send.py | ||
| test_discord_slash_commands.py | ||
| test_discord_thread_persistence.py | ||
| test_document_cache.py | ||
| test_email.py | ||
| test_extract_local_files.py | ||
| test_gateway_shutdown.py | ||
| test_homeassistant.py | ||
| test_honcho_lifecycle.py | ||
| test_hooks.py | ||
| test_interrupt_key_match.py | ||
| test_matrix.py | ||
| test_mattermost.py | ||
| test_media_extraction.py | ||
| test_mirror.py | ||
| test_pairing.py | ||
| test_pii_redaction.py | ||
| test_plan_command.py | ||
| test_platform_base.py | ||
| test_reasoning_command.py | ||
| test_resume_command.py | ||
| test_retry_replacement.py | ||
| test_retry_response.py | ||
| test_run_progress_topics.py | ||
| test_runner_fatal_adapter.py | ||
| test_runner_startup_failures.py | ||
| test_send_image_file.py | ||
| test_session.py | ||
| test_session_env.py | ||
| test_session_hygiene.py | ||
| test_signal.py | ||
| test_slack.py | ||
| test_sms.py | ||
| test_ssl_certs.py | ||
| test_status.py | ||
| test_status_command.py | ||
| test_sticker_cache.py | ||
| test_stt_config.py | ||
| test_telegram_conflict.py | ||
| test_telegram_documents.py | ||
| test_telegram_format.py | ||
| test_telegram_photo_interrupts.py | ||
| test_telegram_text_batching.py | ||
| test_title_command.py | ||
| test_transcript_offset.py | ||
| test_update_command.py | ||
| test_voice_command.py | ||
| test_whatsapp_connect.py | ||
| test_whatsapp_reply_prefix.py | ||