RSK1987 commited on
Commit
d2079d5
·
verified ·
1 Parent(s): c527107

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +57 -0
  2. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # from langchain.llms import OpenAI
2
+ # from dotenv import load_dotenv
3
+ # load_dotenv()
4
+
5
+ # import streamlit as st
6
+ # import os
7
+
8
+ # def get_openai_response(question):
9
+ # llm=OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"),model_name="gpt-3.5-turbo",temperature=0.5)
10
+ # response=llm(question)
11
+ # return response
12
+
13
+
14
+ # ## initialize streamlit app
15
+
16
+ # st.set_page_config(page_title="Q&A Demo")
17
+ # st.header("Langchain Application")
18
+
19
+ # input =st.text_input("Input: ",key="input")
20
+ # response = get_openai_response(input)
21
+
22
+ # submit=st.button("Ask the question")
23
+
24
+ # if submit:
25
+ # st.subheader("The response is")
26
+ # st.write(response)
27
+
28
+ from langchain.llms import OpenAI
29
+ from dotenv import load_dotenv
30
+ import streamlit as st
31
+ import os
32
+ import openai
33
+
34
+ load_dotenv()
35
+
36
+ openai.api_key = os.getenv("OPENAI_API_KEY")
37
+
38
+ def get_openai_response(question):
39
+ response = openai.ChatCompletion.create(
40
+ model="gpt-3.5-turbo",
41
+ messages=[
42
+ {"role": "user", "content": question}
43
+ ]
44
+ )
45
+ return response.choices[0].message['content']
46
+
47
+ ## initialize streamlit app
48
+
49
+ st.set_page_config(page_title="Q&A Demo")
50
+ st.header("Langchain Application")
51
+
52
+ input_text = st.text_input("Input: ", key="input")
53
+
54
+ if st.button("Ask the question"):
55
+ response = get_openai_response(input_text)
56
+ st.subheader("The response is")
57
+ st.write(response)
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ langchain
2
+ langchain-community
3
+ openai
4
+ huggingface_hub
5
+ python-dotenv
6
+ streamlit