langcorn icon indicating copy to clipboard operation
langcorn copied to clipboard

langchain Agents

Open zlapp opened this issue 1 year ago • 7 comments

Thanks for the great repository. Does langcorn support langchain agents?

zlapp avatar Jun 20 '23 10:06 zlapp

I tried to use an Agent. Initially I got an error due to input_key missing. But I then modified the api file with input_keys. It worked, but I don't know how memory is handled, because the API has a memory input as well

nb-programmer avatar Jun 29 '23 05:06 nb-programmer

Thx for the feedback @zlapp ! I just added and tested an example agent https://github.com/msoedov/langcorn/blob/main/examples/ex7_agent.py. It works

msoedov avatar Jul 12 '23 11:07 msoedov

I tried to use an Agent. Initially I got an error due to input_key missing. But I then modified the api file with input_keys. It worked, but I don't know how memory is handled, because the API has a memory input as well

what modifications have you made in api file?

knitish619 avatar Aug 18 '23 10:08 knitish619

I tried to use an Agent. Initially I got an error due to input_key missing. But I then modified the api file with input_keys. It worked, but I don't know how memory is handled, because the API has a memory input as well

what modifications have you made in api file?

It was a while ago and just a quick workaround, but this is what I had changed (in api.py of the package).

image

nb-programmer avatar Aug 18 '23 12:08 nb-programmer

how did you handle memory ?

knitish619 avatar Aug 19 '23 05:08 knitish619

You can store memory on the client side and pass it every time with the request. The updated memory state will be returned from the response.

msoedov avatar Aug 21 '23 14:08 msoedov

Just as an FYI, it is possible to add chat history memory in the chain that will store in a DB itself, without passing the burden to client https://python.langchain.com/docs/modules/memory/agent_with_memory_in_db

You need to pass the session id to the xyzChatMessageHistory class instantiation.

message_history = RedisChatMessageHistory(
    url="redis://localhost:6379/0", ttl=600, session_id="my-session"
)

memory = ConversationBufferMemory(
    memory_key="chat_history", chat_memory=message_history
)

nb-programmer avatar Aug 21 '23 15:08 nb-programmer