firebase

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextProvider added in v0.3.0

func ContextProvider(ctx context.Context, g *genkit.Genkit, policy AuthPolicy) (core.ContextProvider, error)

ContextProvider creates a Firebase context provider for Genkit actions.

func DefineRetriever added in v0.5.2

func DefineRetriever(ctx context.Context, g *genkit.Genkit, cfg RetrieverOptions) (ai.Retriever, error)

DefineRetriever defines a Retriever with the given configuration.

func EnableFirebaseTelemetry added in v1.0.0

func EnableFirebaseTelemetry(options *FirebaseTelemetryOptions)

EnableFirebaseTelemetry enables comprehensive telemetry export to Genkit Monitoring, backed by Google Cloud Observability (Cloud Logging, Metrics, and Trace).

Example usage:

// Basic usage - uses environment variables for project ID
firebase.EnableFirebaseTelemetry(nil)
g, err := genkit.Init(ctx, genkit.WithPlugins(&googlegenai.GoogleAI{}))

// With full configuration
firebase.EnableFirebaseTelemetry(&firebase.FirebaseTelemetryOptions{
	ProjectID:                  "my-firebase-project",
	ForceDevExport:             true,
	DisableLoggingInputAndOutput: false,
	DisableMetrics:             false,
	DisableTraces:              false,
	MetricExportIntervalMillis: &[]int{10000}[0], // 10 seconds
})
g, err := genkit.Init(ctx, genkit.WithPlugins(&googlegenai.GoogleAI{}))

Types

type AuthClient

type AuthClient interface {
	VerifyIDToken(context.Context, string) (*auth.Token, error)
}

AuthClient is a client for the Firebase Auth service.

type AuthContext added in v0.3.0

type AuthContext = *auth.Token

AuthContext is the context of an authenticated request.

type AuthPolicy added in v0.3.0

type AuthPolicy = func(context.Context, AuthContext, json.RawMessage) error

AuthPolicy is a function that validates an incoming request.

type Firebase added in v0.5.2

type Firebase struct {
	ProjectId string          // Firebase project ID.
	App       *firebasev4.App // Firebase app instance.
	// contains filtered or unexported fields
}

Firebase FireStore passes configuration options to the plugin.

func (*Firebase) Init added in v0.5.2

func (f *Firebase) Init(ctx context.Context) []api.Action

Init initializes the Firebase plugin.

func (*Firebase) Name added in v0.5.2

func (f *Firebase) Name() string

Name returns the name of the plugin.

type FirebaseTelemetryOptions added in v1.0.0

type FirebaseTelemetryOptions struct {
	// ProjectID is the Firebase/Google Cloud project ID.
	// If empty, will be auto-detected from environment variables in priority order:
	// 1. FIREBASE_PROJECT_ID, 2. GOOGLE_CLOUD_PROJECT, 3. GCLOUD_PROJECT
	ProjectID string

	// Credentials for authenticating with Google Cloud.
	// If nil, uses Application Default Credentials (ADC).
	// Primarily intended for use in environments outside of GCP.
	// On GCP, credentials will typically be inferred from the environment via ADC.
	Credentials *google.Credentials

	// Sampler controls trace sampling. If nil, uses AlwaysOnSampler.
	// Examples: AlwaysOnSampler, AlwaysOffSampler, TraceIdRatioBasedSampler
	Sampler sdktrace.Sampler

	// MetricExportIntervalMillis controls metrics export frequency.
	// Google Cloud requires minimum 5000ms. Defaults to 5000 (dev) or 300000 (prod).
	MetricExportIntervalMillis *int

	// MetricExportTimeoutMillis controls metrics export timeout.
	// Defaults to match MetricExportIntervalMillis.
	MetricExportTimeoutMillis *int

	// DisableMetrics disables metric export to Google Cloud.
	// Traces and logs may still be exported. Defaults to false.
	DisableMetrics bool

	// DisableTraces disables trace export to Google Cloud.
	// Metrics and logs may still be exported. Defaults to false.
	DisableTraces bool

	// DisableLoggingInputAndOutput disables input/output logging.
	// Defaults to false (input/output logging enabled).
	DisableLoggingInputAndOutput bool

	// ForceDevExport forces telemetry export even in development environment.
	// Defaults to false (only exports in production unless forced).
	ForceDevExport bool
}

FirebaseTelemetryOptions provides comprehensive configuration for Firebase telemetry. This matches the Google Cloud plugin options for full compatibility, with Firebase-specific project ID resolution that checks FIREBASE_PROJECT_ID first.

Environment Variables: - GENKIT_ENV: Set to "dev" to disable export unless ForceDevExport is true - FIREBASE_PROJECT_ID: Project ID for telemetry if not provided inline - GOOGLE_CLOUD_PROJECT: Project ID for telemetry if not provided inline - GCLOUD_PROJECT: Project ID for telemetry if not provided inline

type RetrieverOptions added in v0.3.0

type RetrieverOptions struct {
	Name            string                    // Name of the retriever
	Label           string                    // Label for the retriever
	Collection      string                    // Firestore collection name
	Embedder        ai.Embedder               // Embedder instance for generating embeddings
	VectorField     string                    // Field name for storing vectors
	MetadataFields  []string                  // List of metadata fields to retrieve
	ContentField    string                    // Field name for storing content
	Limit           int                       // Limit on the number of results
	DistanceMeasure firestore.DistanceMeasure // Distance measure for vector similarity
}

RetrieverOptions struct for retriever configuration

type VectorType added in v0.3.0

type VectorType int

Jump to

Keyboard shortcuts

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