Commit Graph

4 Commits

Author SHA1 Message Date
teknium1 3a64df8873 feat: add pseudo-streaming SSE + conversation parameter
- stream=true now returns SSE (role chunk → content chunk → finish → [DONE])
  instead of 501. Not token-by-token but compatible with frontends like
  Open WebUI that require SSE format.
- Add conversation parameter for named session chaining (like /title).
  Mutually exclusive with previous_response_id.
2026-03-10 16:05:17 -07:00
teknium1 93a22a4245 feat: add conversation parameter + named session chaining
Like /title for sessions — clients can name conversations instead of
tracking response IDs manually:

  POST /v1/responses {input: 'hi', conversation: 'my-project'}
  POST /v1/responses {input: 'next step', conversation: 'my-project'}

Server automatically chains to the latest response in that conversation.
Mutually exclusive with previous_response_id (returns 400 if both set).
Not stored if store=false.

5 new tests (72 total).
2026-03-10 16:05:17 -07:00
teknium1 f46bd77ad2 feat: enhance Responses API — retrieval, deletion, tool calls, usage, CORS
- GET /v1/responses/{id} — retrieve stored responses
- DELETE /v1/responses/{id} — delete stored responses
- Tool call items in output (function_call + function_call_output)
- Real token counting from AIAgent (prompt/completion/total)
- Truncation parameter support (auto mode, max 100 messages)
- CORS middleware (Access-Control-Allow-Origin: *)
- Full response objects stored for retrieval
- 16 new tests (67 total)
2026-03-10 16:05:17 -07:00
teknium1 5e5d2bd79a feat: add OpenAI-compatible API server platform adapter (Phase 1)
Adds a new gateway platform adapter that exposes an HTTP server with
OpenAI-compatible endpoints, allowing any OpenAI-compatible frontend
(Open WebUI, LobeChat, etc.) to use hermes-agent as a backend.

Endpoints:
- POST /v1/chat/completions - OpenAI Chat Completions format (stateless)
- POST /v1/responses - OpenAI Responses API format (stateful via previous_response_id)
- GET /v1/models - lists hermes-agent as an available model
- GET /health - health check

Features:
- Bearer token auth via API_SERVER_KEY env var (unauthenticated when no key set)
- System messages/instructions become ephemeral system prompt (layered on top of core prompt)
- In-memory LRU response store for Responses API conversation chaining
- Agent runs in thread executor (run_conversation is synchronous)
- Streaming returns 501 (not yet implemented)

New files:
- gateway/platforms/api_server.py - APIServerAdapter class (~470 lines)
- tests/gateway/test_api_server.py - 51 tests covering all endpoints, auth, config

Modified files:
- gateway/config.py - Added Platform.API_SERVER enum, env var overrides, connected platforms
- gateway/run.py - Added _create_adapter() case, auth map entries, auth bypass
2026-03-10 16:05:17 -07:00