Completions
Completion in a Large Language Model (LLM) refers to the process of generating text based on the input provided by the user. The LLM receives a prompt (input) and then produces a response that continues or completes the text according to patterns learned from its training data.
https://dekallm.cloudeka.ai/v1/chat/completions
Example Request
curl --request POST \
--url https://dekallm.cloudeka.ai/v1/chat/completions \
--header 'Authorization: Bearer API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "meta/llama-3.1-405b-instruct",
"messages": [
{
"role": "system",
"content": "You are a story teller"
},
{
"role": "user",
"content": "Write poem that tell story about Lord of the Rings start from when Frodo leaves his villages. Story should also tell the audience that Frodo is not always good boy, while Sauron also not always a bad boy. Poem should have 10 paragraf and have rythmns like a folks song"
}
],
"stream": false,
"temperature": 0.9,
"top_p": 1,
}'
import requests
import json
url = "https://dekallm.cloudeka.ai/v1/chat/completions"
headers = {
"Authorization": "Bearer API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "meta/llama-3.1-405b-instruct",
"messages": [
{
"role": "system",
"content": "You are a story teller"
},
{
"role": "user",
"content": "Write a poem that tells a story about Lord of the Rings starting from when Frodo leaves his village. The story should also tell the audience that Frodo is not always a good boy, while Sauron is also not always a bad boy. The poem should have 10 paragraphs and have rhythms like a folk song."
}
],
"stream": False,
"temperature": 0.9,
"top_p": 1,
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.status_code)
print(response.json())
Response
{
"id": "chat-96467625014545a2976178313633ce68",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "In the Shire's heart, where the sun always shines\nLived Frodo, a young hobbit, with a fate divine\nHe inherited the Ring, a treasure so grand\nFrom Bilbo, his uncle, who'd traveled the land\n\nHe set out on a journey, from his village so fair\nLeaving friends and family, with tears in the air\nHe knew not the dangers, that lay ahead in store\nBut he felt the weight, of the Ring's power once more\n\nBut little do we know, about Frodo's past\nHe wasn't always good, he had a reckless cast\nHe'd steal from the market, and play pranks on his friends\nAnd cause trouble in the Shire, till the very end\n\nHe'd dance with the ladies, under the stars so bright\nAnd sing with the travelers, through the night so light\nBut amidst the fun, and the laughter so free\nHe'd hide a secret, that only he could see\n\nNow Sauron, the Dark Lord, wasn't always so bold\nHe was once a Maiar, with a heart of gold\nHe was seduced by power, and corrupted by pride\nAnd now his darkness, spreads far and wide\n\nHe forged the One Ring, with fire and with might\nTo control and enslave, all of Middle Earth's light\nBut a part of him, still remembers the past\nWhen love and kindness, were the virtues that would last\n\nAs Frodo traveled on, through mountains and night\nHe met Strider, a Ranger, with a will so bright\nTogether they journeyed, through treacherous terrain\nWith orcs and Uruk-hai, and the Nazgûl's deadly refrain\n\nThe Fellowship formed, with elves, dwarves, and men\nTogether they vowed, to destroy the Ring's evil then\nBut Frodo's own demons, and Sauron's darkest might\nWould test their resolve, through the dark of the night\n\nThe journey was long, through Mordor's burning land\nWith Gollum's conflicted heart, and the Ring's tempting hand\nFrodo and Samwise, a loyal friend so true\nWalked the thin line, between good and evil anew\n\nIn the end, it was Frodo, who stood tall and strong\nWho resisted the Ring's will, and didn't do wrong\nAnd Sauron, the Dark Lord, was defeated that day\nBut a part of him wept, for the love that went astray.",
"role": "assistant",
"tool_calls": null,
"function_call": null
}
}
],
"created": 1727479222,
"model": "meta/llama-3.1-405b-instruct",
"object": "chat.completion",
"system_fingerprint": null,
"usage": {
"completion_tokens": 519,
"prompt_tokens": 86,
"total_tokens": 605,
"completion_tokens_details": null
},
"service_tier": null
}
Last updated