Spaces:
Runtime error
Runtime error
Commit
·
3055acb
1
Parent(s):
f8efad1
Upload 2 files
Browse files- app.py +28 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain.llms import OpenAI
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
import streamlit as st
|
| 4 |
+
from properties import *
|
| 5 |
+
import os
|
| 6 |
+
load_dotenv() # get the environment variable from .env
|
| 7 |
+
|
| 8 |
+
def get_openai_response(question):
|
| 9 |
+
llm = OpenAI(openai_api_key=OPEN_API_KEY,model_name = "text-davinci-003", temperature = 0.5)
|
| 10 |
+
response = llm(question)
|
| 11 |
+
return response
|
| 12 |
+
#streamlit app
|
| 13 |
+
|
| 14 |
+
st.set_page_config(page_title="Q&A Demo")
|
| 15 |
+
|
| 16 |
+
st.header("Langchain Application")
|
| 17 |
+
|
| 18 |
+
input = st.text_input("Input: ",key="input")
|
| 19 |
+
response = get_openai_response(input)
|
| 20 |
+
|
| 21 |
+
submit = st.button('Generate')
|
| 22 |
+
|
| 23 |
+
#if Generate button is clicked
|
| 24 |
+
|
| 25 |
+
if submit:
|
| 26 |
+
st.subheader("The response is:")
|
| 27 |
+
st.write(response)
|
| 28 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
langchain
|
| 2 |
+
openai
|
| 3 |
+
huggingface_hub
|
| 4 |
+
python-dotenv
|
| 5 |
+
streamlit
|