Spaces:
Sleeping
Sleeping
cookiemonster69
commited on
Commit
•
26a1c7b
1
Parent(s):
998b252
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,25 @@
|
|
1 |
-
#Hello! It seems like you want to import the Streamlit library in Python. Streamlit is a powerful open-source framework used for building web applications with interactive data visualizations and machine learning models. To import Streamlit, you'll need to ensure that you have it installed in your Python environment.
|
2 |
-
#Once you have Streamlit installed, you can import it into your Python script using the import statement,
|
3 |
|
4 |
import streamlit as st
|
5 |
|
6 |
-
#As Langchain team has been working aggresively on improving the tool, we can see a lot of changes happening every weeek,
|
7 |
-
#As a part of it, the below import has been depreciated
|
8 |
-
#from langchain.llms import OpenAI
|
9 |
|
10 |
-
#New import from langchain, which replaces the above
|
11 |
from langchain_openai import OpenAI
|
12 |
|
13 |
-
#When deployed on huggingface spaces, this values has to be passed using Variables & Secrets setting, as shown in the video :)
|
14 |
-
#import os
|
15 |
-
#os.environ["OPENAI_API_KEY"] = "sk-werwerwerrtertertwkFJwtwetwteWSig4ZY9AT"
|
16 |
|
17 |
-
|
|
|
18 |
def load_answer(question):
|
19 |
-
|
20 |
llm = OpenAI(model_name="gpt-3.5-turbo-instruct",temperature=0)
|
21 |
|
22 |
-
|
23 |
answer=llm.invoke(question)
|
24 |
return answer
|
25 |
|
26 |
|
27 |
-
#App UI starts here
|
28 |
st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
|
29 |
st.header("LangChain Demo")
|
30 |
|
31 |
-
|
32 |
def get_text():
|
33 |
input_text = st.text_input("You: ", key="input")
|
34 |
return input_text
|
@@ -39,7 +30,7 @@ response = load_answer(user_input)
|
|
39 |
|
40 |
submit = st.button('Generate')
|
41 |
|
42 |
-
|
43 |
if submit:
|
44 |
|
45 |
st.subheader("Answer:")
|
|
|
|
|
|
|
1 |
|
2 |
import streamlit as st
|
3 |
|
|
|
|
|
|
|
4 |
|
|
|
5 |
from langchain_openai import OpenAI
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
+
|
9 |
+
|
10 |
def load_answer(question):
|
11 |
+
|
12 |
llm = OpenAI(model_name="gpt-3.5-turbo-instruct",temperature=0)
|
13 |
|
14 |
+
|
15 |
answer=llm.invoke(question)
|
16 |
return answer
|
17 |
|
18 |
|
|
|
19 |
st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
|
20 |
st.header("LangChain Demo")
|
21 |
|
22 |
+
|
23 |
def get_text():
|
24 |
input_text = st.text_input("You: ", key="input")
|
25 |
return input_text
|
|
|
30 |
|
31 |
submit = st.button('Generate')
|
32 |
|
33 |
+
|
34 |
if submit:
|
35 |
|
36 |
st.subheader("Answer:")
|