etoile-generate


Nameetoile-generate JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-10-06 04:00:09
maintainerNone
docs_urlNone
authorEugene Evstafev
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://badge.fury.io/py/etoile_generate.svg)](https://badge.fury.io/py/etoile_generate)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Downloads](https://static.pepy.tech/badge/etoile_generate)](https://pepy.tech/project/etoile_generate)

# etoile_generate

`etoile_generate` is a Python package developed for the Mistral AI <> a16z London Hackathon held on 06/10/2024. This package facilitates the generation of structured data from natural language queries using machine learning models, integrating with LangChain and HuggingFace technologies to provide seamless experience in transforming text into actionable insights within knowledge graphs.

## Installation

To install `etoile_generate`, use pip:

```bash
pip install etoile_generate
```

## Usage

Here is a detailed example of using `etoile_generate` to extract nodes from natural language texts and transform them into structured JSON format:

### Define the Model

```python
from langchain_mistralai import ChatMistralAI

MODEL = "mistral-large-latest"
llm = ChatMistralAI(
    model=MODEL,
    temperature=0,
    max_retries=2
)
```

### Define the Pydantic Models

```python
from langchain_core.pydantic_v1 import BaseModel, Field
from typing import List

class Node(BaseModel):
    node_name: str = Field(..., title="Name of the node")

class Nodes(BaseModel):
    nodes: List[Node] = Field(..., title="List of nodes")
```

### Generate Nodes

```python
from etoile_generate import generate
from langchain_huggingface import HuggingFaceEmbeddings

texts = ["Your text data..."]
query = """
Generate nodes from the given texts.
Nodes are the basic building blocks of a knowledge graph.
The output will be a list of nodes.
Example:
{
    "nodes": [
        {
            "node_name": "Node 1"
        },
        {
            "node_name": "Node 2"
        }
    ]
}
Write the response in JSON format within ``` tags and provide the response only, without any additional explanation.
"""

# Invoke the generation function
result = generate(
    model=llm,
    embeddings=HuggingFaceEmbeddings(),
    pydantic_object=Nodes,
    texts=texts,
    query=query,
    chat_history=[]
)
print(result)
# Example Output: Nodes(nodes=[Node(node_name='Playwright'), ... (list all example nodes) ...])
```

### Image Processing

`etoile_generate` can also process images by accepting image URLs as part of the input:

```python
after_query = HumanMessage(content=[{
    "type": "image_url",
    "image_url": {"url": "https://example.com/path/to/image.jpg"}
}])

result = generate(
    model=llm,
    embeddings=HuggingFaceEmbeddings(),
    pydantic_object=TestContentSafety,
    texts=[],
    query="Query to analyze the image content for safety",
    chat_history=[],
    after_query=after_query,
    verbose=True
)
print(result)
```

## Features

- Generate structured JSON outputs from natural language inputs.
- Integrated vector storage and retrieval through FAISS.
- Utilizes state-of-the-art embeddings and LLMs from HuggingFace and LangChain.

## Contributing

Contributions, issues, and feature requests are welcome! Please feel free to check the [issues page](https://github.com/chigwell/Mistral-Etoile-London-Hackathon/issues).

## License

`etoile_generate` is licensed under the [MIT License](https://choosealicense.com/licenses/mit/).

## Acknowledgements

This package was created by [Evgenii (Eugene) Evstafev](https://www.linkedin.com/in/eugene-evstafev-716669181/) for the project Mistral Étoile at the Mistral AI <> a16z London Hackathon. More details about the event can be found [here](https://cerebralvalley.notion.site/Mistral-AI-a16z-London-Hackathon-Event-Details-Hackers-62cdf3e742a745aa9f4c31d20a8882af).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "etoile-generate",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Eugene Evstafev",
    "author_email": "chigwel@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8f/47/27fd3fda0bb2630cb0058587b32c41b2bfe671a85959e34126b20cb3dfff/etoile_generate-0.0.2.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://badge.fury.io/py/etoile_generate.svg)](https://badge.fury.io/py/etoile_generate)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n[![Downloads](https://static.pepy.tech/badge/etoile_generate)](https://pepy.tech/project/etoile_generate)\n\n# etoile_generate\n\n`etoile_generate` is a Python package developed for the Mistral AI <> a16z London Hackathon held on 06/10/2024. This package facilitates the generation of structured data from natural language queries using machine learning models, integrating with LangChain and HuggingFace technologies to provide seamless experience in transforming text into actionable insights within knowledge graphs.\n\n## Installation\n\nTo install `etoile_generate`, use pip:\n\n```bash\npip install etoile_generate\n```\n\n## Usage\n\nHere is a detailed example of using `etoile_generate` to extract nodes from natural language texts and transform them into structured JSON format:\n\n### Define the Model\n\n```python\nfrom langchain_mistralai import ChatMistralAI\n\nMODEL = \"mistral-large-latest\"\nllm = ChatMistralAI(\n    model=MODEL,\n    temperature=0,\n    max_retries=2\n)\n```\n\n### Define the Pydantic Models\n\n```python\nfrom langchain_core.pydantic_v1 import BaseModel, Field\nfrom typing import List\n\nclass Node(BaseModel):\n    node_name: str = Field(..., title=\"Name of the node\")\n\nclass Nodes(BaseModel):\n    nodes: List[Node] = Field(..., title=\"List of nodes\")\n```\n\n### Generate Nodes\n\n```python\nfrom etoile_generate import generate\nfrom langchain_huggingface import HuggingFaceEmbeddings\n\ntexts = [\"Your text data...\"]\nquery = \"\"\"\nGenerate nodes from the given texts.\nNodes are the basic building blocks of a knowledge graph.\nThe output will be a list of nodes.\nExample:\n{\n    \"nodes\": [\n        {\n            \"node_name\": \"Node 1\"\n        },\n        {\n            \"node_name\": \"Node 2\"\n        }\n    ]\n}\nWrite the response in JSON format within ``` tags and provide the response only, without any additional explanation.\n\"\"\"\n\n# Invoke the generation function\nresult = generate(\n    model=llm,\n    embeddings=HuggingFaceEmbeddings(),\n    pydantic_object=Nodes,\n    texts=texts,\n    query=query,\n    chat_history=[]\n)\nprint(result)\n# Example Output: Nodes(nodes=[Node(node_name='Playwright'), ... (list all example nodes) ...])\n```\n\n### Image Processing\n\n`etoile_generate` can also process images by accepting image URLs as part of the input:\n\n```python\nafter_query = HumanMessage(content=[{\n    \"type\": \"image_url\",\n    \"image_url\": {\"url\": \"https://example.com/path/to/image.jpg\"}\n}])\n\nresult = generate(\n    model=llm,\n    embeddings=HuggingFaceEmbeddings(),\n    pydantic_object=TestContentSafety,\n    texts=[],\n    query=\"Query to analyze the image content for safety\",\n    chat_history=[],\n    after_query=after_query,\n    verbose=True\n)\nprint(result)\n```\n\n## Features\n\n- Generate structured JSON outputs from natural language inputs.\n- Integrated vector storage and retrieval through FAISS.\n- Utilizes state-of-the-art embeddings and LLMs from HuggingFace and LangChain.\n\n## Contributing\n\nContributions, issues, and feature requests are welcome! Please feel free to check the [issues page](https://github.com/chigwell/Mistral-Etoile-London-Hackathon/issues).\n\n## License\n\n`etoile_generate` is licensed under the [MIT License](https://choosealicense.com/licenses/mit/).\n\n## Acknowledgements\n\nThis package was created by [Evgenii (Eugene) Evstafev](https://www.linkedin.com/in/eugene-evstafev-716669181/) for the project Mistral \u00c9toile at the Mistral AI <> a16z London Hackathon. More details about the event can be found [here](https://cerebralvalley.notion.site/Mistral-AI-a16z-London-Hackathon-Event-Details-Hackers-62cdf3e742a745aa9f4c31d20a8882af).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": null,
    "version": "0.0.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "88ee6c52fd9cd9af500e9800fbcafa14fe11a06c8ab4788a126e9f889597030e",
                "md5": "0b60f25c33354c3a54ca84c49ca4fc3a",
                "sha256": "3428085023c4ab9cbfa8a80ebd8ad72d6b98a7b98204aceb6965fa7f7817d347"
            },
            "downloads": -1,
            "filename": "etoile_generate-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b60f25c33354c3a54ca84c49ca4fc3a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4230,
            "upload_time": "2024-10-06T04:00:06",
            "upload_time_iso_8601": "2024-10-06T04:00:06.600256Z",
            "url": "https://files.pythonhosted.org/packages/88/ee/6c52fd9cd9af500e9800fbcafa14fe11a06c8ab4788a126e9f889597030e/etoile_generate-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f4727fd3fda0bb2630cb0058587b32c41b2bfe671a85959e34126b20cb3dfff",
                "md5": "c5b15ffe3924c384e97d137d8a386000",
                "sha256": "d2d0a94ab2f9b3c68769e076a98f5b7d9fd2acba8261420222bd8cc755963ed8"
            },
            "downloads": -1,
            "filename": "etoile_generate-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c5b15ffe3924c384e97d137d8a386000",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4140,
            "upload_time": "2024-10-06T04:00:09",
            "upload_time_iso_8601": "2024-10-06T04:00:09.178095Z",
            "url": "https://files.pythonhosted.org/packages/8f/47/27fd3fda0bb2630cb0058587b32c41b2bfe671a85959e34126b20cb3dfff/etoile_generate-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-06 04:00:09",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "etoile-generate"
}
        
Elapsed time: 1.31382s