Documentation
¶
Index ¶
- func ContextProvider(ctx context.Context, g *genkit.Genkit, policy AuthPolicy) (core.ContextProvider, error)
- func DefineRetriever(ctx context.Context, g *genkit.Genkit, opts RetrieverOptions) (ai.Retriever, error)
- func EnableFirebaseTelemetry(options *FirebaseTelemetryOptions)
- type AuthClient
- type AuthContext
- type AuthPolicy
- type Firebase
- type FirebaseTelemetryOptions
- type RetrieverOptions
- type VectorType
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 ¶
AuthClient is a client for the Firebase Auth service.
type AuthContext ¶ added in v0.3.0
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
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
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.).
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