Skip to content

gemini

pixeltable.functions.gemini

Pixeltable UDFs that wrap various endpoints from the Google Gemini API. In order to use them, you must first pip install google-generativeai and configure your Gemini credentials, as described in the Working with Gemini tutorial.

generate_content async

generate_content(
    contents: String,
    *,
    model_name: String,
    candidate_count: Optional[Int] = None,
    stop_sequences: Optional[Json] = None,
    max_output_tokens: Optional[Int] = None,
    temperature: Optional[Float] = None,
    top_p: Optional[Float] = None,
    top_k: Optional[Int] = None,
    response_mime_type: Optional[String] = None,
    response_schema: Optional[Json] = None,
    presence_penalty: Optional[Float] = None,
    frequency_penalty: Optional[Float] = None
) -> Json

Generate content from the specified model. For additional details, see: https://ai.google.dev/gemini-api/docs

Request throttling: Applies the rate limit set in the config (section gemini, key rate_limit). If no rate limit is configured, uses a default of 600 RPM.

Requirements:

  • pip install google-generativeai

Parameters:

  • contents (String) –

    The input content to generate from.

  • model_name (String) –

    The name of the model to use.

For details on the other parameters, see: https://ai.google.dev/gemini-api/docs

Returns:

  • Json

    A dictionary containing the response and other metadata.

Examples:

Add a computed column that applies the model gemini-1.5-flash to an existing Pixeltable column tbl.prompt of the table tbl:

>>> tbl.add_computed_column(response=generate_content(tbl.prompt, model_name='gemini-1.5-flash'))