Slop.Controller (slop v0.1.0)

View Source

Provides default controller implementations for SLOP (Simple Language Open Protocol) endpoints.

This module can be used to quickly implement SLOP-compliant controllers in a Phoenix application by providing default implementations for all the standard SLOP endpoints.

Usage

defmodule MyAppWeb.SlopChatController do
  use Slop.Controller, :chat

  # Override the default implementation
  def handle_chat(conn, params) do
    # Your custom chat implementation
    # ...

    json(conn, %{response: "Hello from SLOP!"})
  end
end

You can also implement only specific callbacks:

defmodule MyAppWeb.SlopInfoController do
  use Slop.Controller, :info

  # The default implementation will be used for other callbacks
  def get_info(_conn) do
    %{
      name: "My Custom SLOP Server",
      version: "1.0.0",
      endpoints: ["chat", "info"],
      models: ["gpt-4", "claude-3"]
    }
  end
end

Summary

Functions

Defines the controller implementation for a specific SLOP endpoint type.

Functions

__using__(endpoint_type)

(macro)

Defines the controller implementation for a specific SLOP endpoint type.

Options

  • :chat - Implements a controller for the /chat endpoint
  • :tools - Implements a controller for the /tools endpoints
  • :memory - Implements a controller for the /memory endpoints
  • :resources - Implements a controller for the /resources endpoints
  • :pay - Implements a controller for the /pay endpoint
  • :info - Implements a controller for the /info endpoint