Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import re
|
3 |
import os
|
4 |
-
import bs4
|
5 |
-
from sentence_transformers import SentenceTransformer
|
6 |
-
import torch
|
7 |
-
from langchain_groq import ChatGroq # Import from correct package
|
8 |
-
from langchain.document_loaders import WebBaseLoader
|
9 |
-
from langchain.prompts import RunnablePassthrough
|
10 |
-
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
11 |
-
from langchain.vectorstores import Chroma
|
12 |
-
from langchain.output_parsers import StrOutputParser
|
13 |
|
14 |
# Sidebar Style with Multicolored Background
|
15 |
sidebar_bg_style = """
|
@@ -56,8 +47,8 @@ if not use_preprovided_keys:
|
|
56 |
api_key_1 = st.sidebar.text_input("Enter LangChain API Key", type="password", placeholder="Enter your LangChain API Key", help="Please enter a valid LangChain API key here")
|
57 |
api_key_2 = st.sidebar.text_input("Enter Groq API Key", type="password", placeholder="Enter your Groq API Key", help="Please enter your Groq API key here")
|
58 |
else:
|
59 |
-
api_key_1 = "your-preprovided-langchain-api-key"
|
60 |
-
api_key_2 = "your-preprovided-groq-api-key"
|
61 |
st.sidebar.markdown('<p style="color:blue; font-weight:bold;">Using pre-provided API keys</p>', unsafe_allow_html=True)
|
62 |
|
63 |
# Submit button for API keys with a success/warning message
|
@@ -90,11 +81,7 @@ if 'chat_history' not in st.session_state:
|
|
90 |
|
91 |
# Submit button for chat
|
92 |
if st.button("Submit Query"):
|
93 |
-
if
|
94 |
-
st.markdown('<p style="color:red; font-weight:bold;">Please enter a query before submitting</p>', unsafe_allow_html=True)
|
95 |
-
elif not url_input:
|
96 |
-
st.markdown('<p style="color:red; font-weight:bold;">Please enter a valid URL before submitting</p>', unsafe_allow_html=True)
|
97 |
-
else:
|
98 |
# Blog loading logic based on user input URL
|
99 |
loader = WebBaseLoader(
|
100 |
web_paths=(url_input,), # Use the user-input URL
|
@@ -140,7 +127,7 @@ if st.button("Submit Query"):
|
|
140 |
rag_chain = (
|
141 |
{"context": retriever | format_docs, "question": RunnablePassthrough()}
|
142 |
| prompt
|
143 |
-
| ChatGroq(model="llama3-8b-8192") #
|
144 |
| StrOutputParser()
|
145 |
)
|
146 |
|
|
|
1 |
import streamlit as st
|
2 |
import re
|
3 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Sidebar Style with Multicolored Background
|
6 |
sidebar_bg_style = """
|
|
|
47 |
api_key_1 = st.sidebar.text_input("Enter LangChain API Key", type="password", placeholder="Enter your LangChain API Key", help="Please enter a valid LangChain API key here")
|
48 |
api_key_2 = st.sidebar.text_input("Enter Groq API Key", type="password", placeholder="Enter your Groq API Key", help="Please enter your Groq API key here")
|
49 |
else:
|
50 |
+
api_key_1 = "your-preprovided-langchain-api-key" # Replace with your actual pre-provided key
|
51 |
+
api_key_2 = "your-preprovided-groq-api-key" # Replace with your actual pre-provided key
|
52 |
st.sidebar.markdown('<p style="color:blue; font-weight:bold;">Using pre-provided API keys</p>', unsafe_allow_html=True)
|
53 |
|
54 |
# Submit button for API keys with a success/warning message
|
|
|
81 |
|
82 |
# Submit button for chat
|
83 |
if st.button("Submit Query"):
|
84 |
+
if query and url_input:
|
|
|
|
|
|
|
|
|
85 |
# Blog loading logic based on user input URL
|
86 |
loader = WebBaseLoader(
|
87 |
web_paths=(url_input,), # Use the user-input URL
|
|
|
127 |
rag_chain = (
|
128 |
{"context": retriever | format_docs, "question": RunnablePassthrough()}
|
129 |
| prompt
|
130 |
+
| ChatGroq(model="llama3-8b-8192") # Replace `llm` with an appropriate language model
|
131 |
| StrOutputParser()
|
132 |
)
|
133 |
|