rathodj080898 commited on
Commit
a7a35ab
·
verified ·
1 Parent(s): 63a6d1a

Uploaded app.py which is a basic application

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.llms import OpenAI
2
+ from dotenv import load_dotenv
3
+ load_dotenv()
4
+ import streamlit as st
5
+ import os
6
+
7
+ opanai_api_key = os.getenv("OPENAI_API_KEY")
8
+
9
+ # Function to load openai model and get response
10
+ def get_openai_response(question):
11
+ llm = OpenAI(
12
+ openai_api_key = os.getenv["OPENAI_API_KAY"],
13
+ model_name = "text-davinci-003",
14
+ temperature = 0.2
15
+ )
16
+ response = llm(question)
17
+ return response
18
+
19
+ #Initialize streamlit
20
+
21
+ st.set_page_config(page_title="Q&A DEMO")
22
+ st.header("Langchain Application")
23
+
24
+ input = st.text_input("Input : ", key="input")
25
+ response = get_openai_response(input)
26
+
27
+ submit = st.button("Ask the question")
28
+
29
+ if submit:
30
+ st.subheader("The response is")
31
+ st.write(response)
32
+