Spaces:
Sleeping
Sleeping
Anshuman Dangwal
commited on
Commit
·
690be0f
1
Parent(s):
44311dd
Upload 2 files
Browse files- app.py +21 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain.llms import OpenAI
|
| 2 |
+
# from dotenv import load_dotenv
|
| 3 |
+
# load_dotenv() # takes environment variables
|
| 4 |
+
import streamlit as st
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
def get_openai_response(question):
|
| 8 |
+
llm=OpenAI(openai_api_key=os.getenv('OPENAI_API_KEY'),temperature=0.6)
|
| 9 |
+
response = llm(question)
|
| 10 |
+
return response
|
| 11 |
+
|
| 12 |
+
st.set_page_config(page_title='Simple Q&A bot')
|
| 13 |
+
st.header('Langchain Application')
|
| 14 |
+
|
| 15 |
+
input = st.text_input('Input: ', key='input')
|
| 16 |
+
response = get_openai_response(input)
|
| 17 |
+
submit= st.button('Ask')
|
| 18 |
+
|
| 19 |
+
if submit:
|
| 20 |
+
st.subheader('Response:')
|
| 21 |
+
st.write(response)
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
openai
|
| 2 |
+
python-dotenv
|
| 3 |
+
langchain
|
| 4 |
+
huggingface_hub
|
| 5 |
+
streamlit
|