Packages

A unified Elixir client for multiple AI providers including Vertex AI, OpenAI, Anthropic, AWS Bedrock, and local PyTorch models.

Retired package: Security issue - Copile gcp issues

Current section

Files

Jump to
axiom_ai lib python_interface object.ex
Raw

lib/python_interface/object.ex

defmodule PythonInterface.Object do
@moduledoc """
A struct holding a Python object.
This is an opaque struct used to pass Python objects around in
Elixir code.
"""
defstruct [:resource]
@type t :: %__MODULE__{resource: reference()}
end
defimpl Inspect, for: PythonInterface.Object do
import Inspect.Algebra
alias PythonInterface.Object
def inspect(%Object{} = object, _opts) do
repr_string =
object
|> PythonInterface.NIF.object_repr()
|> PythonInterface.NIF.unicode_to_string()
repr_lines = String.split(repr_string, "\n")
inner = Enum.map_intersperse(repr_lines, line(), &string/1)
force_unfit(
concat([
"#PythonInterface.Object<",
nest(concat([line() | inner]), 2),
line(),
">"
])
)
end
end