Spaces:
Sleeping
Sleeping
GeetaKeote
commited on
Commit
•
e8822cc
1
Parent(s):
8424eb8
Upload 2 files
Browse files- app.py +33 -0
- env-sample.txt +1 -0
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain.llms import OpenAI
|
2 |
+
import streamlit as st
|
3 |
+
import os
|
4 |
+
|
5 |
+
#os.environ["OPENAI_API_KEY"]=""
|
6 |
+
|
7 |
+
|
8 |
+
#Function to return the response
|
9 |
+
def load_answer(question):
|
10 |
+
llm=OpenAI(model_name="gpt-3.5-turbo-instruct",temperature=0)
|
11 |
+
answer=llm(question)
|
12 |
+
return answer
|
13 |
+
|
14 |
+
#App UI starts here
|
15 |
+
st.set_page_config(page_title="Langchain Project")
|
16 |
+
st.header("A Simple Langchain Project")
|
17 |
+
|
18 |
+
#Gets the user input
|
19 |
+
def get_text():
|
20 |
+
input_text =st.text_input("Enter Question",key="input")
|
21 |
+
return input_text
|
22 |
+
|
23 |
+
user_input =get_text()
|
24 |
+
response =load_answer(user_input)
|
25 |
+
|
26 |
+
submit=st.button('Generate')
|
27 |
+
|
28 |
+
#If generate button is clicked
|
29 |
+
if submit:
|
30 |
+
|
31 |
+
st.subheader("Answer:")
|
32 |
+
|
33 |
+
st.write(response)
|
env-sample.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
OPENAI_API_KEY=""
|