Custom langchain Agent & Tools with memory. Turn any Python function into langchain tool with Gpt 3

Опубликовано: 21 Октябрь 2024
на канале: echohive
11,060
241

We will build a web app with Streamlit UI which features 4 Python functions as custom Langchain tools. Our agent will also have a short term conversational memory.

Code is available for download at Patreon: https://www.patreon.com/posts/custom-...

Try the free GPT-4 Auto Coder app : https://gpt4autocoder.streamlit.app/

UPDATE: One of our discord members found a bug in this code. Agent's meomry was resetting with each streamlit interactions. We fix this by adding the agent's memory innitialization to a session state as such: (rest of the code remains the same:
'''if "agent_memory" not in st.session_state:
st.session_state["agent_memory"] = ConversationBufferMemory(memory_key="chat_history") # You can use other memory types as well!

llm=OpenAI(temperature=0, verbose=True)
agent_chain = initialize_agent(tools, llm, agent="conversational-react-description", memory=st.session_state["agent_memory"], verbose=True) # verbose=True to see the agent's thought process'''



Join echohive discord:   / discord  

Langchain memory types:    • Langchain Gpt 3 Chat bot with memory....  
Gpt-3 searches the internet: GPT 3 searches the internet with langchain. how to use langchain tutorial: Agents & Tools explained
   • GPT 3 searches the internet with lang...  
Langchain documentation: https://langchain.readthedocs.io/en/l...
Streamlit documentation: https://docs.streamlit.io/
OpenAI documentation: https://platform.openai.com/docs/intr...

Timeline:

00:00 intro and Demo
02:29 Code review
07:42 Streamlit UI
10:50 Starting the app

#langchain #langchaintutorial #chatbotdevelopment #gpt3 #gpt #openai #streamlit #streamlittutorial