services

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnalysisRetention = 10

AnalysisRetention is the number of most-recent analyses kept per (article, profile); older ones are pruned at the end of each digest generation. Analyses referenced by a digest are always kept regardless. Set from the --analysis-retention flag in main. 0 disables pruning.

View Source
var LLMMonitorRetention = 100

LLMMonitorRetention is the number of most-recent digest runs whose LLM calls are kept; older runs are pruned at the end of each generation. Set from the --llm-monitor-retention flag in main. 0 disables pruning.

Functions

func NewLLMRecorder added in v0.4.0

func NewLLMRecorder() llmgateway.Recorder

NewLLMRecorder returns the gateway recorder for the monitoring layer.

Types

type AnalysisServer

type AnalysisServer struct {
	protos.UnimplementedAnalysisServiceServer
}

AnalysisServer implements the AnalysisService gRPC service

func NewAnalysisServer

func NewAnalysisServer() *AnalysisServer

NewAnalysisServer creates a new Analysis server instance

func (*AnalysisServer) GetAllArticleAnalyses

GetAllArticleAnalyses retrieves all analysis results for a specific article

func (*AnalysisServer) ListGlossaryEntries added in v0.4.0

ListGlossaryEntries lists entries from the persistent global glossary.

func (*AnalysisServer) SetGlossaryOverride added in v0.4.0

SetGlossaryOverride sets a curated definition for a term and returns the updated entry.

type ArticleServer

type ArticleServer struct {
	protos.UnimplementedArticleServiceServer
}

ArticleServer implements the ArticleService gRPC service

func NewArticleServer

func NewArticleServer() *ArticleServer

NewArticleServer creates a new article server instance

func (*ArticleServer) GetArticle

GetArticle implements the GetArticle RPC method

func (*ArticleServer) GetArticleCounts

func (s *ArticleServer) GetArticleCounts(_ context.Context, filter *protos.ArticleFilter) (*protos.ArticleCountsResponse, error)

func (*ArticleServer) ListArticles

ListArticles implements the ListArticles RPC method

func (*ArticleServer) MarkFeedArticlesRead

func (s *ArticleServer) MarkFeedArticlesRead(_ context.Context, req *protos.MarkFeedReadRequest) (*emptypb.Empty, error)

func (*ArticleServer) UpdateArticle

UpdateArticle implements the UpdateArticle RPC method

type AutoConfigResult added in v0.2.0

type AutoConfigResult struct {
	ConfigYAML string
	Summary    string
	Confidence float64
}

AutoConfigResult is the agent's final output.

type CategoriesServer

type CategoriesServer struct {
	protos.UnimplementedCategoriesServiceServer
}

CategoriesServer implements the CategoriesService gRPC service

func NewCategoriesServer

func NewCategoriesServer() *CategoriesServer

NewCategoriesServer creates a new Categories server instance

func (*CategoriesServer) GetOrCreateCategory

GetOrCreateCategory implements the CategoriesService gRPC service

type DigestServer

type DigestServer struct {
	protos.UnimplementedDigestServiceServer
	// contains filtered or unexported fields
}

DigestServer implements the DigestService gRPC service

func NewDigestServer

func NewDigestServer(gw *llmgateway.Gateway, llms *LLMsServer) *DigestServer

NewDigestServer creates a new Digest server instance. The gateway is the single chokepoint for LLM calls (dedupe, summary, article analysis during ensureArticlesAnalyzed); llms is reused so we don't re-construct an LLMsServer on every digest.

func (*DigestServer) GenerateDigest

GenerateDigest generates a new digest, streaming progress events throughout the process

func (*DigestServer) GetDigest

GetDigest returns a single digest by Id

func (*DigestServer) GetDigestArticles

GetDigestArticles returns articles for a digest

func (*DigestServer) ListDigests

ListDigests retrieves all digests

type EffectiveEditorial added in v0.4.0

type EffectiveEditorial struct {
	ProfileId              string
	Provider               string
	Model                  string
	Persona                string
	WritingStyle           string
	Audience               string
	VibeScore              bool
	Glossary               bool
	StandardSynthesis      bool
	ComprehensiveSynthesis bool
	ExecutiveSummary       bool
	Categories             []models.CategoryDef // empty = default allowedCategories
	Scoring                scoring.Config
	Prompts                models.PromptOverrides
	StepProviders          map[string]models.StepProviderOverride // per-step provider/model overrides
}

EffectiveEditorial is a fully-resolved editorial config for one analysis run: the profile's choices layered over the live global AnalysisConfig, with the rubric expressed as a concrete scoring.Config. It is the single object the analysis pipeline reads, so the pipeline never touches config.Config or a profile directly.

func ResolveEditorial added in v0.4.0

func ResolveEditorial(profileId string, ed *models.ProfileEditorial) EffectiveEditorial

ResolveEditorial layers a profile's editorial over the LIVE global AnalysisConfig. Any empty/nil field in ed inherits the global value, so the "default" profile (which stores an empty editorial) always behaves exactly like today's single-tenant config — and keeps tracking config.json changes.

type FeedsServer

type FeedsServer struct {
	protos.UnimplementedFeedsServiceServer
	// contains filtered or unexported fields
}

FeedsServer implements the FeedsService gRPC service

func NewFeedsServer

func NewFeedsServer(queue *QueueServer, gw *llmgateway.Gateway) *FeedsServer

NewFeedsServer creates a new feeds server instance. gw powers AutoBuildFeed and may be nil when no LLM gateway is available (autobuild will then error).

func (*FeedsServer) ApplyFeeds

ApplyFeeds reconciles the stored feeds to match the desired set in the request.

func (*FeedsServer) AutoConfigFeed added in v0.2.0

AutoConfigFeed runs the autonomous LLM agent that discovers a feed's selectors (after probing and locking the scraping mode + headers), streaming each step then the final config.

func (*FeedsServer) BackfillFeedTopics added in v0.4.0

BackfillFeedTopics derives topic labels for each requested feed via the LLM and streams one event per feed. It reuses the autoconfig topic extractor, prefers the established vocabulary (stored topics + the caller's known topics), and keeps the batch internally consistent by feeding each result back into the vocabulary. It is read-only; the caller writes the topics back to feeds.yml.

func (*FeedsServer) DeleteFeed

func (*FeedsServer) DeleteFeeds

DeleteFeeds removes the given feeds (by id) from the database.

func (*FeedsServer) InspectArticle added in v0.2.0

InspectArticle scrapes a single article URL in the requested mode and, when selectors are supplied, returns the extracted content for selector testing.

func (*FeedsServer) InspectFeed added in v0.2.0

InspectFeed probes a feed URL (read-only, pre-registration) and returns its diagnosis plus sample article links for building a feed config.

func (*FeedsServer) ListFeeds

ListFeeds implements the ListFeeds RPC method

func (*FeedsServer) RefreshAllFeeds

func (*FeedsServer) RefreshFeed

func (*FeedsServer) RegisterFeed

func (s *FeedsServer) RegisterFeed(_ context.Context, req *protos.RegisterFeedRequest) (*emptypb.Empty, error)

type LLMRequest

type LLMRequest struct {
	// ProviderName selects an enabled provider by its config Name (highest priority).
	ProviderName string
	// ProviderType selects an enabled provider by type (used when ProviderName is empty).
	ProviderType string
	// Provider is the auto-detect token: it may be a provider type OR a config
	// profile name; the server figures out which. Used by the user-facing
	// --provider flag. Lower priority than the explicit ProviderName/ProviderType
	// fields above (which the internal profile/queue callers set directly).
	Provider  string
	ModelName string // may be "" (use provider default) or "auto"

	// Per-call overrides; nil/zero means inherit from ProviderConfig, then fall
	// back to the package-level defaults above.
	Temperature *float64
	MaxRetries  *int
	Timeout     *time.Duration
	MaxTokens   int
}

LLMRequest describes how to look up and configure a provider for a single call. Zero values mean "use the analysis config default".

type LLMsServer

type LLMsServer struct {
	protos.UnimplementedLLMsServiceServer
	// contains filtered or unexported fields
}

LLMsServer implements the LLMsService gRPC service

func NewLLMsServer

func NewLLMsServer(gw *llmgateway.Gateway) *LLMsServer

NewLLMsServer creates a new LLMs server instance. The gateway is the single chokepoint for every LLM call the server makes; see pkg/llmgateway.

func (*LLMsServer) AnalyzeArticle

AnalyzeArticle analyzes an article using the default model

func (*LLMsServer) AnalyzeArticleOneShot

func (s *LLMsServer) AnalyzeArticleOneShot(ctx context.Context, req *protos.AnalyzeArticleWithProviderModelRequest, onTask func(taskName, status string, taskIndex, totalTasks int, err error)) (*protos.AnalyzeArticleWithProviderModelResponse, error)

func (*LLMsServer) AnalyzeArticleWithProgress

func (s *LLMsServer) AnalyzeArticleWithProgress(ctx context.Context, req *protos.AnalyzeArticleWithProviderModelRequest, onTask func(taskName, status string, taskIndex, totalTasks int, err error)) (*protos.AnalyzeArticleWithProviderModelResponse, error)

AnalyzeArticleWithProgress is like AnalyzeArticleWithProviderModel but invokes the provided callback for each pipeline task start/completion so callers can forward progress events.

func (*LLMsServer) AnalyzeArticleWithProviderModel

AnalyzeArticleWithProviderModel analyzes an article using sequential Eino ChatModelAgent calls.

func (*LLMsServer) BackfillGlossaryTerms added in v0.4.0

func (s *LLMsServer) BackfillGlossaryTerms(ctx context.Context, articleId, analysisId, provider, model string, onTask func(taskName, status string, taskIndex, totalTasks int, err error)) error

BackfillGlossaryTerms runs only the glossary extraction task for an article that already has an analysis and writes the result back via UpdateArticleAnalysisGlossaryTerms. It is called when a digest requests glossary but the cached analysis pre-dates glossary being enabled. An empty result is stored as "[]" (the sentinel meaning "ran, found nothing") so the article is not re-processed on subsequent digest runs.

func (*LLMsServer) GetAnalysisConfig

GetAnalysisConfig returns the current analysis configuration

func (*LLMsServer) GetAvailableModels

GetAvailableModels fetches available models from all configured providers concurrently.

func (*LLMsServer) GetLLMProviders

GetLLMProviders returns the current LLM provider configurations

func (*LLMsServer) PreviewAnalysisPrompt

PreviewAnalysisPrompt builds the prompt for an article without sending it to an LLM

func (*LLMsServer) ResolveLLM added in v0.2.0

ResolveLLM resolves a provider/model selection to the concrete provider type and model name a run would use, via the same path the actual calls take.

func (*LLMsServer) SaveLLMProviders

func (s *LLMsServer) SaveLLMProviders(_ context.Context, req *protos.SaveLLMProvidersRequest) (*emptypb.Empty, error)

SaveLLMProviders updates the LLM provider configurations

func (*LLMsServer) StreamAnalyzeArticle

StreamAnalyzeArticle is the streaming version that sends progress events per task.

type QueueServer

type QueueServer struct {
	protos.UnimplementedQueueServiceServer
	// contains filtered or unexported fields
}

QueueServer implements the server-side analysis queue.

Concurrency model: the LLM-call cap lives in the Gateway (which llms uses internally). QueueServer keeps its own `workerSem` only to bound how many goroutines it spawns from a large backlog, not to bound LLM calls. That budget is auto-derived from maxConcurrentLLMRequests (4× with a floor of 4) so a 10k-article backlog does not spawn 10k parked goroutines.

func NewQueueServer

func NewQueueServer(llms *LLMsServer, maxConcurrentLLMRequests int) *QueueServer

NewQueueServer creates a new QueueServer with a reference to the LLMs service. The optional maxConcurrentLLMRequests seeds the queue's worker fan-out budget (not the LLM-call cap, which lives in the Gateway).

func (*QueueServer) ClearQueue

func (s *QueueServer) ClearQueue(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

func (*QueueServer) DequeueArticle

func (s *QueueServer) DequeueArticle(_ context.Context, req *protos.DequeueArticleRequest) (*emptypb.Empty, error)

func (*QueueServer) EnqueueArticles

func (*QueueServer) StartQueue

func (s *QueueServer) StartQueue(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

func (*QueueServer) StopQueue

func (s *QueueServer) StopQueue(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

func (*QueueServer) StreamQueueProgress

func (s *QueueServer) StreamQueueProgress(_ *emptypb.Empty, stream protos.QueueService_StreamQueueProgressServer) error

type ResolvedLLM

type ResolvedLLM struct {
	Provider     llmprovider.ChatModelProvider
	ProviderType string
	ModelName    string
	Timeout      time.Duration
	MaxRetries   int
}

ResolvedLLM bundles a ready-to-use provider with the resolved identifiers.

func ResolveLLM

func ResolveLLM(req LLMRequest) (*ResolvedLLM, error)

ResolveLLM performs provider lookup, "auto" model resolution, default application, and provider construction in one place.

type ServerConfigServer

type ServerConfigServer struct {
	protos.UnimplementedServerConfigServiceServer
}

ServerConfigServer implements the ServerConfigService gRPC service

func NewServerConfigServer

func NewServerConfigServer() *ServerConfigServer

NewServerConfigServer creates a new ServerConfig server instance

func (*ServerConfigServer) GetConfig

ServerConfigServer implements the ServerConfigService gRPC service

func (*ServerConfigServer) SaveConfig

ServerConfigServer implements the ServerConfigService gRPC service

func (*ServerConfigServer) UpdateAnalysisConfig

UpdateAnalysisConfig updates the analysis configuration

Jump to

Keyboard shortcuts

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