Upload 2 files
Browse files- app.py +104 -0
- requirement.txt +176 -0
app.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain.agents import AgentType, initialize_agent, load_tools
|
| 3 |
+
from langchain import HuggingFaceHub
|
| 4 |
+
from langchain.tools import Tool, ShellTool
|
| 5 |
+
import os
|
| 6 |
+
from datetime import datetime
|
| 7 |
+
from langchain.tools import DuckDuckGoSearchRun
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
token = os.environ['HF_TOKEN']
|
| 11 |
+
|
| 12 |
+
hub_llm = HuggingFaceHub(
|
| 13 |
+
repo_id='mistralai/Mixtral-8x7B-Instruct-v0.1',
|
| 14 |
+
huggingfacehub_api_token=token)
|
| 15 |
+
|
| 16 |
+
# Set the page title and icon
|
| 17 |
+
st.set_page_config(
|
| 18 |
+
page_title="AI Driven Search",
|
| 19 |
+
page_icon="🔍",
|
| 20 |
+
layout="wide", # Wide layout for additional space
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Custom CSS style for the title block
|
| 24 |
+
st.markdown(
|
| 25 |
+
"""
|
| 26 |
+
<style>
|
| 27 |
+
.title-block {
|
| 28 |
+
background-color: #3498db;
|
| 29 |
+
color: #ffffff;
|
| 30 |
+
padding: 20px;
|
| 31 |
+
border-radius: 10px;
|
| 32 |
+
margin-bottom: 20px;
|
| 33 |
+
}
|
| 34 |
+
.subtitle {
|
| 35 |
+
color: #2c3e50;
|
| 36 |
+
}
|
| 37 |
+
</style>
|
| 38 |
+
""",
|
| 39 |
+
unsafe_allow_html=True,
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
# Title block with custom styling
|
| 43 |
+
st.markdown('<div class="title-block">', unsafe_allow_html=True)
|
| 44 |
+
st.title("🌐 AI powered Search Engine")
|
| 45 |
+
st.markdown("### Find what you're looking for with the power of AI!")
|
| 46 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 47 |
+
|
| 48 |
+
# Subtitle and description with custom styling
|
| 49 |
+
st.markdown('<div class="subtitle">', unsafe_allow_html=True)
|
| 50 |
+
st.subheader("How it works:")
|
| 51 |
+
st.write(
|
| 52 |
+
"Our search engine is powered by DuckDuck Go search and uses language models "
|
| 53 |
+
"that understand your queries and provide accurate results. "
|
| 54 |
+
)
|
| 55 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 56 |
+
|
| 57 |
+
# Add any other content or functionality as needed
|
| 58 |
+
|
| 59 |
+
# Example search input
|
| 60 |
+
# search_query = st.text_input("Enter your search query:")
|
| 61 |
+
with st.form(key="form"):
|
| 62 |
+
user_input = st.text_input("Ask your question")
|
| 63 |
+
submit_clicked = st.form_submit_button("Enter your search")
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# Example search button
|
| 67 |
+
# if st.button("Search", key="search_button"):
|
| 68 |
+
if submit_clicked:
|
| 69 |
+
|
| 70 |
+
# Add your AI-powered search functionality here
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
# Define a new tool that returns the current datetime
|
| 74 |
+
datetime_tool = Tool(
|
| 75 |
+
name="Datetime",
|
| 76 |
+
func=lambda x: datetime.now().isoformat(),
|
| 77 |
+
description="Returns the current datetime",
|
| 78 |
+
)
|
| 79 |
+
search = DuckDuckGoSearchRun()
|
| 80 |
+
search_tool = Tool(
|
| 81 |
+
name="search",
|
| 82 |
+
func=search,
|
| 83 |
+
description="search over the internet using this tool"
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
agent_chain = initialize_agent(
|
| 89 |
+
[search_tool],
|
| 90 |
+
hub_llm,
|
| 91 |
+
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
| 92 |
+
verbose=True,
|
| 93 |
+
handle_parsing_errors =True,
|
| 94 |
+
)
|
| 95 |
+
result = agent_chain.run(user_input)
|
| 96 |
+
st.success(result)
|
| 97 |
+
|
| 98 |
+
# Add any other components or features as needed
|
| 99 |
+
|
| 100 |
+
# Footer with custom styling
|
| 101 |
+
st.markdown(
|
| 102 |
+
'<p style="text-align:center; color:#7f8c8d;">Built with ❤️ by Abhishek | <a href="https://github.com/your_username/your_repo" style="color:#3498db;">GitHub Repo</a></p>',
|
| 103 |
+
unsafe_allow_html=True,
|
| 104 |
+
)
|
requirement.txt
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
asttokens==2.4.1
|
| 10 |
+
async-lru==2.0.4
|
| 11 |
+
async-timeout==4.0.3
|
| 12 |
+
attrs==23.1.0
|
| 13 |
+
Babel==2.13.1
|
| 14 |
+
beautifulsoup4==4.12.2
|
| 15 |
+
bleach==6.1.0
|
| 16 |
+
blinker==1.7.0
|
| 17 |
+
cachetools==5.3.2
|
| 18 |
+
certifi==2023.11.17
|
| 19 |
+
cffi==1.16.0
|
| 20 |
+
charset-normalizer==3.3.2
|
| 21 |
+
click==8.1.7
|
| 22 |
+
colorama==0.4.6
|
| 23 |
+
comm==0.2.0
|
| 24 |
+
contourpy==1.2.0
|
| 25 |
+
curl-cffi==0.5.10
|
| 26 |
+
cycler==0.12.1
|
| 27 |
+
dataclasses-json==0.6.3
|
| 28 |
+
debugpy==1.8.0
|
| 29 |
+
decorator==5.1.1
|
| 30 |
+
defusedxml==0.7.1
|
| 31 |
+
duckduckgo_search==4.2
|
| 32 |
+
exceptiongroup==1.2.0
|
| 33 |
+
executing==2.0.1
|
| 34 |
+
fastjsonschema==2.19.0
|
| 35 |
+
filelock==3.13.1
|
| 36 |
+
fonttools==4.46.0
|
| 37 |
+
fqdn==1.5.1
|
| 38 |
+
frozenlist==1.4.1
|
| 39 |
+
fsspec==2023.12.1
|
| 40 |
+
gitdb==4.0.11
|
| 41 |
+
GitPython==3.1.40
|
| 42 |
+
greenlet==3.0.3
|
| 43 |
+
huggingface-hub==0.20.2
|
| 44 |
+
idna==3.6
|
| 45 |
+
importlib-metadata==7.0.1
|
| 46 |
+
ipykernel==6.27.1
|
| 47 |
+
ipython==8.18.1
|
| 48 |
+
isoduration==20.11.0
|
| 49 |
+
jedi==0.19.1
|
| 50 |
+
Jinja2==3.1.2
|
| 51 |
+
joblib==1.3.2
|
| 52 |
+
json5==0.9.14
|
| 53 |
+
jsonpatch==1.33
|
| 54 |
+
jsonpointer==2.4
|
| 55 |
+
jsonschema==4.20.0
|
| 56 |
+
jsonschema-specifications==2023.11.2
|
| 57 |
+
jupyter-events==0.9.0
|
| 58 |
+
jupyter-lsp==2.2.1
|
| 59 |
+
jupyter-server-mathjax==0.2.6
|
| 60 |
+
jupyter_client==8.6.0
|
| 61 |
+
jupyter_core==5.5.0
|
| 62 |
+
jupyter_server==2.12.1
|
| 63 |
+
jupyter_server_terminals==0.4.4
|
| 64 |
+
jupyterlab==4.0.9
|
| 65 |
+
jupyterlab_git==0.50.0
|
| 66 |
+
jupyterlab_pygments==0.3.0
|
| 67 |
+
jupyterlab_server==2.25.2
|
| 68 |
+
kiwisolver==1.4.5
|
| 69 |
+
langchain==0.1.0
|
| 70 |
+
langchain-community==0.0.12
|
| 71 |
+
langchain-core==0.1.10
|
| 72 |
+
langsmith==0.0.80
|
| 73 |
+
lxml==5.1.0
|
| 74 |
+
markdown-it-py==3.0.0
|
| 75 |
+
MarkupSafe==2.1.3
|
| 76 |
+
marshmallow==3.20.2
|
| 77 |
+
matplotlib==3.8.2
|
| 78 |
+
matplotlib-inline==0.1.6
|
| 79 |
+
mdurl==0.1.2
|
| 80 |
+
mistune==3.0.2
|
| 81 |
+
mpmath==1.3.0
|
| 82 |
+
multidict==6.0.4
|
| 83 |
+
mypy-extensions==1.0.0
|
| 84 |
+
nbclient==0.9.0
|
| 85 |
+
nbconvert==7.12.0
|
| 86 |
+
nbdime==4.0.1
|
| 87 |
+
nbformat==5.9.2
|
| 88 |
+
nest-asyncio==1.5.8
|
| 89 |
+
networkx==3.2.1
|
| 90 |
+
notebook_shim==0.2.3
|
| 91 |
+
numpy==1.26.2
|
| 92 |
+
nvidia-cublas-cu12==12.1.3.1
|
| 93 |
+
nvidia-cuda-cupti-cu12==12.1.105
|
| 94 |
+
nvidia-cuda-nvrtc-cu12==12.1.105
|
| 95 |
+
nvidia-cuda-runtime-cu12==12.1.105
|
| 96 |
+
nvidia-cudnn-cu12==8.9.2.26
|
| 97 |
+
nvidia-cufft-cu12==11.0.2.54
|
| 98 |
+
nvidia-curand-cu12==10.3.2.106
|
| 99 |
+
nvidia-cusolver-cu12==11.4.5.107
|
| 100 |
+
nvidia-cusparse-cu12==12.1.0.106
|
| 101 |
+
nvidia-nccl-cu12==2.18.1
|
| 102 |
+
nvidia-nvjitlink-cu12==12.3.101
|
| 103 |
+
nvidia-nvtx-cu12==12.1.105
|
| 104 |
+
overrides==7.4.0
|
| 105 |
+
packaging==23.2
|
| 106 |
+
pandas==2.1.3
|
| 107 |
+
pandocfilters==1.5.0
|
| 108 |
+
parso==0.8.3
|
| 109 |
+
pexpect==4.9.0
|
| 110 |
+
Pillow==10.1.0
|
| 111 |
+
platformdirs==4.1.0
|
| 112 |
+
plotly==5.18.0
|
| 113 |
+
prometheus-client==0.19.0
|
| 114 |
+
prompt-toolkit==3.0.41
|
| 115 |
+
protobuf==4.25.2
|
| 116 |
+
psutil==5.9.6
|
| 117 |
+
ptyprocess==0.7.0
|
| 118 |
+
pure-eval==0.2.2
|
| 119 |
+
pyarrow==14.0.2
|
| 120 |
+
pycparser==2.21
|
| 121 |
+
pydantic==2.5.3
|
| 122 |
+
pydantic_core==2.14.6
|
| 123 |
+
pydeck==0.8.1b0
|
| 124 |
+
Pygments==2.17.2
|
| 125 |
+
pyparsing==3.1.1
|
| 126 |
+
python-dateutil==2.8.2
|
| 127 |
+
python-json-logger==2.0.7
|
| 128 |
+
pytz==2023.3.post1
|
| 129 |
+
PyYAML==6.0.1
|
| 130 |
+
pyzmq==25.1.2
|
| 131 |
+
referencing==0.32.0
|
| 132 |
+
requests==2.31.0
|
| 133 |
+
rfc3339-validator==0.1.4
|
| 134 |
+
rfc3986-validator==0.1.1
|
| 135 |
+
rich==13.7.0
|
| 136 |
+
rpds-py==0.13.2
|
| 137 |
+
scikit-learn==1.3.2
|
| 138 |
+
scipy==1.11.4
|
| 139 |
+
seaborn==0.13.0
|
| 140 |
+
Send2Trash==1.8.2
|
| 141 |
+
six==1.16.0
|
| 142 |
+
smmap==5.0.1
|
| 143 |
+
sniffio==1.3.0
|
| 144 |
+
soupsieve==2.5
|
| 145 |
+
SQLAlchemy==2.0.25
|
| 146 |
+
stack-data==0.6.3
|
| 147 |
+
streamlit==1.30.0
|
| 148 |
+
streamlit-chat==0.1.1
|
| 149 |
+
sympy==1.12
|
| 150 |
+
tenacity==8.2.3
|
| 151 |
+
terminado==0.18.0
|
| 152 |
+
threadpoolctl==3.2.0
|
| 153 |
+
tinycss2==1.2.1
|
| 154 |
+
toml==0.10.2
|
| 155 |
+
tomli==2.0.1
|
| 156 |
+
toolz==0.12.0
|
| 157 |
+
torch==2.1.1
|
| 158 |
+
tornado==6.4
|
| 159 |
+
tqdm==4.66.1
|
| 160 |
+
traitlets==5.14.0
|
| 161 |
+
triton==2.1.0
|
| 162 |
+
types-python-dateutil==2.8.19.14
|
| 163 |
+
typing-inspect==0.9.0
|
| 164 |
+
typing_extensions==4.8.0
|
| 165 |
+
tzdata==2023.3
|
| 166 |
+
tzlocal==5.2
|
| 167 |
+
uri-template==1.3.0
|
| 168 |
+
urllib3==2.0.7
|
| 169 |
+
validators==0.22.0
|
| 170 |
+
watchdog==3.0.0
|
| 171 |
+
wcwidth==0.2.12
|
| 172 |
+
webcolors==1.13
|
| 173 |
+
webencodings==0.5.1
|
| 174 |
+
websocket-client==1.7.0
|
| 175 |
+
yarl==1.9.4
|
| 176 |
+
zipp==3.17.0
|