View Source ProdopsEx.Artifact (ProdopsEx v0.1.0)

Handles artifact operations for the ProdOps 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 prompt template. 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 prompt template prior to generation, known as Retrieval-Augmented Generation (RAG)
  • document attachments: an entire document, such as something uploaded by you, is inserted into the prompt template 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

Link to this function

create(params, config \\ [])

View Source
@spec create(
  %{
    prompt_template_id: integer(),
    artifact_slug: String.t(),
    project_id: integer(),
    inputs: list(),
    fire_and_forget: boolean()
  },
  Keyword.t()
) :: {:ok, map()} | {:error, term()}

Creates an artifact by submitting a request with the required parameters.

Parameters

  • params: The parameters for the artifact request.
  • config (optional): a configuration map used to override default config values

Examples

iex> ProdopsEx.Artifact.create(%{
...>   prompt_template_id: 2,
...>   artifact_slug: "story",
...>   project_id: 1,
...>   inputs: [
...>     %{name: "Context", value: "this is a test"}
...>   ],
...>   fire_and_forget: true
...> })
{:ok, %{"artifact_id" => 123, "status" => "created"}}
Link to this function

delete(artifact_id, artifact_slug, config \\ [])

View Source
@spec delete(integer(), String.t(), Keyword.t()) :: {:ok, map()} | {:error, any()}

Deletes an artifact by its ID.

Parameters

  • artifact_id: the ID of the artifact
  • artifact_slug: the type of the artifact to be deleted
  • config (optional): a configuration map used to override default config values

Example

iex> ProdopsEx.Artifact.delete(1, "story")
{:ok,
  %{status: "ok", response: %{"message" => "Artifact deleted successfully."}}}
Link to this function

get(artifact_id, artifact_slug, config \\ [])

View Source
@spec get(integer(), String.t(), Keyword.t()) :: {:ok, map()} | {:error, any()}

Retrieves an artifact by its ID.

Parameters

  • artifact_id: the ID of the artifact
  • artifact_slug: the slug which defines the type of artifact that will be returned
  • config (optional): a configuration map used to override default config values

Example

iex> ProdopsEx.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
     }
   }
 }}
Link to this function

list_project_artifacts(project_id, artifact_slug, config \\ [])

View Source
@spec list_project_artifacts(integer(), String.t(), Keyword.t()) ::
  {:ok, list()} | {:error, any()}

Retrieves artifacts of one type based on the artifact_slug for a given project.

Parameters

  • project_id: the ID of the project
  • artifact_slug: the slug which defines the type of artifacts that will be returned
  • config (optional): a configuration map used to override default config values

Example

iex> ProdopsEx.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.

Link to this function

refine_artifact(params, config \\ [])

View Source
@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> ProdopsEx.Artifact.refine_artifact(%{
...>   artifact_id: 1,
...>   artifact_slug: "story",
...>   refine_prompt: "Refine this story"
...> })
Link to this function

stream_create_artifact(params, config \\ [])

View Source
@spec stream_create_artifact(map(), Keyword.t()) :: {:ok, map()} | {:error, any()}

Creates an artifact by submitting a request with the required parameters.

Parameters

  • params: The parameters for the artifact creation request.
  • config: The configuration map containing the API key and endpoint URL.

Example

iex> ProdopsEx.Artifact.stream_create_artifact(%{
...>   prompt_template_id: 2,
...>   project_id: 1,
...>   artifact_slug: "story",
...>   inputs: [
...>     %{name: "Context", value: "this is a test"}
...>   ]
...> })
Link to this function

stream_refine_artifact(params, config \\ [])

View Source
@spec stream_refine_artifact(map(), 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 endpoint URL.

Example

iex> ProdopsEx.Artifact.stream_refine_artifact(%{artifact_slug: "story", artifact_id: 1, refine_prompt: "some prompt"})