Shankarm08 commited on
Commit
52d675e
·
verified ·
1 Parent(s): eba567e

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -34
app.py DELETED
@@ -1,34 +0,0 @@
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
- from langchain.chat_models import ChatOpenAI
6
- from langchain.schema import HumanMessage # Used to pass a message from the user
7
-
8
- # Function to return the response
9
- def load_answer(question):
10
- llm = ChatOpenAI(model_name="gpt-4", temperature=0)
11
-
12
- # The input to the model must be a list of messages, specifically a HumanMessage.
13
- answer = llm([HumanMessage(content=question)])
14
- return answer.content # Extract the content of the response
15
-
16
- # App UI starts here
17
- st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
18
- st.header("LangChain Demo")
19
-
20
- # Gets the user input
21
- def get_text():
22
- input_text = st.text_input("You: ", key="input")
23
- return input_text
24
-
25
- user_input = get_text()
26
- submit = st.button('Generate')
27
-
28
- # If generate button is clicked
29
- if submit and user_input:
30
- st.subheader("Answer:")
31
- response = load_answer(user_input) # Generate the response
32
- st.write(response)
33
- elif submit and not user_input:
34
- st.warning("Please enter a question.")