Lang2Logic


NameLang2Logic JSON
Version 1.2.0 PyPI version JSON
download
home_page
SummaryA package for generating, validating, and utilizing Draft-7 JSON schemas with LangChain
upload_time2024-01-10 23:45:09
maintainer
docs_urlNone
authorDylan Wilson
requires_python>=3.7, <4
licenseCC0-1.0
keywords language models structured output
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Lang2Logic Python Package

## Introduction

Lang2Logic: Generating python objects with natural language.

## Overview

Lang2Logic is an innovative Python package designed for developers who need to translate natural language prompts into structured Python outputs. Utilizing advanced language processing algorithms, Lang2Logic simplifies generating Python code from verbal or written descriptions.

## Key Features

- **Natural Language to Python Conversion**: Converts natural language instructions into Python code, facilitating easier programming and automation.
- **Dynamic Schema Generation**: Automatically generates schema from natural language inputs, providing structured outputs like lists, dictionaries, etc.
- **Flexible API Integration**: User-friendly API for seamless integration with existing Python projects.

## Installation and Usage

```python
import os
from Lang2Logic.generator import Generator

# Initialize with API key
test_gen = Generator(os.environ.get("YOUR_API_KEY"))

# Generate schema from natural language
schema = test_gen.generate_schema("return a list of strings")

# The 'schema' here is an instance of the ResponseSchema class
```

### Using the ResponseSchema Class

The `ResponseSchema` class is designed to handle and manipulate JSON schemas. It can accept a JSON string, a dictionary, or another instance of itself to create or modify a schema.

#### Creating an Instance

```python
from Lang2Logic.response_schema import ResponseSchema

# Create a ResponseSchema instance from a dictionary
schema_dict = {"type": "object", "properties": {"name": {"type": "string"}}}
schema = ResponseSchema(schema_dict)

# Or from another ResponseSchema instance
another_schema = ResponseSchema(schema)
```

#### Getting Dictionary or JSON Representation

```python
# Get the schema as a dictionary
schema_dict = schema.to_dict()

# Convert the schema to a JSON string
schema_json = schema.to_json()
```

#### Saving Schema to a File

```python
# Save the schema to a JSON file
schema.save_to_json(key="mySchema", filepath="path/to/file.json")
```

### Automatic Schema Generation

```python
test_gen.generate("return a list of strings with 5 colors")
# The output is an instance of ResponseSchema
# Output: ["color1", "color2", "color3", "color4", "color5"]
```

### Example Usage

#### Classifying Decisions and Preferences

```python
schema = test_gen.generate_schema("return a dictionary with keys 'rational' and 'decision' (boolean)")

potential_buyers = []
for user in users_data_json["bios"]:
    decision = test_gen.generate(f"return true if this user might be interested in products related to rock climbing.\nUser Bio:\n{user['bio']}", schema)
    if decision["decision"]:
        potential_buyers.append(user)
```

## Roadmap

- **Function Generation**
- **Optimized Logic for Increased Accuracy**
- **Code Parsing and LLM integration tools**
- **Python Agents**

## Bug Reporting and Contributions

Found a bug or have a suggestion? Please contact [dylanpwilson2005@gmail.com](mailto:dylanpwilson2005@gmail.com).

## License

Lang2Logic is available under a Creative Commons license and may not be used for commercial purposes without explicit consent from the author.



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "Lang2Logic",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7, <4",
    "maintainer_email": "",
    "keywords": "language models,structured output",
    "author": "Dylan Wilson",
    "author_email": "dylanpwilson2005@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bd/6c/75579f27d42d88dc44c30dcf79166325df93e363c19910b1bca06b6898ff/Lang2Logic-1.2.0.tar.gz",
    "platform": null,
    "description": "\n# Lang2Logic Python Package\n\n## Introduction\n\nLang2Logic: Generating python objects with natural language.\n\n## Overview\n\nLang2Logic is an innovative Python package designed for developers who need to translate natural language prompts into structured Python outputs. Utilizing advanced language processing algorithms, Lang2Logic simplifies generating Python code from verbal or written descriptions.\n\n## Key Features\n\n- **Natural Language to Python Conversion**: Converts natural language instructions into Python code, facilitating easier programming and automation.\n- **Dynamic Schema Generation**: Automatically generates schema from natural language inputs, providing structured outputs like lists, dictionaries, etc.\n- **Flexible API Integration**: User-friendly API for seamless integration with existing Python projects.\n\n## Installation and Usage\n\n```python\nimport os\nfrom Lang2Logic.generator import Generator\n\n# Initialize with API key\ntest_gen = Generator(os.environ.get(\"YOUR_API_KEY\"))\n\n# Generate schema from natural language\nschema = test_gen.generate_schema(\"return a list of strings\")\n\n# The 'schema' here is an instance of the ResponseSchema class\n```\n\n### Using the ResponseSchema Class\n\nThe `ResponseSchema` class is designed to handle and manipulate JSON schemas. It can accept a JSON string, a dictionary, or another instance of itself to create or modify a schema.\n\n#### Creating an Instance\n\n```python\nfrom Lang2Logic.response_schema import ResponseSchema\n\n# Create a ResponseSchema instance from a dictionary\nschema_dict = {\"type\": \"object\", \"properties\": {\"name\": {\"type\": \"string\"}}}\nschema = ResponseSchema(schema_dict)\n\n# Or from another ResponseSchema instance\nanother_schema = ResponseSchema(schema)\n```\n\n#### Getting Dictionary or JSON Representation\n\n```python\n# Get the schema as a dictionary\nschema_dict = schema.to_dict()\n\n# Convert the schema to a JSON string\nschema_json = schema.to_json()\n```\n\n#### Saving Schema to a File\n\n```python\n# Save the schema to a JSON file\nschema.save_to_json(key=\"mySchema\", filepath=\"path/to/file.json\")\n```\n\n### Automatic Schema Generation\n\n```python\ntest_gen.generate(\"return a list of strings with 5 colors\")\n# The output is an instance of ResponseSchema\n# Output: [\"color1\", \"color2\", \"color3\", \"color4\", \"color5\"]\n```\n\n### Example Usage\n\n#### Classifying Decisions and Preferences\n\n```python\nschema = test_gen.generate_schema(\"return a dictionary with keys 'rational' and 'decision' (boolean)\")\n\npotential_buyers = []\nfor user in users_data_json[\"bios\"]:\n    decision = test_gen.generate(f\"return true if this user might be interested in products related to rock climbing.\\nUser Bio:\\n{user['bio']}\", schema)\n    if decision[\"decision\"]:\n        potential_buyers.append(user)\n```\n\n## Roadmap\n\n- **Function Generation**\n- **Optimized Logic for Increased Accuracy**\n- **Code Parsing and LLM integration tools**\n- **Python Agents**\n\n## Bug Reporting and Contributions\n\nFound a bug or have a suggestion? Please contact [dylanpwilson2005@gmail.com](mailto:dylanpwilson2005@gmail.com).\n\n## License\n\nLang2Logic is available under a Creative Commons license and may not be used for commercial purposes without explicit consent from the author.\n\n\n",
    "bugtrack_url": null,
    "license": "CC0-1.0",
    "summary": "A package for generating, validating, and utilizing Draft-7 JSON schemas with LangChain",
    "version": "1.2.0",
    "project_urls": null,
    "split_keywords": [
        "language models",
        "structured output"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a9e217e2e119467b8440d9ce6f264f71e53fb83165bd162b597ca730e3841e4e",
                "md5": "431fbb0108fa98ef8d1085719cb59c49",
                "sha256": "ad866bab7821b22580f6ac42133946b7ff477d18b5facc93471b25bb234c2f77"
            },
            "downloads": -1,
            "filename": "Lang2Logic-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "431fbb0108fa98ef8d1085719cb59c49",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7, <4",
            "size": 18356,
            "upload_time": "2024-01-10T23:45:07",
            "upload_time_iso_8601": "2024-01-10T23:45:07.333686Z",
            "url": "https://files.pythonhosted.org/packages/a9/e2/17e2e119467b8440d9ce6f264f71e53fb83165bd162b597ca730e3841e4e/Lang2Logic-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd6c75579f27d42d88dc44c30dcf79166325df93e363c19910b1bca06b6898ff",
                "md5": "e590bcb0f52e6722803e5103aceb3776",
                "sha256": "c4f1b25516da150fe327dc70fe9011774d30e9d0c1ea9c6dae9f2d9c72232fb7"
            },
            "downloads": -1,
            "filename": "Lang2Logic-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e590bcb0f52e6722803e5103aceb3776",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7, <4",
            "size": 17038,
            "upload_time": "2024-01-10T23:45:09",
            "upload_time_iso_8601": "2024-01-10T23:45:09.791467Z",
            "url": "https://files.pythonhosted.org/packages/bd/6c/75579f27d42d88dc44c30dcf79166325df93e363c19910b1bca06b6898ff/Lang2Logic-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-10 23:45:09",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "lang2logic"
}
        
Elapsed time: 0.17612s