File size: 1,064 Bytes
c94c3e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_community.llms import Ollama
import os
import streamlit as st
from dotenv import load_dotenv
load_dotenv()
#os.environ["OPENAI_API_KEY"]=os.getenv("OPENAI_API_KEY", "not found")
#langmith Tracking
os.environ["LANGCHAIN_TRACING_V2"]="true"
os.environ["LANGCHAIN_API_KEY"]=os.getenv("LANGCHAIN_API_KEY", "not found")
#Prompt Template
prompt = ChatPromptTemplate.from_messages(
[
("system", "You are a world class helpful assistant.Please respond to the user."),
("user","Question:{question}")
]
)
#streamlit framework
st.title('LLAMA3 using Langchain :sunglasses:')
st.subheader("Designed by :blue[Kartavya.] How can i assist you:question:")
input_text = st.text_input("")
#OLLAMA LLAma3
llm = Ollama(model="llama3")
output_parser = StrOutputParser()
chain = prompt|llm|output_parser
if st.button("Enter"):
st.write(chain.invoke({"question":input_text}))
|