Metadata-Version: 2.1
Name: promptedgraphs
Version: 0.1.0
Summary: A template to build and deploy fastapi applications
License: MIT
Author: Sean Kruzel
Author-email: sean@closedloop.tech
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: colorama (>=0.4.6,<0.5.0)
Requires-Dist: dataclasses-json (>=0.6.0,<0.7.0)
Requires-Dist: gcloud (>=0.18.3,<0.19.0)
Requires-Dist: httpx (>=0.25.0,<0.26.0)
Requires-Dist: pre-commit (>=3.3.1,<4.0.0)
Requires-Dist: pydantic (>=2.3.0,<3.0.0)
Requires-Dist: pyfiglet (>=0.8.post1,<0.9)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: spacy (>=3.6.1,<4.0.0)
Requires-Dist: sse-starlette (>=1.6.5,<2.0.0)
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
Requires-Dist: termcolor (>=2.3.0,<3.0.0)
Requires-Dist: tiktoken (>=0.5.1,<0.6.0)
Requires-Dist: twine (>=4.0.2,<5.0.0)
Requires-Dist: typer (>=0.9.0,<0.10.0)
Project-URL: Bug Tracker, https://github.com/closedLoop/promptedgraphs/issues
Project-URL: Repository, https://github.com/closedLoop/promptedgraphs
Description-Content-Type: text/markdown

# PromptedGraphs

**From Dataset Labeling to Deployment: The Power of NLP and LLMs Combined.**

## Description

PromptedGraphs is a Python library that aims to seamlessly integrate traditional NLP methods with the capabilities of modern Large Language Models (LLMs) in the realm of knowledge graphs. Our library offers tools tailored for dataset labeling, model training, and smooth deployment to production environments. We leverage the strengths of [spacy](https://github.com/explosion/spaCy) for core NLP tasks, [snorkel](https://github.com/closedloop-technologies/snorkel) for effective data labeling, and `async` to ensure enhanced performance. Our mission is to provide a harmonized solution to knowledge graph development when you have to merge traditional and LLM-driven approaches, squarely addressing the challenges associated with accuracy, efficiency, and affordability.

## ✨ Features

- **Named Entity Recognition (NER)**: Customize ER labels based on your domain.
- **Entity Resolution**: Deduplication and normalization
- **Relationship Extraction**: Either open ended labels or constrain to your domain
- **Entity Linking**: Link references in text to entities in a graph
- **Graph Construction**: Create or update knowledge graphs

## Core Functions

- **Dataset Labeling**: Efficient tools for labeling datasets, powered by `haystack`.
- **Model Training**: Combine the reliability of NLP and the prowess of LLMs.
- **Deployment**: Streamlined processes to ensure smooth transition to production.

## Requirements

- Python 3.10 or newer.

## 📦 Installation

To install `PromptedGraphs` via pip:

```bash
pip install promptedgraphs
# or
poetry add promptedgraphs
```

## Usage

from [examples/er_reviews.ipynb](https://github.com/closedloop-technologies/promptedgraphs/examples/er_reviews.ipynb)

```python
from spacy import displacy
from promptedgraphs.config import Config
from promptedgraphs.entity_recognition import extract_entities

labels = {
    "POSITIVE": "A postive review of a product or service.",
    "NEGATIVE": "A negative review of a product or service.",
    "NEUTRAL": "A neutral review of a product or service.",
}

text_of_reviews = """
1. "I absolutely love this product. It's been a game changer!"
2. "The service was quite poor and the staff was rude."
3. "The item is okay. Nothing special, but it gets the job done."
""".strip()


# Label Sentiment
ents = []
async for msg in extract_entities(
    name="sentiment",
    description="Sentiment Analysis of Customer Reviews",
    text=text_of_reviews,
    labels=labels,
    config=Config(),  # Reads `OPENAI_API_KEY` from .env file or environment
):
    ents.append(msg)

# Show Results using spacy.displacy
displacy.render(
    {
        "text": text_of_reviews,
        "ents": [e.to_dict() for e in ents],
    },
    style="ent",
    jupyter=True,
    manual=True,
    options={
        "colors": {"POSITIVE": "#7aecec", "NEGATIVE": "#f44336", "NEUTRAL": "#f4f442"}
    },
)
```
![displacy-sentiment-example](./assets/displacy-sentiment-example.png?raw=true)


## 📚 Resources

  * [Awesome-LLM-KG](https://github.com/RManLuo/Awesome-LLM-KG)
  * [KG-LLM-Papers](https://github.com/zjukg/KG-LLM-Papers)

## Contributing

We welcome contributions! Please DM me [@seankruzel](https://twitter.com/seankruzel) or create issues or pull requests.

## 📝 License

This project is licensed under the terms of the [MIT license](/LICENSE).

Built using [quantready](https://github.com/closedloop-technologies/quantready) using template [https://github.com/closedloop-technologies/quantready-api](https://github.com/closedloop-technologies/quantready-api)

