Skip to main content
Pixeltable UDFs that wrap various endpoints from the Groq API. In order to use them, you must first pip install groq and configure your Groq credentials, as described in the Working with Groq tutorial. View source on GitHub

UDFs


chat_completions() udf

Chat Completion API. Equivalent to the Groq chat/completions API endpoint. For additional details, see: https://console.groq.com/docs/api-reference#chat-create Request throttling: Applies the rate limit set in the config (section groq, key rate_limit). If no rate limit is configured, uses a default of 600 RPM. Requirements:
  • pip install groq
Signature:
chat_completions(
    messages: Json,
    model: String,
    model_kwargs: Optional[Json],
    tools: Optional[Json],
    tool_choice: Optional[Json]
)-> Json
Parameters: Returns:
  • Json: A dictionary containing the response and other metadata.
Example: Add a computed column that applies the model llama-3.1-8b-instant to an existing Pixeltable column tbl.prompt of the table tbl:
messages = [{'role': 'user', 'content': tbl.prompt}]
tbl.add_computed_column(response=chat_completions(messages, model='llama-3.1-8b-instant'))

invoke_tools() udf

Converts an OpenAI response dict to Pixeltable tool invocation format and calls tools._invoke(). Signature:
invoke_tools(
    tools: pixeltable.func.tools.Tools,
    response: pixeltable.exprs.expr.Expr
)-> pixeltable.exprs.inline_expr.InlineDict
I