Posts

Showing posts with the label ChatBot

Simple ChatBot using Open AI and LangChain, LangSmith

Image
This post is about simple chatbot one liner for understanding the flow. How the API coommunicate, how to structure the code, and what to call.  Open AI api and LangChain and LangSmith have been used here. Please note, you need to install LangChain, Open AI related chat model interfaces -  pip install -qU "langchain[openai]" Next step is to create one API key in LangSmith, and put your API keys in the below code. Replace your keys in the respective position: ( YOUR SANGSMITH KEY GOES HERE) and ( YOUR OPENAI KEY GOES HERE ). This is simple chat application which read your name and understand your first name. The reading and understanding is made through LangChain schema. Here the code goes... import getpass import os from langchain_openai import ChatOpenAI from langchain.schema import HumanMessage from langchain_core.messages import AIMessage os.environ[ "LANGSMITH_TRACING" ] = "true" os.environ[ "LANGSMITH_API_KEY" ] = "YOUR SANGSMITH...