TamaEx.Perception (TamaEx v0.2.0)

View Source

Client for interacting with Perception API endpoints.

Summary

Functions

get_chain(client, id)

get_chain(client, space_id, slug)

Gets a chain by slug from a specific space.

Parameters

  • client - The HTTP client
  • space - The space identifier (can be space_id string or Space struct)
  • slug - The slug identifier for the chain

Examples

iex> client = %Req.Request{options: %{base_url: "https://api.example.com/provision"}}
iex> {:ok, _} = TamaEx.validate_client(client, ["provision"])
iex> is_binary("space_123") and is_binary("my-chain")
true

iex> space = %TamaEx.Neural.Space{id: "space_123", name: "Test", provision_state: "active"}
iex> space.id
"space_123"

iex> attrs = %{"name" => "Test Chain", "provision_state" => "active"}
iex> chain = TamaEx.Perception.Chain.parse(attrs)
iex> chain.name
"Test Chain"

list_concepts(client)

Lists concepts from the perception namespace.

This function supports both perception concept endpoints:

Query params can be passed as either a keyword list or a map. When a map is provided, nested maps are flattened into bracketed query params.

Parameters

  • client - The HTTP client configured for the perception namespace
  • entity_id - Optional entity identifier for the entity-specific concepts endpoint
  • options - Optional request options
  • query - Optional query params as a keyword list or nested map
  • retry - Optional Req retry option

Examples

iex> client = %Req.Request{options: %{base_url: "https://api.example.com/perception"}}
iex> {:ok, _} = TamaEx.validate_client(client, ["perception"])
iex> is_list([])
true

iex> query = %{
...>   actor: %{source: "system", identifier: "agent_123"},
...>   tool_call_id: "tool-call-123"
...> }
iex> TamaEx.Query.flatten(query)
[{"actor[source]", "system"}, {"actor[identifier]", "agent_123"}, {"tool_call_id", "tool-call-123"}]

iex> entity_query = %{
...>   generator: %{type: "model"},
...>   relations: "reply"
...> }
iex> TamaEx.Query.flatten(entity_query)
[{"generator[type]", "model"}, {"relations", "reply"}]

Example usage:

TamaEx.Perception.list_concepts(client,
  query: %{
    actor: %{
      source: actor.source,
      identifier: actor.identifier
    },
    tool_call_id: "tool-call-123"
  }
)

TamaEx.Perception.list_concepts(client, entity_id,
  query: %{
    generator: %{type: "model"},
    relations: "reply"
  }
)

list_concepts(client, options)

list_concepts(client, entity_id, options)