pynapavani commited on
Commit
32ed298
·
verified ·
1 Parent(s): 5a1a56d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_core.prompts import ChatPromptTemplate
2
+ from langchain_core.output_parsers import StrOutputParser
3
+ from langchain_community.llms import Ollama
4
+ import streamlit as st
5
+ import os
6
+ from dotenv import load_dotenv
7
+
8
+ load_dotenv()
9
+
10
+ os.environ["LANGCHAIN_TRACING_V2"]="true"
11
+ os.environ["LANGCHAIN_API_KEY"]=os.getenv("LANGCHAIN_API_KEY")
12
+
13
+ ## Prompt Template
14
+
15
+ prompt=ChatPromptTemplate.from_messages(
16
+ [
17
+ ("system","You are a helpful assistant. Please response to the user queries"),
18
+ ("user","Question:{question}")
19
+ ]
20
+ )
21
+ ## streamlit framework
22
+
23
+ st.title('Langchain chatbot app With LLAMA2 API')
24
+ input_text=st.text_input("Search the topic u want")
25
+
26
+ # ollama LLAma2 LLm
27
+ llm=Ollama(model="llama2")
28
+ output_parser=StrOutputParser()
29
+ chain=prompt|llm|output_parser
30
+
31
+ if input_text:
32
+ st.write(chain.invoke({"question":input_text}))
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ langchain
2
+ langchain_community
3
+ streamlit
4
+ python-dotenv