Skip to main content
Pixeltable UDFs for Deepseek AI models. Provides integration with Deepseek’s language models for chat completions and other AI capabilities. View source on GitHub

UDFs


chat_completions() udf

Creates a model response for the given chat conversation. Equivalent to the Deepseek chat/completions API endpoint. For additional details, see: https://api-docs.deepseek.com/api/create-chat-completion Deepseek uses the OpenAI SDK, so you will need to install the openai package to use this UDF. Request throttling: Applies the rate limit set in the config (section deepseek, key rate_limit). If no rate limit is configured, uses a default of 600 RPM. Requirements:
  • pip install openai
Signature:
chat_completions(
    messages: Json,
    model: String,
    model_kwargs: Optional[Json],
    tools: Optional[Json],
    tool_choice: Optional[Json]
)-> Json
Parameters:
  • messages (Json): A list of messages to use for chat completion, as described in the Deepseek API documentation.
  • model (String): The model to use for chat completion.
  • model_kwargs (Optional[Json]): Additional keyword args for the Deepseek chat/completions API. For details on the available parameters, see: https://api-docs.deepseek.com/api/create-chat-completion
  • tools (Optional[Json]): An optional list of Pixeltable tools to use for the request.
  • tool_choice (Optional[Json]): An optional tool choice configuration.
Returns:
  • Json: A dictionary containing the response and other metadata.
Example: Add a computed column that applies the model deepseek-chat to an existing Pixeltable column tbl.prompt of the table tbl:
messages = [{'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': tbl.prompt}]
tbl.add_computed_column(response=chat_completions(messages, model='deepseek-chat'))
I