sanjivinsmoke121
commited on
Commit
•
674bcce
1
Parent(s):
f99882a
Upload 2 files
Browse files- app.py +30 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain.llms import OpenAI
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
import streamlit as st
|
4 |
+
import os
|
5 |
+
|
6 |
+
# Simple Chatbot
|
7 |
+
|
8 |
+
load_dotenv() # take environment
|
9 |
+
|
10 |
+
# Function to load openai model and get reponse
|
11 |
+
def get_response_ai(question):
|
12 |
+
llm = OpenAI(model_name = "gpt-3.5-turbo",temperature = 0.75)
|
13 |
+
response = llm(question)
|
14 |
+
return response
|
15 |
+
|
16 |
+
# initialize our streamlit app
|
17 |
+
st.set_page_config(page_title = 'Q&A Demo')
|
18 |
+
st.header('Langchain Application')
|
19 |
+
|
20 |
+
question = st.text_input("Input :",key = "input")
|
21 |
+
response = get_response_ai(question)
|
22 |
+
|
23 |
+
submit = st.button('Ask a question')
|
24 |
+
|
25 |
+
|
26 |
+
if submit:
|
27 |
+
st.subheader("The Response is ")
|
28 |
+
st.write(response)
|
29 |
+
|
30 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain
|
2 |
+
openai
|
3 |
+
huggingface-hub
|
4 |
+
python-dotenv
|
5 |
+
streamlit
|