ghrasko commited on
Commit
2efcfd8
·
1 Parent(s): d267725

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Q&A chatbot
2
+ # Run as: streamlit run app.py
3
+
4
+ from langchain.llms import OpenAI
5
+ import streamlit as st
6
+
7
+ import os
8
+ from dotenv import load_dotenv
9
+
10
+ load_dotenv()
11
+
12
+ # Function to load OpenAI model and get responses
13
+ def get_openai_response(question):
14
+ llm = OpenAI(openai_api_key=os.getenv("OPENAI_API_KEY"), model="gpt-3.5-turbo-instruct", temperature=0.0)
15
+ response = llm(question)
16
+ return response
17
+
18
+ # initialize Streamlit app
19
+ st.set_page_config(page_title="Q&A Demo")
20
+ st.header("Langchain Application")
21
+
22
+ input = st.text_input("Input: ", key="input")
23
+ response = get_openai_response(input)
24
+
25
+ submit = st.button("Ask a question")
26
+ if submit:
27
+ st.subheader("Response: ")
28
+ st.write(response)