Skip to main content

From Chaos

A python library for extracting organized data out of chaos using large-language-models (LLMs) like ChatGPT and Gemini-Pro.

Installation

To install, use the following command:

pip install fromchaos

In order to use FromChaos, you must have the following environment variable set in the environment where your script is running:

OPENAI_API_KEY="<<your-openai-api-key-here>>"

Using FromChaos

FromChaos uses ChatGPT as its primary LLM (though others could be incorporated if desired). It accepts at its most basic level a question (about the data you want to get back), and the context (where to extract the value from).

Depending on your use-case, there are different classes of FromChaos to use. The following are code examples.


FromChaosList - Parsing Data To A List

With a block of text, using FromChaosList you can extract values as a python list.

from fromchaos import FromChaosList

context = """
This is a long string of data, it could be anything you like, plain text,
html, markdown, or something else like JSON.
"""

question = "Identify all data types that are mentioned"

try:
    chaos = FromChaosList(question, context, model='gpt-4')
    print(chaos.response)
except Exception:
    print('An error occured')

The response is a python list object, or an exception is thrown.

[
    "plain text",
    "html",
    "markdown",
    "json"
]

FromChaosShortString - Short Strings

For a quick summary of something, use the FromChaosShortString class.

from fromchaos import FromChaosShortString

context = """
Some very large text that talks about a variety of different things. Canada is a really big country. Australia is also big, but there are spiders. Italy has very good food. There's really good beef noodle soup in Taiwan.
"""

question = "Summarize what is talked about in these paragraphs."

try:
    chaos = FromChaosShortString(question, context, model='gpt-4')
    print(chaos.response)
except Exception:
    print('An error occured')

The response is a short python string.

The text talks about various characteristics of Canada, Australia, Italy, and Taiwan.

FromChaosBoolOrNone - True/False, or None values

For classifying something as either True, False, or None, use the FromChaosBoolOrNone class.

from fromchaos import FromChaosBoolOrNone

context = """
Some very large text that talks about a variety of different things. Canada is a really big country. Australia is also big, but there are spiders. Italy has very good food. There's really good beef noodle soup in Taiwan.
"""

question = "Is the united states mentioned in this paragraph?."

try:
    chaos = FromChaosBoolOrNone(question, context, model='gpt-4')
    print(chaos.response)
except Exception:
    print('An error occured')

The response is a boolean object, or Nonetype.

False

FromChaosParagraph - Get a paragraph of text

FromChaosParagraph works similar to FromChaosShortString, except instead of a succinct response, it allows the model to elaborate for a little bit for a longer response.

from fromchaos import FromChaosParagraph

context = """
The working holiday visa is valid for 12 months and it cannot be renewed. Applicants must show proof of funds. To apply, visit the consolate and pay the application fee of $65 CAD, then wait 3 weeks.
"""

question = "Summarize this visa."

try:
    chaos = FromChaosParagraph(question, context, model='gpt-4', max_chars=2000)
    print(chaos.response)
except Exception:
    print('An error occured')

The response is returned as a long string of text, or an exception is thrown

This visa is a working-holiday visa, with a validity of 12 months. This visa is non-renewable. For those interested in applying, proof of sufficient funds must be shown, and the consulate must be visited. An application fee of $65 CAD will apply, and a 3-week waiting period will be required.

FromChaosDict - Getting a dictionary

FromChaosDict allows you to pass in a dictionary of your choosing as a sample object, and get the response in the same format.

from fromchaos import FromChaosDict

context = """
The working holiday visa is valid for 12 months and it cannot be renewed. Applicants must show proof of funds. To apply, visit the consolate and pay the application fee of $65 CAD, then wait 3 weeks.
"""

question = "What is the fee, if any, for applying to this visa?."

sample_obj = {
    'amount': 400,
    'currency': 'USD'
}

try:
    chaos = FromChaosDict(question, context, sample_obj=sample_obj, model='gpt-4')
    print(chaos.response)
except Exception:
    print('An error occured')

The response is returned as a python dictionary, or an exception is thrown

{
    "amount": 65,
    "currency": "CAD"
}

Metadata

Release files for fromchaos 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fromchaos 0.0.10
File Size Uploaded Provenance Actions
fromchaos-0.0.10.tar.gz 5.4 kB Without provenance Details for fromchaos-0.0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fromchaos 0.0.10
File Interpreter ABI Platform Actions
fromchaos-0.0.10-py3-none-any.whl Python 3 none any Details for fromchaos-0.0.10-py3-none-any.whl

Total release size: 11.0 kB

Release files / fromchaos-0.0.10.tar.gz

Download URL fromchaos-0.0.10.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b900273ac291542db7baecd069d70665a72a625feb3d225b97932ce094267049
BLAKE2b-256 checksum
How to use checksums
859538eaf3ea573105c307ef412bd2dc4367e24ee24a670c19684f25e543caa0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / fromchaos-0.0.10-py3-none-any.whl

Download URL fromchaos-0.0.10-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbff02cd606d7383b5d27be293c7d14299cfe6e5f45df385d5cd41a6d7288d7c
BLAKE2b-256 checksum
How to use checksums
e2fae4ce1d797c50e695a39ec87306e4d0f1ca158bed43ff281b1dd2b8a5ae85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Security for fromchaos 0.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page