Spaces:
Sleeping
Sleeping
Saliltrehan7
commited on
Commit
•
473cd8a
1
Parent(s):
015d316
Upload 2 files
Browse files- app.py +38 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Q&A Chatbot using LLMs
|
2 |
+
|
3 |
+
from langchain.llms import OpenAI
|
4 |
+
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
|
7 |
+
load_dotenv() #Fetching the environment variable from .env
|
8 |
+
|
9 |
+
import streamlit as st
|
10 |
+
import os
|
11 |
+
|
12 |
+
# Function to load OpenAI model and get response
|
13 |
+
|
14 |
+
def get_openai_response(question):
|
15 |
+
llm = OpenAI(model_name='text-davinci-003', temperature=0.5)
|
16 |
+
response = llm(question)
|
17 |
+
|
18 |
+
return response
|
19 |
+
|
20 |
+
# Initializing Streamlit App
|
21 |
+
|
22 |
+
st.set_page_config(page_title="Q&A Demo")
|
23 |
+
|
24 |
+
st.header("Langchain Application")
|
25 |
+
|
26 |
+
input = st.text_input("Input: ", key="input")
|
27 |
+
|
28 |
+
response = get_openai_response(question=input)
|
29 |
+
|
30 |
+
submit = st.button("Ask the Question")
|
31 |
+
|
32 |
+
# If ask button is clicked
|
33 |
+
|
34 |
+
if submit:
|
35 |
+
st.subheader('The response is')
|
36 |
+
st.write(response)
|
37 |
+
|
38 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain
|
2 |
+
openai
|
3 |
+
ipykernel
|
4 |
+
huggingface_hub
|
5 |
+
python-dotenv
|
6 |
+
streamlit
|