AxiomAi.PythonInterface (AxiomAI v0.1.11)

View Source

Python Interface - Interface module for embedded python functionality.

This module provides a clean API for interacting with the embedded python library within the axiom project. It handles Python environment management, code execution, and provides utilities for AI model inference.

Summary

Functions

Clean up Python environment for a specific category.

Execute Python code with python_interface.

Get available Python packages in the environment.

Initialize Python environment with specified dependencies.

Functions

cleanup_environment(category \\ :default)

Clean up Python environment for a specific category.

Parameters

  • category: Category to clean up

Returns

  • :ok

execute_inference(model_path, message, python_code, config, category \\ :default)

Execute AI model inference using Python.

Parameters

  • model_path: Path to the AI model
  • message: Input message for the model
  • python_code: Python code template for inference
  • config: Configuration map with model parameters
  • category: Category for environment isolation

Returns

  • {:ok, response} with model response
  • {:error, reason} on failure

execute_python(code, globals \\ %{}, category \\ :default)

Execute Python code with python_interface.

Parameters

  • code: Python code string to execute
  • globals: Global variables dictionary (optional)
  • category: Category for environment isolation

Returns

  • {:ok, result} with decoded Python result
  • {:error, reason} on failure

execute_streaming_inference(model_path, message, python_code, config, category \\ :default)

Execute streaming inference for AI models.

Parameters

  • model_path: Path to the AI model
  • message: Input message for the model
  • python_code: Python code template for streaming inference
  • config: Configuration map with model parameters
  • category: Category for environment isolation

Returns

  • Stream of responses or error

get_installed_packages(category \\ :default)

Get available Python packages in the environment.

Parameters

  • category: Category for environment isolation

Returns

  • {:ok, packages} list of installed packages
  • {:error, reason} on failure

init_environment(python_deps, category \\ :default)

Initialize Python environment with specified dependencies.

Parameters

  • python_deps: List of Python dependencies to install
  • category: Category identifier for environment isolation

Returns

  • :ok on success
  • {:error, reason} on failure