array

class numpyai.array(data, verbose=False, provider_name='google', model_name=None)

Bases: object

A wrapper around numpy.ndarray providing AI-powered functionalities and extended operations.

Parameters:
  • data – numpy.ndarray The data of the array class.

  • verbose – bool, default=True If False, only show rich console outputs when the try is the last try, successful, or fails in the last try.

  • provider_name (str) – LLM provider name (“google”, “openai”, or “claude”).

  • model_name (Optional[str]) – Specific model name to use (defaults per provider).

assert_is_code(llm_response, attempt=1)

Ensure LLM response is valid Python/NumPy code.

chat(query)

Handles user queries by generating and executing NumPy code.

property data
execute_numpy_code(code, args)

Execute the generated code safely.

Parameters:
  • code – The code to execute

  • args – Either the array itself or a dict containing variables for execution

generate_numpy_code(query, attempt=1)

Generate valid NumPy code from the query.