Skip to content

fireworks

pixeltable.functions.fireworks

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

chat_completions

chat_completions(
    messages: JsonT,
    *,
    model: str,
    max_tokens: Optional[int] = None,
    top_k: Optional[int] = None,
    top_p: Optional[float] = None,
    temperature: Optional[float] = None
) -> JsonT

Creates a model response for the given chat conversation.

Equivalent to the Fireworks AI chat/completions API endpoint. For additional details, see: https://docs.fireworks.ai/api-reference/post-chatcompletions

Requirements:

  • pip install fireworks-ai

Parameters:

  • messages (JsonT) –

    A list of messages comprising the conversation so far.

  • model (str) –

    The name of the model to use.

For details on the other parameters, see: https://docs.fireworks.ai/api-reference/post-chatcompletions

Returns:

  • JsonT

    A dictionary containing the response and other metadata.

Examples:

Add a computed column that applies the model accounts/fireworks/models/mixtral-8x22b-instruct to an existing Pixeltable column tbl.prompt of the table tbl:

>>> messages = [{'role': 'user', 'content': tbl.prompt}]
... tbl['response'] = chat_completions(messages, model='accounts/fireworks/models/mixtral-8x22b-instruct')