drkareemkamal commited on
Commit
d8f7d75
·
verified ·
1 Parent(s): ad10eee

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # create a simple chatbot using streamlit
2
+
3
+ #from langchain.llms import OpenAI
4
+ from langchain_openai import OpenAI
5
+ from dotenv import load_dotenv
6
+
7
+ load_dotenv()
8
+
9
+ import os
10
+ import streamlit as st
11
+
12
+ ## create a function to load OpenAI model and get response
13
+
14
+ def get_openai_response(question):
15
+
16
+ llm = OpenAI(openai_api_key = os.getenv('OPEN_API_KEY'),model_name = 'gpt-3.5-turbo-instruct',
17
+ temperature = 0.5)
18
+ response = llm.invoke(question)
19
+ return response
20
+
21
+ ## initialize our streamlit app
22
+
23
+ st.set_page_config(page_title='Q&A Demo')
24
+ st.header('Langchain Application')
25
+
26
+ input = st.text_input('Input : ',key="input")
27
+ response = get_openai_response(input)
28
+
29
+ submit = st.button('Ask the question')
30
+
31
+ ## if ask button is clicked
32
+ if submit:
33
+ st.subheader('the response is')
34
+ st.write(response)