FIM Completion (Beta)
In FIM (Fill In the Middle) completion, users can provide a prefix and a suffix (optional), and the model will complete the content in between. FIM is commonly used for content completion、code completion.
Notice
- The max tokens of FIM completion is 4K.
- The user needs to set
base_url=https://api.deepseek.com/beta
to enable the Beta feature.
Sample Code
Below is a complete Python code example for FIM completion. In this example, we provide the beginning and the end of a function to calculate the Fibonacci sequence, allowing the model to complete the content in the middle.
from openai import OpenAI
client = OpenAI(
api_key="<your api key>",
base_url="https://api.deepseek.com/beta",
)
response = client.completions.create(
model="deepseek-chat",
prompt="def fib(a):",
suffix=" return fib(a-1) + fib(a-2)",
max_tokens=128
)
print(response.choices[0].text)
Integration With Continue
Continue is a VSCode plugin that supports code completion. You can refer to this document to configure Continue for using the code completion feature.