{
"frequency_penalty": 0,
"grammar": "root ::= \"```python\\ndef num_occurrences(c: str, s: str) -> int:\\n \" code \"```\"\ncode ::= [^`()]+",
"max_tokens": 500,
"mirostat_entropy": 5,
"mirostat_learning_rate": 0.1,
"mirostat_mode": "Disabled",
"presence_penalty": 0,
"prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a short program that counts the number of occurrences of a character in a string.\n\n### Response:",
"repeat_penalty": 1.1,
"temperature": 0.8,
"top_k": 10,
"top_p": 0.95
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_KSz**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run andreasjansson/wizardcoder-python-34b-v1-gguf using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"andreasjansson/wizardcoder-python-34b-v1-gguf:b357a162acd41ce53c04b14a25df0f1d476c2e39d465895d28cdba87944506c6",
{
input: {
frequency_penalty: 0,
grammar: "root ::= \"```python\\ndef num_occurrences(c: str, s: str) -> int:\\n \" code \"```\"\ncode ::= [^`()]+",
max_tokens: 500,
mirostat_entropy: 5,
mirostat_learning_rate: 0.1,
mirostat_mode: "Disabled",
presence_penalty: 0,
prompt: "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a short program that counts the number of occurrences of a character in a string.\n\n### Response:",
repeat_penalty: 1.1,
temperature: 0.8,
top_k: 10,
top_p: 0.95
}
}
);
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_KSz**********************************
This is your API token. Keep it to yourself.
import replicate
Run andreasjansson/wizardcoder-python-34b-v1-gguf using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"andreasjansson/wizardcoder-python-34b-v1-gguf:b357a162acd41ce53c04b14a25df0f1d476c2e39d465895d28cdba87944506c6",
input={
"frequency_penalty": 0,
"grammar": "root ::= \"```python\\ndef num_occurrences(c: str, s: str) -> int:\\n \" code \"```\"\ncode ::= [^`()]+",
"max_tokens": 500,
"mirostat_entropy": 5,
"mirostat_learning_rate": 0.1,
"mirostat_mode": "Disabled",
"presence_penalty": 0,
"prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a short program that counts the number of occurrences of a character in a string.\n\n### Response:",
"repeat_penalty": 1.1,
"temperature": 0.8,
"top_k": 10,
"top_p": 0.95
}
)
# The andreasjansson/wizardcoder-python-34b-v1-gguf 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/andreasjansson/wizardcoder-python-34b-v1-gguf/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_KSz**********************************
This is your API token. Keep it to yourself.
Run andreasjansson/wizardcoder-python-34b-v1-gguf 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": "andreasjansson/wizardcoder-python-34b-v1-gguf:b357a162acd41ce53c04b14a25df0f1d476c2e39d465895d28cdba87944506c6",
"input": {
"frequency_penalty": 0,
"grammar": "root ::= \\"```python\\\\ndef num_occurrences(c: str, s: str) -> int:\\\\n \\" code \\"```\\"\\ncode ::= [^`()]+",
"max_tokens": 500,
"mirostat_entropy": 5,
"mirostat_learning_rate": 0.1,
"mirostat_mode": "Disabled",
"presence_penalty": 0,
"prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n### Instruction:\\nWrite a short program that counts the number of occurrences of a character in a string.\\n\\n### Response:",
"repeat_penalty": 1.1,
"temperature": 0.8,
"top_k": 10,
"top_p": 0.95
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
```python
def num_occurrences(c: str, s: str) -> int:
"""Counts the number of occurrences of a character c in a string s."""
count = 0
for char in s:
if char == c:
count += 1
return count
```{
"id": "s5oeuzlb6ij36miihdoy4mnj34",
"model": "andreasjansson/wizardcoder-python-34b-v1-gguf",
"version": "b357a162acd41ce53c04b14a25df0f1d476c2e39d465895d28cdba87944506c6",
"input": {
"frequency_penalty": 0,
"grammar": "root ::= \"```python\\ndef num_occurrences(c: str, s: str) -> int:\\n \" code \"```\"\ncode ::= [^`()]+",
"max_tokens": 500,
"mirostat_entropy": 5,
"mirostat_learning_rate": 0.1,
"mirostat_mode": "Disabled",
"presence_penalty": 0,
"prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a short program that counts the number of occurrences of a character in a string.\n\n### Response:",
"repeat_penalty": 1.1,
"temperature": 0.8,
"top_k": 10,
"top_p": 0.95
},
"logs": "from_string grammar:\nroot ::= [`] [`] [`] [p] [y] [t] [h] [o] [n] [<U+000A>] [d] [e] [f] [ ] [n] [u] [m] [_] [o] [c] [c] [u] [r] [r] [e] [n] [c] [e] [s] [(] [c] [:] [ ] [s] [t] [r] [,] [ ] [s] [:] [ ] [s] [t] [r] [)] [ ] [-] [>] [ ] [i] [n] [t] [:] [<U+000A>] [ ] [ ] [ ] [ ] code [`] [`] [`] \ncode ::= code_2\ncode_2 ::= [^`()] code_2 | [^`()]\nPrompt:\nBelow is an instruction that describes a task. Write a response that appropriately completes the request.\n### Instruction:\nWrite a short program that counts the number of occurrences of a character in a string.\n### Response:\nLlama.generate: prefix-match hit\nllama_print_timings: load time = 323.93 ms\nllama_print_timings: sample time = 644.67 ms / 74 runs ( 8.71 ms per token, 114.79 tokens per second)\nllama_print_timings: prompt eval time = 0.00 ms / 1 tokens ( 0.00 ms per token, inf tokens per second)\nllama_print_timings: eval time = 3161.00 ms / 74 runs ( 42.72 ms per token, 23.41 tokens per second)\nllama_print_timings: total time = 3983.35 ms",
"output": [
"```",
"python",
"\n",
"def",
" num",
"_",
"occ",
"urr",
"ences",
"(",
"c",
":",
" str",
",",
" s",
":",
" str",
")",
" ->",
" int",
":",
"\n",
" ",
" \"\"\"",
"Count",
"s",
" the",
" number",
" of",
" occurr",
"ences",
" of",
" a",
" character",
" c",
" in",
" a",
" string",
" s",
".\"",
"\"\"",
"\n",
" ",
" count",
" =",
" ",
"0",
"\n",
" ",
" for",
" char",
" in",
" s",
":",
"\n",
" ",
" if",
" char",
" ==",
" c",
":",
"\n",
" ",
" count",
" +=",
" ",
"1",
"\n",
" ",
" return",
" count",
"\n",
"```"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2023-09-22T22:10:42.257147Z",
"started_at": "2023-09-22T22:10:42.162819Z",
"completed_at": "2023-09-22T22:10:46.157018Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/s5oeuzlb6ij36miihdoy4mnj34/cancel",
"get": "https://api.replicate.com/v1/predictions/s5oeuzlb6ij36miihdoy4mnj34"
},
"metrics": {
"predict_time": 3.994199,
"total_time": 3.899871
}
}