Narsingh-Maurya commited on
Commit
29532c6
1 Parent(s): 17edbd5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.llms import OpenAI
2
+ from dotenv import load_dotenv
3
+ import streamlit as st
4
+ import os
5
+
6
+ load_dotenv() # take environment variable from .env
7
+
8
+
9
+ ## Function to load openAI model and get response
10
+ def get_openai_response(question):
11
+ llm = OpenAI(openai_api_key = os.getenv('OPEN_API_KEY'), model_name = "text-davinci-003", temperature = 0.6)
12
+ response = llm(question)
13
+ return response
14
+
15
+
16
+ st.set_page_config(page_title = "QnA_Project Using OpenAI")
17
+ st.header("Langchain Application using OpenAI")
18
+
19
+ input = st.text_input("Input: ", key = "input")
20
+ response = get_openai_response(input)
21
+
22
+ submit = st.button("Ask the Question")
23
+
24
+ # if ask button is clicked
25
+ if submit:
26
+ st.subheader("The response is ")
27
+ st.write(response)
28
+