Skip to main content
Pixeltable UDFs for AWS Bedrock AI models. Provides integration with AWS Bedrock for accessing various foundation models including Anthropic Claude, Amazon Titan, and other providers. View source on GitHub

UDFs


converse() udf

Generate a conversation response. Equivalent to the AWS Bedrock converse API endpoint. For additional details, see: https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html Requirements:
  • pip install boto3
Signature:
converse(
    messages: Json,
    model_id: String,
    system: Optional[Json],
    inference_config: Optional[Json],
    additional_model_request_fields: Optional[Json],
    tool_config: Optional[Json]
)-> Json
Parameters:
  • messages (Json): Input messages.
  • model_id (String): The model that will complete your prompt.
  • system (Optional[Json]): An optional system prompt.
  • inference_config (Optional[Json]): Base inference parameters to use.
  • additional_model_request_fields (Optional[Json]): Additional inference parameters to use.
Returns:
  • Json: A dictionary containing the response and other metadata.
Example: Add a computed column that applies the model anthropic.claude-3-haiku-20240307-v1:0 to an existing Pixeltable column tbl.prompt of the table tbl:
msgs = [{'role': 'user', 'content': [{'text': tbl.prompt}]}]
tbl.add_computed_column(response=messages(msgs, model_id='anthropic.claude-3-haiku-20240307-v1:0'))

invoke_tools() udf

Converts an Anthropic 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