langchain-tilores


Namelangchain-tilores JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryThis package contains tools to work with Tilores entity resolution database within Langchain.
upload_time2024-09-11 15:22:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Tilo Tech GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords entity-resolution tilores graph-raq langchain langchain-tool
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LangChain Using Tilores

This repository provides the building blocks for integrating LangChain, LangGraph, and the
Tilores entity resolution system.

Developers can use these tools to create powerful systems that leverage entity resolution
for record retrieval, search, and entity resolution.

## Examples

* **Human-in-the-Loop Chat:** [`examples/chat`](https://github.com/tilotech/langchain-tilores/tree/main/examples/chat)

    This example demonstrates how to build a chat application using Chainlit and LangGraph to explore a Tilores instance through natural language. It guides users through search functionality and explains the search results.

* **Basic Usage:** [`examples/basic`](https://github.com/tilotech/langchain-tilores/tree/main/examples/basic)

    This example shows how to use tools with an LLM model in a basic setup.

## Usage

```python
from tilores import TiloresAPI
from langchain_tilores import TiloresTools
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage

# Initialize the Tilores API.
tilores = TiloresAPI.from_environ()
# TiloresTools helps you build typed tools from a specific Tilores instance, typed according to
# the schema of the instance.
tilores_tools = TiloresTools(tilores)

# Setup a LLM model for inference bound with a set of tools.
tools = [tilores_tools.search_tool]
tools_dict = {tool.name: tool for tool in tools}
model = ChatOpenAI(temperature=0, streaming=True, model_name="gpt-4o")
model = model.bind_tools(tools)

# The basic loop works like this, that a list of messages is passed to the LLM
messages = [
    HumanMessage("Find me an entity by the first name Emma, surname Schulz, born on 1988-03-12")
]
ai_message = model.invoke(messages)
messages.append(ai_message)

# And for each AiMessage, you must check if it wants to invoke tools.
for tool_call in ai_message.tool_calls:
    # Perform the tool call and append the ToolMessage to the list of messages
    selected_tool = tools_dict[tool_call['name']]
    tool_message = selected_tool.invoke(tool_call)
    messages.append(tool_message)

# Then continue the basic loop by invoking the LLM with the current state, passing the list of messages.
ai_response = model.invoke(messages)
print(ai_response.content)
```

```console
$ cd examples/basic/
$ pip install -r requirements.txt
$ python llm_with_tools.py
I found multiple records for an entity with the first name Emma, surname Schulz, born on 1988-03-12. Here are the details:

1. **Record ID:** cc001001-0006-4000-c000-000000000006
   - **First Name:** Emma
   - **Last Name:** Schulz
   - **Date of Birth:** 1988-03-12

2. **Record ID:** cc001001-0002-4000-c000-000000000002
   - **First Name:** Emma
   - **Last Name:** Schulz
   - **Date of Birth:** 1988-03-12

[... snip ...]

If you need more specific information or further assistance, please let me know!
```

## Provided tools

- [x] `tilores_search`


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "langchain-tilores",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "entity-resolution, tilores, graph-raq, langchain, langchain-tool",
    "author": null,
    "author_email": "Lukas Rieder <lukas@parlant.co>",
    "download_url": "https://files.pythonhosted.org/packages/ee/ff/a1c371a5cda4f3d1f8d81100287768b7fe76c1d63f9d276d79829db41463/langchain_tilores-0.1.3.tar.gz",
    "platform": null,
    "description": "# LangChain Using Tilores\n\nThis repository provides the building blocks for integrating LangChain, LangGraph, and the\nTilores entity resolution system.\n\nDevelopers can use these tools to create powerful systems that leverage entity resolution\nfor record retrieval, search, and entity resolution.\n\n## Examples\n\n* **Human-in-the-Loop Chat:** [`examples/chat`](https://github.com/tilotech/langchain-tilores/tree/main/examples/chat)\n\n    This example demonstrates how to build a chat application using Chainlit and LangGraph to explore a Tilores instance through natural language. It guides users through search functionality and explains the search results.\n\n* **Basic Usage:** [`examples/basic`](https://github.com/tilotech/langchain-tilores/tree/main/examples/basic)\n\n    This example shows how to use tools with an LLM model in a basic setup.\n\n## Usage\n\n```python\nfrom tilores import TiloresAPI\nfrom langchain_tilores import TiloresTools\nfrom langchain_openai import ChatOpenAI\nfrom langchain_core.messages import HumanMessage\n\n# Initialize the Tilores API.\ntilores = TiloresAPI.from_environ()\n# TiloresTools helps you build typed tools from a specific Tilores instance, typed according to\n# the schema of the instance.\ntilores_tools = TiloresTools(tilores)\n\n# Setup a LLM model for inference bound with a set of tools.\ntools = [tilores_tools.search_tool]\ntools_dict = {tool.name: tool for tool in tools}\nmodel = ChatOpenAI(temperature=0, streaming=True, model_name=\"gpt-4o\")\nmodel = model.bind_tools(tools)\n\n# The basic loop works like this, that a list of messages is passed to the LLM\nmessages = [\n    HumanMessage(\"Find me an entity by the first name Emma, surname Schulz, born on 1988-03-12\")\n]\nai_message = model.invoke(messages)\nmessages.append(ai_message)\n\n# And for each AiMessage, you must check if it wants to invoke tools.\nfor tool_call in ai_message.tool_calls:\n    # Perform the tool call and append the ToolMessage to the list of messages\n    selected_tool = tools_dict[tool_call['name']]\n    tool_message = selected_tool.invoke(tool_call)\n    messages.append(tool_message)\n\n# Then continue the basic loop by invoking the LLM with the current state, passing the list of messages.\nai_response = model.invoke(messages)\nprint(ai_response.content)\n```\n\n```console\n$ cd examples/basic/\n$ pip install -r requirements.txt\n$ python llm_with_tools.py\nI found multiple records for an entity with the first name Emma, surname Schulz, born on 1988-03-12. Here are the details:\n\n1. **Record ID:** cc001001-0006-4000-c000-000000000006\n   - **First Name:** Emma\n   - **Last Name:** Schulz\n   - **Date of Birth:** 1988-03-12\n\n2. **Record ID:** cc001001-0002-4000-c000-000000000002\n   - **First Name:** Emma\n   - **Last Name:** Schulz\n   - **Date of Birth:** 1988-03-12\n\n[... snip ...]\n\nIf you need more specific information or further assistance, please let me know!\n```\n\n## Provided tools\n\n- [x] `tilores_search`\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Tilo Tech GmbH  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "This package contains tools to work with Tilores entity resolution database within Langchain.",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/tilotech/langchain-tilores",
        "Issues": "https://github.com/tilotech/langchain-tilores/issues"
    },
    "split_keywords": [
        "entity-resolution",
        " tilores",
        " graph-raq",
        " langchain",
        " langchain-tool"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9ebf82f654322f167ad98bd1e739b0372e24f6d2e22bc7c1283a013bf79b3735",
                "md5": "7ccdcfc50dbac8acf551812d65b46703",
                "sha256": "9a3ff6128690f1858c3546719439d846f3f8b463a3d1e0e2c337448e1a051a02"
            },
            "downloads": -1,
            "filename": "langchain_tilores-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7ccdcfc50dbac8acf551812d65b46703",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5035,
            "upload_time": "2024-09-11T15:22:39",
            "upload_time_iso_8601": "2024-09-11T15:22:39.974972Z",
            "url": "https://files.pythonhosted.org/packages/9e/bf/82f654322f167ad98bd1e739b0372e24f6d2e22bc7c1283a013bf79b3735/langchain_tilores-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eeffa1c371a5cda4f3d1f8d81100287768b7fe76c1d63f9d276d79829db41463",
                "md5": "936b499e730c8d6754c2c4ffe6743cbd",
                "sha256": "ce7761bdcfeadef50b595409db4a6ecc0dcd64440a1c1f2a259f6d16bd76ac0f"
            },
            "downloads": -1,
            "filename": "langchain_tilores-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "936b499e730c8d6754c2c4ffe6743cbd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4166,
            "upload_time": "2024-09-11T15:22:41",
            "upload_time_iso_8601": "2024-09-11T15:22:41.936442Z",
            "url": "https://files.pythonhosted.org/packages/ee/ff/a1c371a5cda4f3d1f8d81100287768b7fe76c1d63f9d276d79829db41463/langchain_tilores-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-11 15:22:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tilotech",
    "github_project": "langchain-tilores",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "langchain-tilores"
}
        
Elapsed time: 0.36320s