Skip to main content

This package brings language model capabilities into the coding environment, providing a variety of functionalities.

Project description

utilityai

This package brings language model capabilities into the coding environment, providing a variety of functionalities such as:

  • Message and ask anything
  • Chat and have a conversation
  • Chat about a function
  • Chat about a numpy array
  • Chat about a pandas dataframe
  • Chat about a pytorch tensor
  • Generate a function interactively
  • Generate a function by setting data within the code
  • Generate a function and provide a comment on the result for guided generation

Function generation feature iteratively builds and refines functions by evaluating them against predefined test cases.

install

pip install utilityai

quick start

Download the model once after installation

from utilityai.model import download
download()

Message and ask anything

from utilityai.chat import message
message("How do you transpose a PyTorch tensor?");

Message and ask anything

Chat and have a conversation

from utilityai.chat import message
r1, c1 = message("What do mutable and immutable mean?")
message("Give more examples.", c1);

Chat and have a conversation

Chat about a function

from utilityai.chat import message
def list_sum(numbers):
    return sum(numbers)
r1, c1 = message("What does this do?", attachment=list_sum)
message("Return the minimum and maximum values of the numbers instead.", c1);

Chat about a function

Chat about a numpy array

from utilityai.chat import message
import numpy as np
array = np.array([[1, 2, 3, 4], 
                  [5, 6, 7, 8], 
                  [9, 10, 11, 12]])
r1, c1 = message("Each row represents the salary of a person. How do I calculate the average salary of each person in another array?", attachment=array)
message("How do I calculate the average salary of these people for each year in an array?", c1);

Chat about a numpy array

Chat about a pandas dataframe

from utilityai.chat import message
import pandas as pd
data = {
    'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve'],
    'Age': [24, 27, 22, 32, 29],
    'Salary': [50000, 54000, 49000, 62000, 58000],
    'Department': ['HR', 'Engineering', 'Marketing', 'Finance', 'Engineering'],
    'Joining Date': pd.to_datetime(['2020-01-15', '2019-06-23', '2021-03-01', '2018-11-15', '2020-08-30'])
}
df = pd.DataFrame(data)
r1, c1 = message("How to calculate the average salary?", attachment=df)
message("How to calculate the average salary for each department?", c1);

Chat about a pandas dataframe

Chat about a pytorch tensor

from utilityai.chat import message
import torch
tensor = torch.tensor([[1, 2, 3], [4, 5, 6]])
r1, c1 = message("How to transpose this tensor?", attachment=tensor)
message("How to determine the size of the resulting tensor?", c1);

Chat about a pytorch tensor

Generate a function interactively by calling data() first, then provide function information

from utilityai.code import InputData, function
data = InputData()
data()
function(data);

Generate a function interactively by calling data() first, then provide function information

Generate a function by setting data within the code

from utilityai.code import InputData, function
data = InputData()
data_dict = {
    'function_name': 'prime_number_checker',
    'input_names': ['num'],
    'input_types': ['int'],
    'output_names': ['is_prime'],
    'output_types': ['bool'],
    'description': "A function to check if a given number is prime.",
    'test_cases': [
        {'inputs': [5], 'outputs': [True]},
        {'inputs': [10], 'outputs': [False]},
        {'inputs': [17], 'outputs': [True]}
    ]
}
data.set_data(data_dict['function_name'], data_dict['input_names'], data_dict['output_names'], data_dict['input_types'], data_dict['output_types'], data_dict['description'], data_dict['test_cases'])
function(data);

Generate a function by setting data within the code

Generate a function and provide a comment on the result for guided generation

from utilityai.code import InputData, function
data = InputData()
data_dict = {
    'function_name': 'vague_function',
    'input_names': ['a', 'b'],
    'input_types': ['int', 'int'],
    'output_names': ['subtract'],
    'output_types': ['int'],
    'description': "A function to subtract two numbers.",
    'test_cases': [
        {'inputs': [1,2], 'outputs': [1]}
    ]
}
data.set_data(data_dict['function_name'], data_dict['input_names'], data_dict['output_names'], data_dict['input_types'], data_dict['output_types'], data_dict['description'], data_dict['test_cases'])
res = function(data, max_tries=1)
res.comment = "A function that subtracts the smaller number from the larger one."
function(data, res);

Generate a function and provide a comment on the result for guided generation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utilityai-1.0.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

utilityai-1.0.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file utilityai-1.0.1.tar.gz.

File metadata

  • Download URL: utilityai-1.0.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2

File hashes

Hashes for utilityai-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1b909a370ea7b7fd12dd382369226510390f2e1eb047b4925a74cced56586ee1
MD5 666321ae358418986320369c7524bf23
BLAKE2b-256 e6039f1a096c0d7381973660420ea017a5cf3bc0eab2d1a007eae1a49f779cc7

See more details on using hashes here.

File details

Details for the file utilityai-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: utilityai-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2

File hashes

Hashes for utilityai-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7cb15bd4334f1ec664b2ea0981b499d820cf7cac6e5c1846695a5f2eb7fe056b
MD5 4b0f15d22a971f343d2bf412f2985b97
BLAKE2b-256 95b8e475cbcf5a5f17ff5650f943f59350a6f1c6a0f5484c25c32b692a843d4f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page