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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file convertanything-0.0.16.tar.gz
.
File metadata
- Download URL: convertanything-0.0.16.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa6c756c48df6ae0709fd597de4bcedf306e288572223a7d6cb7c1660eeb40c0 |
|
MD5 | ce0ad4d4c0c4a559eb0e8269c9f14371 |
|
BLAKE2b-256 | 39e6ef5adcbd6591c5dd3514893152a07789d364905d3fae487cbc6c588cfed7 |
File details
Details for the file convertanything-0.0.16-py3-none-any.whl
.
File metadata
- Download URL: convertanything-0.0.16-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b82bcedabc201840a196375c8e7a4ec4e2e0aa65b095ef9d51e9d8b5b31a23ec |
|
MD5 | 96ac85c964d927788e092df56bd4eee0 |
|
BLAKE2b-256 | f3c54ad38e2d39c0b022b45797cf096cfe1b38cb8457da550c1852d39db78677 |