Skip to main content

convertanything is a Python package that allows you to convert any text into a structured format according to the schema provided.

Project description

convertanything

convertanything is a simple way to convert any unstructured texts into pydantic models in Python with the use of language models. See the examples notebook for more details.

Installation

pip install convertanything

Usage Examples

ezLocalai

To use with ezLocalai in Python, make sure your ezLocalai server is running then run the following code:

from convertanything import convertanything
from pydantic import BaseModel
from typing import List


class Person(BaseModel):
    name: str
    age: int
    email: str
    interests: List[str]


response = convertanything(
    input_string="Hi my name is John Doe, I am 30 years old, my email is johndoe@example.com . I like to go fishing and watching football.",
    model=Person,
    api_key="Your ezlocalai API Key",
    server="http://localhost:8091",
)
print(response)

AGiXT

To use with AGiXT in Python, make sure your AGiXT server is running then run the following code:

from convertanything import convertanything
from pydantic import BaseModel
from typing import List


class Person(BaseModel):
    name: str
    age: int
    email: str
    interests: List[str]


response = convertanything(
    input_string="Hi my name is John Doe, I am 30 years old, my email is johndoe@example.com . I like to go fishing and watching football.",
    model=Person,
    api_key="Your AGiXT API Key",
    server="http://localhost:7437",
    llm="Your AGiXT Agent Name",
    prompt_name="User Input",
)
print(response)

OpenAI

If you have an OpenAI API key, you can use it as follows with OpenAI language models:

from convertanything import convertanything
from pydantic import BaseModel
from typing import List

class Person(BaseModel):
    name: str
    age: int
    email: str
    interests: List[str]

response = convertanything(
    input_string="Hi my name is John Doe, I am 30 years old, my email is johndoe@example.com . I like to go fishing.",
    model=Person,
    api_key="Your OpenAI API Key",
    llm="gpt-3.5-turbo",
)
print(response)

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

convertanything-0.0.16.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

convertanything-0.0.16-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

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