kartavya17 commited on
Commit
c94c3e2
1 Parent(s): 40365dc

Create app.py

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