Failed to load versions. Head to the versions page to see all versions for this model.
You're looking at a specific version of this model. Jump to the model overview.
zeke /cog-markdown-example:146e98d6
Input
Run this model in Node.js with one line of code:
npm install replicate
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run zeke/cog-markdown-example using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"zeke/cog-markdown-example:146e98d6b010c431f601ac8482d7f0f9562730c8e82f93f9ad6eff711f95023a",
{
input: {
markdown: "```py\ndef allow_iframe_youtube(tag, name, value):\n if name == \"src\" and value.startswith(\"https://www.youtube.com/embed/\"):\n return True\n if name in (\"allow\", \"width\", \"height\"):\n return True\n return False\n\n\ndef allow_fenced_code_languages(tag, name, value):\n return (\n tag == \"code\"\n and name == \"class\"\n and value.startswith(\"language-\")\n and \" \" not in value\n )\n```"
}
}
);
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=<paste-your-token-here>
Find your API token in your account settings.
import replicate
Run zeke/cog-markdown-example using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"zeke/cog-markdown-example:146e98d6b010c431f601ac8482d7f0f9562730c8e82f93f9ad6eff711f95023a",
input={
"markdown": "```py\ndef allow_iframe_youtube(tag, name, value):\n if name == \"src\" and value.startswith(\"https://www.youtube.com/embed/\"):\n return True\n if name in (\"allow\", \"width\", \"height\"):\n return True\n return False\n\n\ndef allow_fenced_code_languages(tag, name, value):\n return (\n tag == \"code\"\n and name == \"class\"\n and value.startswith(\"language-\")\n and \" \" not in value\n )\n```"
}
)
print(output)
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Run zeke/cog-markdown-example 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": "146e98d6b010c431f601ac8482d7f0f9562730c8e82f93f9ad6eff711f95023a",
"input": {
"markdown": "```py\\ndef allow_iframe_youtube(tag, name, value):\\n if name == \\"src\\" and value.startswith(\\"https://www.youtube.com/embed/\\"):\\n return True\\n if name in (\\"allow\\", \\"width\\", \\"height\\"):\\n return True\\n return False\\n\\n\\ndef allow_fenced_code_languages(tag, name, value):\\n return (\\n tag == \\"code\\"\\n and name == \\"class\\"\\n and value.startswith(\\"language-\\")\\n and \\" \\" not in value\\n )\\n```"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
Output
Rendering markdown...
{
"completed_at": "2022-05-04T22:01:59.237909Z",
"created_at": "2022-05-04T22:01:56.200623Z",
"data_removed": false,
"error": null,
"id": "v27nberxbjaghie3qjk6iplygy",
"input": {
"markdown": "```py\ndef allow_iframe_youtube(tag, name, value):\n if name == \"src\" and value.startswith(\"https://www.youtube.com/embed/\"):\n return True\n if name in (\"allow\", \"width\", \"height\"):\n return True\n return False\n\n\ndef allow_fenced_code_languages(tag, name, value):\n return (\n tag == \"code\"\n and name == \"class\"\n and value.startswith(\"language-\")\n and \" \" not in value\n )\n```"
},
"logs": null,
"metrics": {
"predict_time": 0.000002,
"total_time": 3.037286
},
"output": "https://replicate.delivery/mgxm/dbcf023a-1cb0-483a-84d2-2f9610effe8c/out.md",
"started_at": "2022-05-04T22:01:59.237907Z",
"status": "succeeded",
"urls": {
"get": "https://api.replicate.com/v1/predictions/v27nberxbjaghie3qjk6iplygy",
"cancel": "https://api.replicate.com/v1/predictions/v27nberxbjaghie3qjk6iplygy/cancel"
},
"version": "146e98d6b010c431f601ac8482d7f0f9562730c8e82f93f9ad6eff711f95023a"
}