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: Json,
*,
model: String,
max_tokens: Int = 1024,
metadata: Optional[Json] = None,
stop_sequences: Optional[Json] = None,
system: Optional[String] = None,
temperature: Optional[Float] = None,
tool_choice: Optional[Json] = None,
tools: Optional[Json] = None,
top_k: Optional[Int] = None,
top_p: Optional[Float] = None
) -> Json
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
(Json
) –Input messages.
-
model
(String
) –The model that will complete your prompt.
For details on the other parameters, see: https://docs.anthropic.com/en/api/messages
Returns:
-
Json
–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')