View Source Potions (Potions v0.1.0)
Documentation for Potions
.
Summary
Functions
Parses out OpenAI's chat completion response into a cleaner format. Returns {:ok, text_content} or {:error, message}
Implements the ~LLM sigil, which parses text into an OpenAI friendly chat completion prompt.
~LLM works by parsing out the model
, system
, user
and assistant
keywords.
Functions
Parses out OpenAI's chat completion response into a cleaner format. Returns {:ok, text_content} or {:error, message}
Instead of: {:ok, %{ id: "chatcmpl-7zSc1rsCXpyALMjM9MkaF077xYRot", usage: %{ "completion_tokens" => 10, "prompt_tokens" => 19, "total_tokens" => 29 }, created: 1694882349, choices: [ %{
"finish_reason" => "stop",
"index" => 0,
"message" => %{
"content" => "Compact and stack snow blocks in a dome shape.",
"role" => "assistant"
}
} ], model: "gpt-3.5-turbo-0613", object: "chat.completion" }}
Implements the ~LLM sigil, which parses text into an OpenAI friendly chat completion prompt.
~LLM works by parsing out the model
, system
, user
and assistant
keywords.
Examples
iex> import Potions iex> ~LLM"model: gpt-3.5-turbo system: You are an expert at text to image prompts. Given a description, write a text-to-image prompt. user: sunset" [ model: "gpt-3.5-turbo", messages: [
%{
content: "You are an expert at text to image prompts. Given a description, write a text-to-image prompt.",
role: "system"
},
%{content: "sunset", role: "user"}
] ]