{
"frequency_penalty": 0,
"max_tokens": 512,
"min_tokens": 0,
"presence_penalty": 0,
"prompt": "write a quick sort algorithm in python.",
"system_prompt": "You are an expert software engineer proficient in multiple programming languages.",
"temperature": 0.6,
"top_k": 50,
"top_p": 0.9
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_ZF7**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run deepseek-ai/deepseek-coder-v2-lite-instruct using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"deepseek-ai/deepseek-coder-v2-lite-instruct:a182159595ee209e25e673a5ab6f0293111dd6733df973f77efcd1f851123330",
{
input: {
frequency_penalty: 0,
max_tokens: 512,
min_tokens: 0,
presence_penalty: 0,
prompt: "write a quick sort algorithm in python.",
system_prompt: "You are an expert software engineer proficient in multiple programming languages.",
temperature: 0.6,
top_k: 50,
top_p: 0.9
}
}
);
console.log(output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_ZF7**********************************
This is your API token. Keep it to yourself.
import replicate
Run deepseek-ai/deepseek-coder-v2-lite-instruct using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"deepseek-ai/deepseek-coder-v2-lite-instruct:a182159595ee209e25e673a5ab6f0293111dd6733df973f77efcd1f851123330",
input={
"frequency_penalty": 0,
"max_tokens": 512,
"min_tokens": 0,
"presence_penalty": 0,
"prompt": "write a quick sort algorithm in python.",
"system_prompt": "You are an expert software engineer proficient in multiple programming languages.",
"temperature": 0.6,
"top_k": 50,
"top_p": 0.9
}
)
# The deepseek-ai/deepseek-coder-v2-lite-instruct model can stream output as it's running.
# The predict method returns an iterator, and you can iterate over that output.
for item in output:
# https://replicate.com/deepseek-ai/deepseek-coder-v2-lite-instruct/api#output-schema
print(item, end="")
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_ZF7**********************************
This is your API token. Keep it to yourself.
Run deepseek-ai/deepseek-coder-v2-lite-instruct using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "deepseek-ai/deepseek-coder-v2-lite-instruct:a182159595ee209e25e673a5ab6f0293111dd6733df973f77efcd1f851123330",
"input": {
"frequency_penalty": 0,
"max_tokens": 512,
"min_tokens": 0,
"presence_penalty": 0,
"prompt": "write a quick sort algorithm in python.",
"system_prompt": "You are an expert software engineer proficient in multiple programming languages.",
"temperature": 0.6,
"top_k": 50,
"top_p": 0.9
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
def quick_sort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quick_sort(left) + middle + quick_sort(right)
print(quick_sort([3,6,8,10,1,2,1]))
{
"id": "ha35gkakfdrgm0cgjf4rm0gfm8",
"model": "deepseek-ai/deepseek-coder-v2-lite-instruct",
"version": "a182159595ee209e25e673a5ab6f0293111dd6733df973f77efcd1f851123330",
"input": {
"frequency_penalty": 0,
"max_tokens": 512,
"min_tokens": 0,
"presence_penalty": 0,
"prompt": "write a quick sort algorithm in python.",
"system_prompt": "You are an expert software engineer proficient in multiple programming languages.",
"temperature": 0.6,
"top_k": 50,
"top_p": 0.9
},
"logs": "INFO 07-08 19:19:23 async_llm_engine.py:584] Received request 3bea0322126645299a822ea89c4e4778: prompt: 'write a quick sort algorithm in python.', params: SamplingParams(n=1, best_of=1, presence_penalty=0.0, frequency_penalty=0.0, repetition_penalty=1.0, temperature=0.6, top_p=0.9, top_k=50, min_p=0.0, seed=None, use_beam_search=False, length_penalty=1.0, early_stopping=False, stop=[], stop_token_ids=[100001], include_stop_str_in_output=False, ignore_eos=False, max_tokens=512, min_tokens=0, logprobs=None, prompt_logprobs=None, skip_special_tokens=True, spaces_between_special_tokens=True, truncate_prompt_tokens=None), prompt_token_ids: None, lora_request: None.\n stdoutINFO 07-08 19:19:23 metrics.py:341] Avg prompt throughput: 1.5 tokens/s, Avg generation throughput: 21.6 tokens/s, Running: 1 reqs, Swapped: 0 reqs, Pending: 0 reqs, GPU KV cache usage: 0.1%, CPU KV cache usage: 0.0%.\n stdoutGeneration took 1720466049.90sINFO 07-08 19:19:24 async_llm_engine.py:134] Finished request 3bea0322126645299a822ea89c4e4778.\n stdoutFormatted prompt: {system_prompt}\n\nUser: {prompt}\n\nAssistant:",
"output": [
"\n",
"def",
" quick",
"_",
"sort",
"(",
"arr",
"):",
"\n",
" ",
" if",
" len",
"(",
"arr",
")",
" <=",
" ",
"1",
":",
"\n",
" ",
" return",
" arr",
"\n",
" ",
" pivot",
" =",
" arr",
"[",
"len",
"(",
"arr",
")",
" //",
" ",
"2",
"]",
"\n",
" ",
" left",
" =",
" [",
"x",
" for",
" x",
" in",
" arr",
" if",
" x",
" <",
" pivot",
"]",
"\n",
" ",
" middle",
" =",
" [",
"x",
" for",
" x",
" in",
" arr",
" if",
" x",
" ==",
" pivot",
"]",
"\n",
" ",
" right",
" =",
" [",
"x",
" for",
" x",
" in",
" arr",
" if",
" x",
" >",
" pivot",
"]",
"\n",
" ",
" return",
" quick",
"_",
"sort",
"(",
"left",
")",
" +",
" middle",
" +",
" quick",
"_",
"sort",
"(",
"right",
")",
"\n",
"\n",
"print",
"(",
"quick",
"_",
"sort",
"([",
"3",
",",
"6",
",",
"8",
",",
"1",
"0",
",",
"1",
",",
"2",
",",
"1",
"]))",
"\n",
""
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-07-08T19:19:23.259Z",
"started_at": "2024-07-08T19:19:23.29247Z",
"completed_at": "2024-07-08T19:19:24.930258Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/ha35gkakfdrgm0cgjf4rm0gfm8/cancel",
"get": "https://api.replicate.com/v1/predictions/ha35gkakfdrgm0cgjf4rm0gfm8",
"stream": "https://streaming-api.svc.us.c.replicate.net/v1/streams/rp3y6oobige4rodjk2vl4uz5q5undz3tagqvqjwcph5jmlp7cyha",
"web": "https://replicate.com/p/ha35gkakfdrgm0cgjf4rm0gfm8"
},
"metrics": {
"predict_time": 1.637787113,
"total_time": 1.671258
}
}