geminicommon

package
v1.4.430 Latest Latest
Warning

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

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

Documentation

Overview

Package geminicommon provides shared utilities for Gemini API integrations. Used by both the standalone Gemini provider (API key auth) and VertexAI provider (ADC auth).

Index

Constants

View Source
const (
	CitationHeader    = "\n\n## Sources\n\n"
	CitationSeparator = "\n"
	CitationFormat    = "- [%s](%s)"
)

Citation formatting constants

Variables

This section is empty.

Functions

func ConvertMessages

func ConvertMessages(msgs []*chat.ChatCompletionMessage) []*genai.Content

ConvertMessages converts fabric chat messages to genai Content format. Gemini's API only accepts "user" and "model" roles, so other roles are mapped to "user".

func ExtractCitations

func ExtractCitations(response *genai.GenerateContentResponse) []string

ExtractCitations extracts web citations from grounding metadata.

func ExtractText

func ExtractText(response *genai.GenerateContentResponse) string

ExtractText extracts just the text parts from a Gemini response.

func ExtractTextWithCitations

func ExtractTextWithCitations(response *genai.GenerateContentResponse) string

ExtractTextWithCitations extracts text content from the response and appends any web citations in a standardized format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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