Skip to main content

Join two keyed lists with the use of LLMs

Project description

Introduction

Joinly is a library that is mean to help assist in the joining of two different lists of items using a LLM. Like a human data annotator you can provide context through a prompt on how you want the task achieved. The library supports inner, left, right, and full joins.

By default the library uses OpenAI's gpt-4o model. You will need to set your OpenAI credentials prior to using the library with:

 OPENAI_API_KEY=XXXX

Installation

pip install llm-joinly

Quickstart

Let's say you have two lists of fruits. One is a bit more specific with types of each fruit while the second one is more general. Joinly allows you to describe the task you want and join in a fuzzy way using LLMs.

from joinly import join

context = '''
You are joining fruits so make sure to be aware of that fruits
have different types but make sure the catagory is correct
'''

left = [
    ("apple", 1),
    ("banana", 2),
    ("orange", 3),
]

right = [
    ("honeycrisp", 4),
    ("florida orange", 5),
    ("gala", 6),
    ("grannysmith", 7)
]

results = join.inner_join(left, right, context=context)
> [
 (('apple', 1), ('honeycrisp', 4)),
 (('apple', 1), ('gala', 6)),
 (('apple', 1), ('grannysmith', 7)),
 (('orange', 3), ('florida orange', 5))
]

Other Models

You can bring in any custom model as BaseAI with an embedding method and a prompt.

from joinly.ai import BaseAI


class MyAI(BaseAI):
    def __init__(self) -> None:
        self.client = ...

    def __call__(self, system_message: str, user_message: str) -> Optional[str]
        pass

    def embed(self, text: str) -> Optional[ArrayLike]:
        pass


results = join.inner_join(left, right, context=context, llm=MyAI())

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

joinly-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

joinly-0.1.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file joinly-0.1.1.tar.gz.

File metadata

  • Download URL: joinly-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for joinly-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1945c7c5afd019cf276ec94e63836c06b1c8aff9ff7c49f187a5b3e2dd93f790
MD5 8b1cf10407f32c01ed616e95525d4a49
BLAKE2b-256 eb7c998c76df648dc0d1436fbdbd5a2d3f373a2ce9c69d6e7ad3ab1a51df7746

See more details on using hashes here.

File details

Details for the file joinly-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: joinly-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for joinly-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9cdf8d1a1cac38c7e4c208ea8b78246da0a1431989ecfb3462a6164ae341f62d
MD5 07f5602ae8c46ff5f8ee556e1ba8c464
BLAKE2b-256 89595f3c1b91678cd880a01feb18f168339d2cc5fa65c1999aab6aced4d32ce9

See more details on using hashes here.

Supported by

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