Skip to content

anthropic

pixeltable.functions.anthropic

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

messages

messages(
    messages: JsonT,
    *,
    model: str,
    max_tokens: int = 1024,
    metadata: Optional[JsonT] = None,
    stop_sequences: Optional[JsonT] = None,
    system: Optional[str] = None,
    temperature: Optional[float] = None,
    tool_choice: Optional[JsonT] = None,
    tools: Optional[JsonT] = None,
    top_k: Optional[int] = None,
    top_p: Optional[float] = None
) -> JsonT

Create a Message.

Equivalent to the Anthropic messages API endpoint. For additional details, see: https://docs.anthropic.com/en/api/messages

Requirements:

  • pip install anthropic

Parameters:

  • messages (JsonT) –

    Input messages.

  • model (str) –

    The model that will complete your prompt.

For details on the other parameters, see: https://docs.anthropic.com/en/api/messages

Returns:

  • JsonT

    A dictionary containing the response and other metadata.

Examples:

Add a computed column that applies the model claude-3-haiku-20240307 to an existing Pixeltable column tbl.prompt of the table tbl:

>>> msgs = [{'role': 'user', 'content': tbl.prompt}]
... tbl['response'] = messages(msgs, model='claude-3-haiku-20240307')