Si-borg commited on
Commit
d81ccec
1 Parent(s): b1b788d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Q&A Chatbot
2
+ from langchain.llms import OpenAI
3
+
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv() # take environment variables from .env
7
+
8
+ import streamlit as st
9
+ import os
10
+
11
+ ## Function to load OpenAI model and get response
12
+
13
+ def get_openai_response(question):
14
+ llm=OpenAI(openai_api_key=os.getenv("OPENAI_API_KEY"),model_name="gpt-4",temperature=0.6)
15
+ response=llm(question)
16
+ return response
17
+
18
+ ## Initialize Streamlit app
19
+
20
+ st.set_page_config(page_title="Q&A Demo")
21
+
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 Question")
28
+
29
+ ## If ask button is clicked
30
+
31
+ if submit:
32
+ st.subheader("the response is")
33
+ st.write(response)
34
+
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ langchain
2
+ openai
3
+ huggingface_hub
4
+ python-dotenv
5
+ streamlit