Documentation
¶
Overview ¶
Package backend is the engine-side HTTP client for everything the engine needs from fh-backend: agent registration, log ingestion, LLM chat, RAG queries. All requests authenticate with the engine's agent secret via the Agent-Key header (validated by the backend's AgentKeyAuth middleware).
Index ¶
- Constants
- func NewBackendProvider(c *Client, id llmproxy.ProviderID, models []llmproxy.ModelInfo) llmproxy.Provider
- type Client
- func (c *Client) Chat(ctx context.Context, req *llmproxy.ChatRequest) (*llmproxy.ChatResponse, error)
- func (c *Client) GetProviders(ctx context.Context) ([]llmproxy.ProviderInfo, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) Heartbeat(ctx context.Context, publicAddress string) error
- func (c *Client) Hydrate(ctx context.Context) ([]workflow.MemoryFile, error)
- func (c *Client) Push(ctx context.Context, uid, content string) error
- func (c *Client) QueryRAG(ctx context.Context, params engine.RAGQueryParams) ([]engine.RAGQueryResult, error)
- func (c *Client) Register(ctx context.Context, reg engine.AgentRegistration) error
Constants ¶
const ( // BootCallbackTimeout caps the one-shot boot callback HTTP call so a // single unreachable backend cannot wedge engine startup. BootCallbackTimeout = 10 * time.Second // RegisterRetryInterval is the wait between failed Register attempts // when the backend is unreachable at engine startup. RegisterRetryInterval = 30 * time.Second // ProviderLoadTimeout caps the one-shot /llm/providers fetch used to // discover backend-routed LLM fallbacks at engine startup. ProviderLoadTimeout = 10 * time.Second // HeartbeatInterval is the cadence at which HeartbeatLoop ticks. Sized // at one third of the backend's 90s online-threshold so a single missed // tick does not flip the agent to offline. HeartbeatInterval = 30 * time.Second // HeartbeatTimeout caps a single heartbeat HTTP call so a hung attempt // cannot wedge the loop. HeartbeatTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func NewBackendProvider ¶
func NewBackendProvider(c *Client, id llmproxy.ProviderID, models []llmproxy.ModelInfo) llmproxy.Provider
NewBackendProvider creates a backendRoutedProvider for the given provider ID and model list.
Types ¶
type Client ¶
type Client struct {
BackendURL string
AgentSecret string
// contains filtered or unexported fields
}
Client is the engine-side HTTP client for backend interactions. All requests carry the Agent-Key authorization header.
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, req *llmproxy.ChatRequest) (*llmproxy.ChatResponse, error)
Chat forwards a chat request through the backend's /llm/generate route. The backend dispatches it to whichever underlying provider owns the model.
func (*Client) GetProviders ¶
GetProviders fetches the list of LLM providers configured on the backend and the models they expose. Used by the engine to decide which upstream providers it can fall back to via the backend.
func (*Client) Health ¶
Health pings the backend's LLM service and returns nil if every configured provider on the backend is healthy.
func (*Client) Heartbeat ¶
Heartbeat performs a single POST /agents/heartbeat. The publicAddress is the externally reachable URL of this engine, e.g. "http://10.0.1.50:8081", or "" for Cloud-mode engines behind NAT.
func (*Client) Hydrate ¶ added in v1.0.2
Hydrate pulls every memory file owned by the calling agent. The Manager calls this on a cold start to seed an empty local working copy.
func (*Client) Push ¶ added in v1.0.2
Push mirrors new content for the memory file identified by uid to the backend. The Manager calls this best-effort after every local write. The backend rejects unknown uids (404) and oversized payloads (413).
func (*Client) QueryRAG ¶
func (c *Client) QueryRAG(ctx context.Context, params engine.RAGQueryParams) ([]engine.RAGQueryResult, error)
QueryRAG forwards a similarity-search query through the backend's /rag/query route and returns the ranked results.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
httpclient
Package httpclient is a minimal JSON HTTP client vendored into the engine so the fh-backend capability implementation has no dependency on the closed fh-backend module.
|
Package httpclient is a minimal JSON HTTP client vendored into the engine so the fh-backend capability implementation has no dependency on the closed fh-backend module. |