langchain
langchain copied to clipboard
DOC: Add tooling for Tilores entity resolution SDK
URL
https://python.langchain.com/v0.2/docs/integrations/tools/
Checklist
- [X] I added a very descriptive title to this issue.
- [X] I included a link to the documentation page I am referring to (if applicable).
Issue with current documentation:
- Page: https://python.langchain.com/v0.2/docs/integrations/tools/
- Suggested New Page: https://python.langchain.com/v0.2/docs/integrations/tools/tilores/
Can we get the Tilores LangChain integration listed on the LangChain WIKI? This week we release the first version of the Python packages, and they are ready to be used. Tilores is an entity resolution system that works with structured data and can perfectly augment GenAI in its context. Tilores supports dynamic schemas, and can therefore be used to resolve any types of records to single entities. Hence why we published a LangChain tool, so that structured requests can be made to any Tilores schema.
The resources we would like to link to are:
- Github: https://github.com/tilotech/langchain-tilores
- PyPi: https://pypi.org/project/langchain-tilores
I have also added an idea/content to write on the "Tilores SDK" page for the Tilores tooling. Happy to receive feedback on my suggestion and clarify any questions you might have. If this is the wrong place to suggest an addition to your WIKI, please let me know.
Kind regards,
Lukas
Idea or request for content:
Tilores SDK
This tool 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
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
This example shows how to use tools with an LLM model in a basic setup.
Installation
$ pip install langchain-tilores
Sources to langchain-tilores
are available on Github.
Example usage
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)