Handles artifact operations for the RevelryAI API such as retrieving artifacts for a given project, creating artifacts, refining artifacts, and deleting artifacts.
Artifacts are any generated content, i.e. user stories, blog posts, code
snippets, etc. They are organized by artifact_slugs, which define what type
of content they are. Most artifact operations require specifying the
artifact_slug.
They are generated by passing input into a skill. Inputs come from up to three places:
- user inputs: you can specify what values these have when creating Artifacts
- document queries: semantically similar parts of documents are automatically found within a collection of documents, and inserted into the skill's prompt prior to generation, known as Retrieval-Augmented Generation (RAG)
- document attachments: an entire document, such as something uploaded by you, is inserted into the skill's prompt prior to generation
Summary
Functions
Creates an artifact by submitting a request with the required parameters.
Deletes an artifact by its ID.
Retrieves an artifact by its ID.
Retrieves artifacts of one type based on the artifact_slug for a given project.
Refines an artifact by submitting a request with the required parameters.
Creates an artifact by submitting a request with the required parameters.
Refines an artifact by submitting a request with the required parameters.
Functions
@spec create( String.t(), integer(), %{ :skill_id => integer(), :inputs => list(), optional(:fire_and_forget) => boolean(), optional(:name) => String.t(), optional(:model_configuration_id) => integer() }, Keyword.t() ) :: {:ok, map()} | {:error, term()}
Creates an artifact by submitting a request with the required parameters.
Parameters
artifact_slug: the slug which defines the type of artifact to createproject_id: the ID of the project the artifact belongs toparams: the request body:skill_id(required): the ID of the skill to runinputs(required): a list of%{name: name, value: value}maps matching the skill's custom variablesfire_and_forget(optional): return immediately and deliver the completed artifact via webhookname(optional): a name for the artifact; auto-generated when absentmodel_configuration_id(optional): overrides the organization's default model configuration
config(optional): a configuration map used to override default config values
Examples
iex> RevelryAI.Artifact.create("story", 1, %{
...> skill_id: 2,
...> inputs: [
...> %{name: "Context", value: "this is a test"}
...> ],
...> fire_and_forget: true
...> })
{:ok, %{"artifact_id" => 123, "status" => "created"}}
Deletes an artifact by its ID.
Parameters
artifact_id: the ID of the artifactartifact_slug: the type of the artifact to be deletedconfig(optional): a configuration map used to override default config values
Example
iex> RevelryAI.Artifact.delete(1, "story")
{:ok,
%{status: "ok", response: %{"message" => "Artifact deleted successfully."}}}
Retrieves an artifact by its ID.
Parameters
artifact_id: the ID of the artifactartifact_slug: the slug which defines the type of artifact that will be returnedconfig(optional): a configuration map used to override default config values
Example
iex> RevelryAI.Artifact.get(1, "story")
{:ok,
%{
status: "ok",
response: %{
"artifact" => %{
"chat_history" => [
%{
"content" => "some user prompt content",
"role" => "user"
},
%{
"content" => "some assistant response content",
"role" => "assistant"
}
],
"id" => 123,
"manually_edited" => false,
"name" => "Some Name",
"notes" => nil,
"share_token" => nil
}
}
}}
Retrieves artifacts of one type based on the artifact_slug for a given project.
Parameters
project_id: the ID of the projectartifact_slug: the slug which defines the type of artifacts that will be returnedconfig(optional): a configuration map used to override default config values
Example
iex> RevelryAI.Artifact.list_project_artifacts(1, "story")
{:ok,
%{
status: "ok",
response: %{
"artifacts" => [
%{
"chat_history" => [
%{
"content" => "You are going to be a product manager and write a BDD-style user story...",
"role" => "user"
},
%{
"content" => "## Background ...",
"role" => "assistant"
}
],
"content" => "## Background ...",
"id" => 1,
"manually_edited" => false,
"name" => "Artifact Name",
"notes" => nil,
"share_token" => nil
}
]
}
}}Returns
The function returns a list of artifacts for the specified project which match the artifact slug.
@spec refine_artifact( %{ artifact_id: integer(), artifact_slug: String.t(), refine_prompt: String.t() }, Keyword.t() ) :: {:ok, map()} | {:error, any()}
Refines an artifact by submitting a request with the required parameters.
Parameters
params: The parameters for the artifact request.config: The configuration map containing the API key and optionally the URL.
Example
iex> RevelryAI.Artifact.refine_artifact(%{
...> artifact_id: 1,
...> artifact_slug: "story",
...> refine_prompt: "Refine this story"
...> })
@spec stream_create_artifact(String.t(), integer(), map(), Keyword.t()) :: Enumerable.t() | {:error, any()}
Creates an artifact by submitting a request with the required parameters.
Parameters
artifact_slug: the slug which defines the type of artifact to createproject_id: the ID of the project the artifact belongs toparams: the request body, as increate/4config: The configuration map containing the API key and endpoint URL.
Example
iex> RevelryAI.Artifact.stream_create_artifact("story", 1, %{
...> skill_id: 2,
...> inputs: [
...> %{name: "Context", value: "this is a test"}
...> ]
...> })
Refines an artifact by submitting a request with the required parameters.
Parameters
params: The parameters for the artifact request.config: The configuration map containing the API key and endpoint URL.
Example
iex> RevelryAI.Artifact.stream_refine_artifact(%{artifact_slug: "story", artifact_id: 1, refine_prompt: "some prompt"})