rajsecrets0 commited on
Commit
d4e6017
·
verified ·
1 Parent(s): d553e19

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # q & a chatbot
2
+ from langchain.llms import OpenAI
3
+
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv() # take environment varibales from .env
7
+
8
+ import streamlit as st
9
+ import os
10
+
11
+ # lets make a function for calling the llm
12
+ def get_openai_response(question):
13
+ llm=OpenAI(openai_api_key = OPENAI_API_KEY, model_name = "text-davinci-003", temperature = 0.6)
14
+ response = llm(question)
15
+ return response
16
+
17
+ # Streamlit app
18
+
19
+
20
+ st.header("Langchain Application")
21
+
22
+ input = st.text_input("input : ", key="input")
23
+ get_openai_response(input)
24
+
25
+ submit = st.button("Ask the question")
26
+
27
+ # if ask button is clicked
28
+
29
+ if submit:
30
+ st.subheader("the response is")
31
+ st.write(response)