Documentation
¶
Index ¶
- type ReflectionInput
- type Service
- func (s *Service) CreateTag(ctx context.Context, name, description string) (*knowledgeModel.KnowledgeTag, error)
- func (s *Service) DeleteKnowledge(ctx context.Context, id types.KnowledgeID, reason string, author types.UserID, ...) error
- func (s *Service) DeleteTag(ctx context.Context, id types.KnowledgeTagID) error
- func (s *Service) GetKnowledge(ctx context.Context, id types.KnowledgeID) (*knowledgeModel.Knowledge, error)
- func (s *Service) ListKnowledgeLogs(ctx context.Context, knowledgeID types.KnowledgeID) ([]*knowledgeModel.KnowledgeLog, error)
- func (s *Service) ListTags(ctx context.Context) ([]*knowledgeModel.KnowledgeTag, error)
- func (s *Service) MergeTags(ctx context.Context, oldID, newID types.KnowledgeTagID) error
- func (s *Service) RunReflection(ctx context.Context, llmClient gollem.LLMClient, toolSet gollem.ToolSet, ...) error
- func (s *Service) SaveKnowledge(ctx context.Context, k *knowledgeModel.Knowledge, message string, ...) error
- func (s *Service) SearchKnowledge(ctx context.Context, category types.KnowledgeCategory, ...) ([]*knowledgeModel.Knowledge, error)
- func (s *Service) UpdateTag(ctx context.Context, id types.KnowledgeTagID, name, description string) (*knowledgeModel.KnowledgeTag, error)
- type ServiceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReflectionInput ¶ added in v0.14.0
type ReflectionInput struct {
Category types.KnowledgeCategory
// ExecutionSummary is a text summary of the execution history.
// This is provided instead of raw History to avoid gollem type coupling.
ExecutionSummary string
// Set only for ticket resolve reflection
Ticket *ticket.Ticket
TicketID types.TicketID
// OnComplete is called when the background reflection finishes.
// ctx is a non-cancelled context safe for I/O operations.
// traceID is the trace ID used for the reflection execution (empty if tracing is not configured).
OnComplete func(ctx context.Context, traceID string)
}
ReflectionInput holds the input for the knowledge reflection agent.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides knowledge management operations.
func New ¶
func New(repo interfaces.Repository, embeddingModel interfaces.EmbeddingClient, opts ...ServiceOption) *Service
New creates a new knowledge service.
func (*Service) CreateTag ¶ added in v0.14.0
func (s *Service) CreateTag(ctx context.Context, name, description string) (*knowledgeModel.KnowledgeTag, error)
CreateTag creates a new tag. Returns existing tag if name already exists (case-insensitive).
func (*Service) DeleteKnowledge ¶ added in v0.14.0
func (s *Service) DeleteKnowledge(ctx context.Context, id types.KnowledgeID, reason string, author types.UserID, ticketID types.TicketID) error
DeleteKnowledge records a deletion log then physically deletes the knowledge.
func (*Service) DeleteTag ¶ added in v0.14.0
DeleteTag deletes a tag and removes it from all knowledges that reference it.
func (*Service) GetKnowledge ¶
func (s *Service) GetKnowledge(ctx context.Context, id types.KnowledgeID) (*knowledgeModel.Knowledge, error)
GetKnowledge retrieves a specific knowledge by ID.
func (*Service) ListKnowledgeLogs ¶ added in v0.14.0
func (s *Service) ListKnowledgeLogs(ctx context.Context, knowledgeID types.KnowledgeID) ([]*knowledgeModel.KnowledgeLog, error)
ListKnowledgeLogs retrieves change history for a knowledge.
func (*Service) ListTags ¶ added in v0.14.0
func (s *Service) ListTags(ctx context.Context) ([]*knowledgeModel.KnowledgeTag, error)
ListTags returns all knowledge tags.
func (*Service) MergeTags ¶ added in v0.14.0
MergeTags merges oldID into newID: replaces oldID with newID in all knowledges, then deletes oldID.
func (*Service) RunReflection ¶ added in v0.14.0
func (s *Service) RunReflection(ctx context.Context, llmClient gollem.LLMClient, toolSet gollem.ToolSet, input *ReflectionInput) error
RunReflection launches a background reflection agent that extracts knowledge from the given execution summary and saves it to the knowledge store. The toolSet must be a knowledge tool in ModeReadWrite for the target category. Caller is responsible for creating the tool to avoid import cycles.
func (*Service) SaveKnowledge ¶
func (s *Service) SaveKnowledge(ctx context.Context, k *knowledgeModel.Knowledge, message string, ticketID types.TicketID) error
SaveKnowledge creates or updates a knowledge entry, recording a log. If k.ID is empty, a new ID is generated (create). All tag IDs are validated to exist before saving.
func (*Service) SearchKnowledge ¶ added in v0.14.0
func (s *Service) SearchKnowledge(ctx context.Context, category types.KnowledgeCategory, tagIDs []types.KnowledgeTagID, query string, limit int) ([]*knowledgeModel.Knowledge, error)
SearchKnowledge performs hybrid search (cosine similarity + BM25 + RRF) on knowledges filtered by category and tags.
func (*Service) UpdateTag ¶ added in v0.14.0
func (s *Service) UpdateTag(ctx context.Context, id types.KnowledgeTagID, name, description string) (*knowledgeModel.KnowledgeTag, error)
UpdateTag updates an existing tag.
type ServiceOption ¶ added in v0.14.0
type ServiceOption func(*Service)
ServiceOption configures a Service.
func WithTraceRepository ¶ added in v0.14.0
func WithTraceRepository(repo trace.Repository) ServiceOption
WithTraceRepository sets the trace repository for reflection tracing.