brainresearch

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SynthesisSchemaVersion  = "research_synthesis.v1"
	SynthesisPromptVersion  = "brain-research-synthesis-v2"
	DefaultMaxEvidenceChars = 24000
)
View Source
const (
	SchemaVersion = "research_pack.v1"
)

Variables

View Source
var ErrSynthesisUnavailable = errors.New("synthesis model is not configured")

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Key   string `json:"key"`
	Count int    `json:"count"`
}

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func New

func New(cfg config.Config, st *store.Store) *Builder

func (*Builder) Build

func (b *Builder) Build(ctx context.Context, opts Options) (Pack, error)

type Citation

type Citation struct {
	SourceKey string `json:"source_key"`
	Title     string `json:"title,omitempty"`
	URL       string `json:"url,omitempty"`
	NotePath  string `json:"note_path,omitempty"`
	Kind      string `json:"kind,omitempty"`
}

type Coverage

type Coverage struct {
	EvidenceCount     int      `json:"evidence_count"`
	ByKind            []Bucket `json:"by_kind"`
	BySourceType      []Bucket `json:"by_source_type"`
	TopUserTags       []Bucket `json:"top_user_tags,omitempty"`
	ExactTagMatches   []Bucket `json:"exact_tag_matches,omitempty"`
	ItemTextMatches   int      `json:"item_text_matches,omitempty"`
	SourceTextMatches int      `json:"source_text_matches,omitempty"`
	TopicNodeCount    int      `json:"topic_node_count,omitempty"`
	TopicEdgeCount    int      `json:"topic_edge_count,omitempty"`
	DisplayedLimit    int      `json:"displayed_limit"`
	RelatedLimit      int      `json:"related_limit,omitempty"`
	RecallNote        string   `json:"recall_note,omitempty"`
}

type Options

type Options struct {
	Question        string
	Topic           string
	Limit           int
	SourceTypes     []string
	IncludeRelated  bool
	RelatedLimit    int
	SeedLimit       int
	IncludeTopic    *bool
	MaxCharsPerDoc  int
	PlannerModel    string
	PlannerTimeout  time.Duration
	PlannerBinary   string
	UseModelPlanner bool
	DisablePlanner  bool
}

type Pack

type Pack struct {
	SchemaVersion    string            `json:"schema_version"`
	Question         string            `json:"question"`
	Mode             string            `json:"mode"`
	QueryPlan        QueryPlan         `json:"query_plan"`
	Coverage         Coverage          `json:"coverage"`
	Topic            string            `json:"topic,omitempty"`
	UsedTopicBrief   bool              `json:"used_topic_brief"`
	Evidence         []ask.Evidence    `json:"evidence"`
	ExactTagEvidence []ask.Evidence    `json:"exact_tag_evidence,omitempty"`
	TopicBrief       *TopicBrief       `json:"topic_brief,omitempty"`
	NextSteps        []SuggestedAction `json:"next_steps,omitempty"`
}

func Build

func Build(ctx context.Context, cfg config.Config, st *store.Store, opts Options) (Pack, error)

type PreparedSynthesis

type PreparedSynthesis struct {
	SchemaVersion string             `json:"schema_version"`
	Question      string             `json:"question"`
	Model         string             `json:"model"`
	PromptVersion string             `json:"prompt_version"`
	Input         string             `json:"-"`
	Truncation    TruncationMetadata `json:"truncation"`
	Citations     []Citation         `json:"citations,omitempty"`
	Warnings      []string           `json:"answer_warnings,omitempty"`
	Status        string             `json:"answer_status"`
}

func PrepareSynthesis

func PrepareSynthesis(cfg config.Config, opts SynthesisOptions) (PreparedSynthesis, error)

type QueryConcept

type QueryConcept struct {
	Key       string   `json:"key"`
	Preferred string   `json:"preferred,omitempty"`
	Terms     []string `json:"terms"`
	Required  bool     `json:"required"`
}

type QueryPlan

type QueryPlan struct {
	TextQuery         string         `json:"text_query"`
	QueryTerms        []string       `json:"query_terms"`
	TagQueries        []string       `json:"tag_queries"`
	QueryVariants     []QueryVariant `json:"query_variants,omitempty"`
	Concepts          []QueryConcept `json:"concepts,omitempty"`
	Planner           string         `json:"planner,omitempty"`
	PlannerModel      string         `json:"planner_model,omitempty"`
	PlannerError      string         `json:"planner_error,omitempty"`
	SourceTypes       []string       `json:"source_types,omitempty"`
	Limit             int            `json:"limit"`
	MaxCharsPerDoc    int            `json:"max_chars_per_doc"`
	IncludeRelated    bool           `json:"include_related"`
	RelatedLimit      int            `json:"related_limit,omitempty"`
	Topic             string         `json:"topic,omitempty"`
	TopicSource       string         `json:"topic_source,omitempty"`
	IncludeTopicBrief bool           `json:"include_topic_brief"`
}

type QueryVariant

type QueryVariant struct {
	Query  string `json:"query"`
	Reason string `json:"reason,omitempty"`
}

type SuggestedAction

type SuggestedAction struct {
	Action string                 `json:"action"`
	Label  string                 `json:"label"`
	Reason string                 `json:"reason,omitempty"`
	Params map[string]interface{} `json:"params,omitempty"`
}

type SynthesisOptions

type SynthesisOptions struct {
	Question         string
	Pack             Pack
	Model            string
	CLI              string
	Length           string
	Timeout          time.Duration
	MaxEvidenceChars int
	Binary           string
}

type SynthesisResult

type SynthesisResult struct {
	SchemaVersion string             `json:"schema_version"`
	Question      string             `json:"question"`
	Answer        string             `json:"answer"`
	AnswerStatus  string             `json:"answer_status"`
	Warnings      []string           `json:"answer_warnings,omitempty"`
	Truncation    TruncationMetadata `json:"truncation"`
	Citations     []Citation         `json:"citations,omitempty"`
	PromptVersion string             `json:"prompt_version"`
	Model         string             `json:"model"`
	Tool          string             `json:"tool"`
	ToolVersion   string             `json:"tool_version"`
}

func RunPreparedSynthesis

func RunPreparedSynthesis(ctx context.Context, cfg config.Config, prepared PreparedSynthesis, opts SynthesisOptions) (SynthesisResult, error)

func Synthesize

func Synthesize(ctx context.Context, cfg config.Config, opts SynthesisOptions) (SynthesisResult, error)

type TopicBrief

type TopicBrief struct {
	Topic        string                `json:"topic"`
	SourceTypes  []string              `json:"source_types,omitempty"`
	SeedLimit    int                   `json:"seed_limit"`
	RelatedLimit int                   `json:"related_limit"`
	Summary      string                `json:"summary"`
	Pivots       topics.TopicPivots    `json:"pivots,omitempty"`
	Entities     []topics.TopicEntity  `json:"entities,omitempty"`
	Nodes        []topics.TopicMapNode `json:"nodes"`
	Edges        []topics.TopicMapEdge `json:"edges"`
}

type TruncationMetadata

type TruncationMetadata struct {
	EvidenceBudgetChars       int      `json:"evidence_budget_chars"`
	EvidenceCharsUsed         int      `json:"evidence_chars_used"`
	DroppedSourceKeys         []string `json:"dropped_source_keys,omitempty"`
	PartiallyTrimmedSourceKey string   `json:"partially_trimmed_source_key,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL