Spaces:
Sleeping
Sleeping
Eli Wilner
commited on
Commit
·
291b2ba
1
Parent(s):
b34fc24
first commit
Browse files- app.py +40 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Q&A Chatbot
|
2 |
+
|
3 |
+
import warnings
|
4 |
+
warnings.filterwarnings("ignore")
|
5 |
+
|
6 |
+
from langchain.llms import OpenAI
|
7 |
+
from dotenv import load_dotenv
|
8 |
+
|
9 |
+
load_dotenv()
|
10 |
+
import streamlit as st
|
11 |
+
import os
|
12 |
+
from typing import Any
|
13 |
+
|
14 |
+
|
15 |
+
## Function to load OpenAI model and get respones
|
16 |
+
|
17 |
+
def get_openai_response(question: Any):
|
18 |
+
llm = OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"),
|
19 |
+
model_name="gpt-3.5-turbo-instruct",
|
20 |
+
temperature=.6)
|
21 |
+
response = llm(question)
|
22 |
+
|
23 |
+
return response
|
24 |
+
|
25 |
+
|
26 |
+
## Intialize streamlit app
|
27 |
+
|
28 |
+
st.set_page_config(page_title="Q&A Demo")
|
29 |
+
st.header("Langchain Application")
|
30 |
+
|
31 |
+
|
32 |
+
input = st.text_input("Input: ", key="input")
|
33 |
+
response = get_openai_response(input)
|
34 |
+
|
35 |
+
submit = st.button("Ask the question")
|
36 |
+
|
37 |
+
## If asked button is clicked
|
38 |
+
if submit:
|
39 |
+
st.subheader("The response is:")
|
40 |
+
st.write(response)
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain
|
2 |
+
openai
|
3 |
+
huggingface_hub
|
4 |
+
python-dotenv
|
5 |
+
streamlit
|