feat(qa): add synthesis conversations with source retention (#52)
This commit is contained in:
@ -15,14 +15,15 @@ import (
|
||||
)
|
||||
|
||||
type UserInput struct {
|
||||
RankingModelID *string
|
||||
SummaryContext string
|
||||
SummaryPromptTokenBudget int
|
||||
SummaryModelID *string
|
||||
Language, RankingMode string
|
||||
GlobalLimit int
|
||||
Assets []models.UserAsset
|
||||
Sources []models.Source
|
||||
SourceArticleRetentionDays int
|
||||
RankingModelID *string
|
||||
SummaryContext string
|
||||
SummaryPromptTokenBudget int
|
||||
SummaryModelID *string
|
||||
Language, RankingMode string
|
||||
GlobalLimit int
|
||||
Assets []models.UserAsset
|
||||
Sources []models.Source
|
||||
}
|
||||
type Candidate struct {
|
||||
RelevanceScore float64
|
||||
@ -70,8 +71,10 @@ type GenerationOutcome struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
type Result struct {
|
||||
Summary *models.Summary `json:"summary"`
|
||||
Outcome GenerationOutcome `json:"outcome"`
|
||||
SourceArticles []models.SummarySourceArticle `json:"-"`
|
||||
SourceArticleRetentionDays int `json:"-"`
|
||||
Summary *models.Summary `json:"summary"`
|
||||
Outcome GenerationOutcome `json:"outcome"`
|
||||
}
|
||||
type GenerationRecord = Result
|
||||
type Repository interface {
|
||||
@ -166,11 +169,14 @@ func (u *useCase) Generate(ctx context.Context, userID string) (Result, error) {
|
||||
}
|
||||
out := GenerationOutcome{PromptBudget: summarybudget.Usage{RequestedTokens: requestedBudget}, ID: id, Language: input.Language, RankingMode: input.RankingMode, GlobalLimit: input.GlobalLimit, CreatedAt: u.Clock(), SourceStats: []SourceStat{}}
|
||||
resolved := ResolvedSummary{Summarizer: u.Summarizer}
|
||||
retainedSources := []models.SummarySourceArticle{}
|
||||
finish := func(status, code, content string) (Result, error) {
|
||||
out.Status = status
|
||||
out.FailureCode = code
|
||||
result := Result{Outcome: out}
|
||||
if content != "" {
|
||||
result.SourceArticles = retainedSources
|
||||
result.SourceArticleRetentionDays = input.SourceArticleRetentionDays
|
||||
result.Summary = &models.Summary{ID: NewID(), UserID: userID, Content: content, GeneratedAt: out.CreatedAt}
|
||||
if resolved.CatalogID != "" {
|
||||
result.Summary.SummaryModelID = &resolved.CatalogID
|
||||
@ -443,6 +449,9 @@ func (u *useCase) Generate(ctx context.Context, userID string) (Result, error) {
|
||||
if len(selected) == 0 {
|
||||
return finish("no_results", "", "")
|
||||
}
|
||||
for _, c := range selected {
|
||||
retainedSources = append(retainedSources, models.SummarySourceArticle{Title: c.Article.Title, Source: c.Article.Source, Content: c.Article.Content, URL: c.Article.URL, PublishedAt: c.Article.PublishedAt})
|
||||
}
|
||||
var content string
|
||||
if budgeted, ok := resolved.Summarizer.(BudgetedSummarizer); ok {
|
||||
budget := requestedBudget
|
||||
|
||||
Reference in New Issue
Block a user