firebase

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 20 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, opts RetrieverOptions) (ai.Retriever, error)

DefineRetriever defines a Firestore vector retriever with the given configuration. The Firebase plugin must be registered with genkit.Init() before calling this function.

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 is the Firebase/GCP project ID. If set, a Firebase app is created automatically.
	// Can also be set via the FIREBASE_PROJECT_ID environment variable.
	ProjectId string
	// App is an existing Firebase app instance. Provide either ProjectId or App, not both.
	App *firebasev4.App
	// contains filtered or unexported fields
}

Firebase is the Genkit plugin for Firebase services. It provides integration with Firebase Firestore for retrievers, indexers, and durable streaming.

Usage:

g := genkit.Init(ctx, genkit.WithPlugins(&firebase.Firebase{ProjectId: "my-project"}))

Or with an existing Firebase app:

g := genkit.Init(ctx, genkit.WithPlugins(&firebase.Firebase{App: myFirebaseApp}))

func (*Firebase) Auth added in v1.3.0

func (f *Firebase) Auth(ctx context.Context) (*auth.Client, error)

Auth returns a cached Firebase Auth client for the Firebase project. The client is created lazily on first call and reused for subsequent calls.

func (*Firebase) Firestore added in v1.3.0

func (f *Firebase) Firestore(ctx context.Context) (*firestore.Client, error)

Firestore returns a cached Firestore client for the Firebase project. The client is created lazily on first call and reused for subsequent calls. This client is shared across all Firebase plugin features (retrievers, stream managers, etc.).

func (*Firebase) Init added in v0.5.2

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

Init initializes the Firebase plugin. Called automatically by genkit.Init().

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

Directories

Path Synopsis
Package exp provides experimental Firebase integrations for Genkit's agent runtime (see github.com/firebase/genkit/go/ai/exp).
Package exp provides experimental Firebase integrations for Genkit's agent runtime (see github.com/firebase/genkit/go/ai/exp).

Jump to

Keyboard shortcuts

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