citations

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package citations provides shared citation and document types and helper functions used by both the connector and bridge packages.

Index

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

type GeneratedFilePart struct {
	URL       string
	MediaType string
}

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.

type SourceDocument

type SourceDocument struct {
	ID        string
	Title     string
	Filename  string
	MediaType string
}

SourceDocument represents a file/document citation.

Jump to

Keyboard shortcuts

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