Brahmadev619 commited on
Commit
57f8aa8
·
verified ·
1 Parent(s): f729a37

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.llms import OpenAI
2
+ from dotenv import load_dotenv
3
+ import streamlit as st
4
+ import os
5
+ load_dotenv() # take environment variable from .env
6
+
7
+ # function to load OpenAI model and response
8
+
9
+ def get_openai_response(question:str):
10
+ llm = OpenAI(temperature=0.6,openai_api_key = os.getenv('OPENAI_API_KEY'),model = "gpt-3.5-turbo-instruct") # initilizing llm model
11
+ response = llm(question)
12
+ return response
13
+
14
+
15
+ # initize streamlit
16
+
17
+ st.set_page_config(page_title="Q&A Demo")
18
+ st.header("My 1st Langchain Application")
19
+
20
+ input = st.text_input("Input:", key="input")
21
+ response = get_openai_response(input)
22
+
23
+ submit = st.button("Ask the question")
24
+
25
+ if submit:
26
+ st.subheader("response is :")
27
+ st.write(response)