Package: txtchat
Retrieval Augmented Generation (RAG) powered searchtxtchat builds retrieval augmented generation (RAG) and language model powered search applications.The advent of large language models (LLMs) has pushed a reimagination of search. LLM-powered search can do more. Instead of just bringing back results, search can now extract, summarize, translate and transform content into answers.txtchat adds a set of intelligent agents that are available to integrate with messaging platforms. These agents or personas are associated with an automated account and respond to messages with AI-powered responses. Workflows can use large language models (LLMs), small models or both.txtchat is built with Python 3.8+ andtxtai.InstallationThe easiest way to install is via pip and PyPIpip install txtchatYou can also install txtchat directly from GitHub. Using a Python Virtual Environment is recommended.pip install git+https://github.com/neuml/txtchatPython 3.8+ is supportedSeethis linkto help resolve environment-specific install issues.Messaging platformstxtchat is designed to and will support a number of messaging platforms. Currently,Rocket.Chatis the only supported platform given it's ability to be installed in a local environment along with being MIT-licensed. The easiest way to start a local Rocket.Chat instance is with Docker Compose. See theseinstructionsfor more.Extending txtchat to additional platforms only needs a new Agent subclass for that platform.ArchitectureA persona is a combination of a chat agent and workflow that determines the type of responses. Each agent is tied to an account in the messaging platform. Persona workflows are messaging-platform agnostic. Thetxtchat-personarepository has a list of standard persona workflows.Wikitalk: Chat with WikipediaSummary: Reads input URLs and summarizes the textMr. French: Translates input text into FrenchSee theexamplesdirectory for additional persona and workflow configurations.The following command shows how to start a txtchat persona.# Set to server URL, this is default when running local
export AGENT_URL=ws://localhost:3000/websocket
export AGENT_USERNAME=<Rocket Chat User>
export AGENT_PASSWORD=<Rocket Chat User Password>

# YAML is loaded from Hugging Face Hub, can also reference local path
python -m txtchat.agent wikitalk.ymlWant to add a new persona? Simply create a txtai workflow and save it to a YAML file.ExamplesThe following is alist of YouTube videosthat shows how txtchat works. These videos run a series of queries with the Wikitalk persona. Wikitalk is a combination of aWikipedia embeddings indexand a LLM prompt to answer questions.Every answer shows an associated reference with where the data came from. Wikitalk will say "I don't have data on that" when it doesn't have an answer.HistoryConversation with Wikitalk about history.SportsTalk about sports.CultureArts and culture questions.ScienceLet's quiz Wikitalk on science.SummaryNot all workflows need a LLM. There are plenty of great small models available to perform a specific task. The Summary persona simply reads the input URL and summarizes the text.Mr. FrenchLike the summary persona, Mr. French is a simple persona that translates input text to French.Connect your own dataWant to connect txtchat to your own data? All that you need to do is create a txtai workflow. Let's run through an example of building a Hacker News indexing workflow and a txtchat persona.First, we'll define the indexing workflow and build the index. This is done with a workflow for convenience. Alternatively it could be a Python program that builds an embeddings index from your dataset. There are over50 example notebookscovering a wide range of ways to get data into txtai. There are also example workflows that can be downloaded from in thisHugging Face Space.path:/tmp/hnembeddings:path:sentence-transformers/all-MiniLM-L6-v2content:truetabular:idcolumn:urltextcolumns:-titleworkflow:index:tasks:-batch:falseextract:-hitsmethod:getparams:tags:nulltask:serviceurl:https://hn.algolia.com/api/v1/search?hitsPerPage=50-action:tabular-action:indexwritable:trueThis workflow parses the Hacker News front page feed and builds an embeddings index at the path/tmp/hn.Run the workflow with the following.fromtxtai.appimportApplicationapp=Application("index.yml")list(app.workflow("index",["front_page"]))Now we'll define the chat workflow and run it as an agent.path:/tmp/hnwritable:falseextractor:path:google/flan-t5-xloutput:flattenworkflow:search:tasks:-task:txtchat.task.Questionaction:extractorpython -m txtchat.agent query.ymlLet's talk to Hacker News!As you can see, Hacker News is a highly opinionated data source!Getting answers is nice but being able to have answers with where they came from is nicer. Let's build a workflow that adds a reference link to each answer.path:/tmp/hnwritable:falseextractor:path:google/flan-t5-xloutput:referenceworkflow:search:tasks:-task:txtchat.task.Questionaction:extractor-task:txtchat.task.AnswerFurther ReadingIntroducing txtchat — Retrieval Augmented Generation (RAG) powered search