captain-awesome
commited on
Commit
•
81a4020
1
Parent(s):
b5fe45f
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,9 @@ from langchain_openai import OpenAIEmbeddings, ChatOpenAI
|
|
7 |
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
8 |
from langchain.chains import create_history_aware_retriever, create_retrieval_chain
|
9 |
from langchain.chains.combine_documents import create_stuff_documents_chain
|
|
|
10 |
|
|
|
11 |
|
12 |
def get_response(user_input):
|
13 |
return "I dont know"
|
@@ -42,9 +44,9 @@ def get_context_retriever_chain(vector_store):
|
|
42 |
return retriever_chain
|
43 |
|
44 |
|
45 |
-
def get_conversational_rag_chain(retriever_chain
|
46 |
|
47 |
-
llm = ChatOpenAI(
|
48 |
|
49 |
prompt = ChatPromptTemplate.from_messages([
|
50 |
("system", "Answer the user's questions based on the below context:\n\n{context}"),
|
@@ -80,10 +82,10 @@ st.title("Chat with Websites")
|
|
80 |
with st.sidebar:
|
81 |
st.header("Settings")
|
82 |
website_url = st.text_input("Website URL")
|
83 |
-
openai_apikey = st.text_input("Enter your OpenAI API key")
|
84 |
|
85 |
-
if (website_url is None or website_url == "")
|
86 |
-
st.info("Please ensure if website URL
|
87 |
|
88 |
|
89 |
else:
|
@@ -100,7 +102,7 @@ else:
|
|
100 |
#user_input
|
101 |
user_query = st.chat_input("Type your message here...")
|
102 |
if user_query is not None and user_query !="":
|
103 |
-
response = get_response(user_query
|
104 |
st.session_state.chat_history.append(HumanMessage(content=user_query))
|
105 |
st.session_state.chat_history.append(AIMessage(content=response))
|
106 |
|
|
|
7 |
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
8 |
from langchain.chains import create_history_aware_retriever, create_retrieval_chain
|
9 |
from langchain.chains.combine_documents import create_stuff_documents_chain
|
10 |
+
from dotenv import load_dotenv
|
11 |
|
12 |
+
load_dotenv()
|
13 |
|
14 |
def get_response(user_input):
|
15 |
return "I dont know"
|
|
|
44 |
return retriever_chain
|
45 |
|
46 |
|
47 |
+
def get_conversational_rag_chain(retriever_chain):
|
48 |
|
49 |
+
llm = ChatOpenAI()
|
50 |
|
51 |
prompt = ChatPromptTemplate.from_messages([
|
52 |
("system", "Answer the user's questions based on the below context:\n\n{context}"),
|
|
|
82 |
with st.sidebar:
|
83 |
st.header("Settings")
|
84 |
website_url = st.text_input("Website URL")
|
85 |
+
# openai_apikey = st.text_input("Enter your OpenAI API key")
|
86 |
|
87 |
+
if (website_url is None or website_url == ""):
|
88 |
+
st.info("Please ensure if website URL is entered")
|
89 |
|
90 |
|
91 |
else:
|
|
|
102 |
#user_input
|
103 |
user_query = st.chat_input("Type your message here...")
|
104 |
if user_query is not None and user_query !="":
|
105 |
+
response = get_response(user_query)
|
106 |
st.session_state.chat_history.append(HumanMessage(content=user_query))
|
107 |
st.session_state.chat_history.append(AIMessage(content=response))
|
108 |
|