LangChain Integration 🦜⛓️
Using Honcho with LangChain with drop-in primitives
You can use Honcho to manage user context around LLM frameworks like LangChain. First, import the appropriate packages:
Next let’s instantiate our Honcho client:
Then we can define our chain using the LangChain Expression Language (LCEL):
Honcho returns lists of Message
objects when queried using a built-in method like get_messages()
, so a quick utility function is needed to change the list format to message objects LangChain expects:
This method is importable with the following statement
Now we can structure Honcho calls around our LLM inference:
Here we query messages from a user’s session using Honcho and construct a chat history object to send to the LLM alongside our immediate user input. Once the LLM has responded, we can add that to Honcho!