Documentation
¶
Overview ¶
Package citations provides shared citation and document types and helper functions used by both the connector and bridge packages.
Index ¶
- func AppendSourceDocumentPart(parts *[]map[string]any, seen map[string]struct{}, doc SourceDocument)
- func AppendSourceURLPart(parts *[]map[string]any, seen map[string]struct{}, url, title string, ...)
- func ProviderMetadata(c SourceCitation) map[string]any
- type GeneratedFilePart
- type SourceCitation
- type SourceDocument
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendSourceDocumentPart ¶
func AppendSourceDocumentPart(parts *[]map[string]any, seen map[string]struct{}, doc SourceDocument)
AppendSourceDocumentPart appends a deduplicated source-document part to parts.
func AppendSourceURLPart ¶
func AppendSourceURLPart(parts *[]map[string]any, seen map[string]struct{}, url, title string, providerMetadata map[string]any)
AppendSourceURLPart appends a deduplicated source-url part to parts.
func ProviderMetadata ¶
func ProviderMetadata(c SourceCitation) map[string]any
ProviderMetadata builds the providerMetadata map for a source-url part from a SourceCitation. The keys match what the desktop client reads (e.g. "siteName" in camelCase). Emit both siteName and site_name during transition.
Types ¶
type GeneratedFilePart ¶
GeneratedFilePart pairs a URL with its media type for generated files.
type SourceCitation ¶
type SourceCitation struct {
URL string
Title string
Description string
Published string
SiteName string
Author string
Image string
Favicon string
}
SourceCitation represents a URL citation extracted from AI tool output.
func AppendUniqueCitation ¶
func AppendUniqueCitation(citations []SourceCitation, c SourceCitation) []SourceCitation
AppendUniqueCitation appends a single citation, deduplicating by URL without allocating a map. Use this on hot paths (e.g. streaming) where citations arrive one at a time.
func ExtractWebSearchCitations ¶
func ExtractWebSearchCitations(output string) []SourceCitation
ExtractWebSearchCitations parses a JSON tool output containing web search results and returns the extracted source citations. The output is expected to be a JSON object with a "results" array of objects containing url, title, description, etc.
func MergeCitationFields ¶
func MergeCitationFields(dst, src SourceCitation) SourceCitation
MergeCitationFields fills empty fields of dst from src.
func MergeSourceCitations ¶
func MergeSourceCitations(existing, incoming []SourceCitation) []SourceCitation
MergeSourceCitations deduplicates citations by URL, merging fields when the same URL appears more than once.