The DeepSeek API has recently undergone a significant upgrade, introducing a suite of powerful new features designed to enhance the capabilities of AI models. These enhancements include Chat Prefix Completion, Fill-In-the-Middle (FIM) Completion, Function Calling, and JSON Output, all aimed at providing developers with greater flexibility and control over model interactions. This article dives into these exciting new functionalities and explores how they can be leveraged to build more sophisticated and efficient AI applications.
This major update to the DeepSeek API focuses on unlocking the full potential of AI models by providing new interface features:
These features are available for the deepseek-chat
and deepseek-coder
models. Let’s explore each feature in detail.
The DeepSeek API now supports JSON Output, which is compatible with the OpenAI API. This feature enforces the model to output valid JSON format strings, which is particularly useful for tasks involving data processing. By ensuring that the model returns data in a predefined JSON format, subsequent parsing of the output is simplified, and the automation of program flows is greatly enhanced.
To utilize the JSON Output feature:
response_format
to {'type': 'json_object'}
.max_tokens
appropriately to prevent truncation of the JSON string.This functionality is especially valuable when you need structured data from the model, making it easier to integrate AI-generated content into existing systems and workflows. For a deeper understanding, refer to the JSON Output Guide.
The introduction of Function Calling in the DeepSeek API enables AI models to interact with the physical world through external tools. Compatible with the OpenAI API, this feature allows models to execute specific functions based on user input, opening up a wide range of applications.
Key aspects of Function Calling include:
Function Calling can be integrated into various applications, as demonstrated by integrating deepseek-coder
into the LobeChat frontend. In this example, enabling a "Website Crawler" plugin allows the model to crawl and summarize website content.
This feature involves a multi-step interaction process:
For more information, see the Function Calling Guide.
Chat Prefix Completion gives developers greater control over the model's output. Following the Chat Completion API format, this feature allows users to specify a prefix for the last assistant message. The model then completes the message, starting from that prefix. This is useful for enforcing a particular output format or continuing messages that were truncated due to token limits.
To use this feature:
base_url
to https://api.deepseek.com/beta
to enable Beta features.prefix
parameter to True
. For instance: {"role": "assistant", "content": "Once upon a time,", "prefix": True}
.For instance, you can force the model to begin its response with a code block by setting the initial message to 'python\n'. Adding a stop parameter like '
' prevents the model from generating extra content. Check out the Chat Prefix Completion Guide for more details.
To address use cases that require extended text output, the DeepSeek API has increased the max_tokens
parameter limit to 8K in the Beta API.
To enable this feature:
base_url
to https://api.deepseek.com/beta
to access Beta features.max_tokens
remains at 4096, enabling the Beta API allows it to be set up to 8192.This enhancement allows models to generate more comprehensive and detailed responses, making it suitable for tasks such as long-form content creation and detailed report generation.
DeepSeek API now supports Fill-In-the-Middle (FIM) Completion, which is compatible with the OpenAI FIM Completion API. This allows users to provide custom prefixes and suffixes, with the model completing the content in between. This feature is especially useful in scenarios such as story completion and code completion.
To use FIM Completion:
base_url
to https://api.deepseek.com/beta
to enable the Beta features.For example, if a user provides the beginning and end of a Fibonacci sequence function, the model can complete the code in the middle. The FIM Completion Guide provides more details on this feature.
It’s important to note:
base_url
to https://api.deepseek.com/beta
.The functionalities will be released to the open-source community once they are stable.
The latest upgrades to the DeepSeek API mark a significant step forward in AI model capabilities. By introducing features like JSON Output, Function Calling, Chat Prefix Completion, increased max_tokens
, and FIM Completion, DeepSeek is empowering developers to create more versatile, efficient, and powerful AI applications. These enhancements allow for broader and more flexible interaction with AI models, ultimately unlocking new possibilities across various domains.