Documentation
¶
Overview ¶
Package fakes provides httptest servers standing in for the three network boundaries of decision-backed kb flows: the OpenRouter decisions endpoint (Jev), OpenRouter chat completions (generation) and Firecrawl scrape. Tests use them to exercise real vault flows without the network (spec §17).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Call ¶
type Call struct {
Model string
State json.RawMessage
Questions map[string]Question
}
Call is one decoded decisions request.
func (Call) StateString ¶
StateString returns the raw JSON state as text (for substring rules).
type DecideFunc ¶
DecideFunc answers one question of a call. Returning nil falls back to the server default (noul 0.05; choice picks the exit option `none`, `unknown`, `other` or `different` when present, else the first option; score 0).
type Firecrawl ¶
Firecrawl is a fake Firecrawl server. Point [firecrawl].api_url at URL.
func NewFirecrawl ¶
func NewFirecrawl(scrape ScrapeFunc) *Firecrawl
NewFirecrawl starts a fake Firecrawl server.
func (*Firecrawl) Requests ¶
func (f *Firecrawl) Requests() []ScrapeRequest
Requests returns a copy of every scrape request received.
type GenRequest ¶
GenRequest is one recorded generation request.
type GenerateFunc ¶
GenerateFunc answers one generation request: schema name and the user prompt; it returns the JSON object to place in the message content.
type OpenRouter ¶
type OpenRouter struct {
*httptest.Server
CostPerCall float64
// contains filtered or unexported fields
}
OpenRouter is a fake OpenRouter serving /alpha/decisions and /v1/chat/completions. Point [openrouter].api_url at URL.
func NewOpenRouter ¶
func NewOpenRouter(decide DecideFunc, generate GenerateFunc) *OpenRouter
NewOpenRouter starts a fake OpenRouter. Close it with t.Cleanup(srv.Close).
func (*OpenRouter) Calls ¶
func (f *OpenRouter) Calls() []Call
Calls returns a copy of every decisions request received.
func (*OpenRouter) GenCalls ¶
func (f *OpenRouter) GenCalls() []GenRequest
GenCalls returns a copy of every generation request received.
func (*OpenRouter) QuestionCount ¶
func (f *OpenRouter) QuestionCount(prefix string) int
QuestionCount counts received questions whose id starts with prefix.
func (*OpenRouter) SetDecide ¶
func (f *OpenRouter) SetDecide(decide DecideFunc)
SetDecide replaces the decide rule.
func (*OpenRouter) SetGenerate ¶
func (f *OpenRouter) SetGenerate(generate GenerateFunc)
SetGenerate replaces the generate rule.
type ScrapeFunc ¶
type ScrapeFunc func(req ScrapeRequest) ScrapeResponse
ScrapeFunc answers one scrape request.
type ScrapeRequest ¶
type ScrapeRequest struct {
URL string `json:"url"`
Formats []string `json:"formats"`
MaxAge *int64 `json:"maxAge,omitempty"`
WaitFor *int64 `json:"waitFor,omitempty"`
OnlyMainContent *bool `json:"onlyMainContent,omitempty"`
}
ScrapeRequest is one decoded Firecrawl /v2/scrape request.