Spaces:
Runtime error
Runtime error
detroitnatif
commited on
Commit
·
964e814
1
Parent(s):
c02e69c
Adding GroqSearch Space
Browse files- .env +3 -0
- LangchainSearch.py +14 -0
- app.py +44 -0
- config.py +17 -0
- requirements.txt +319 -0
.env
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
API_KEy='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'
|
2 |
+
GROQ_API_KEY = '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'
|
3 |
+
SERPER_API_KEY = 'fc4e9e4dda3ab09a3b51896f6d0211a7bc19db9e'
|
LangchainSearch.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
from langchain.llms import OpenAI
|
4 |
+
from langchain.agents import load_tools, initialize_agent, AgentType
|
5 |
+
|
6 |
+
|
7 |
+
load_dotenv()
|
8 |
+
|
9 |
+
llm = OpenAI(temperature=0.5, streaming=True, openai_api_key=os.getenv('API_KEY'))
|
10 |
+
tools = load_tools(
|
11 |
+
''
|
12 |
+
)
|
13 |
+
|
14 |
+
|
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_chat import message
|
3 |
+
from researcher import Researcher
|
4 |
+
from dotenv import find_dotenv, load_dotenv
|
5 |
+
load_dotenv(find_dotenv())
|
6 |
+
st.set_page_config(layout="wide")
|
7 |
+
st.session_state.clicked=True
|
8 |
+
|
9 |
+
@st.cache_resource(show_spinner=True)
|
10 |
+
def create_researcher():
|
11 |
+
researcher = Researcher()
|
12 |
+
return researcher
|
13 |
+
research_apprentice = create_researcher()
|
14 |
+
|
15 |
+
def display_conversation(history):
|
16 |
+
for i in range(len(history["apprentice"])):
|
17 |
+
message(history["user"][i], is_user=True, key=str(i) + "_user")
|
18 |
+
message(history["apprentice"][i], key=str(i))
|
19 |
+
|
20 |
+
if st.session_state.clicked:
|
21 |
+
st.title("GroqSearch - Your 24/7 AI Research Apprentice")
|
22 |
+
st.subheader("Search the Web with Mixtral")
|
23 |
+
|
24 |
+
if "apprentice" not in st.session_state:
|
25 |
+
st.session_state["apprentice"] = ["Hello. How can I help you?"]
|
26 |
+
if "user" not in st.session_state:
|
27 |
+
st.session_state["user"] = ["Hey Assisstant"]
|
28 |
+
|
29 |
+
col1, col2 = st.columns([1,2])
|
30 |
+
|
31 |
+
# with col1:
|
32 |
+
# st.image("res/assistant.png")
|
33 |
+
|
34 |
+
with col2:
|
35 |
+
with st.expander("Command RoboWiz"):
|
36 |
+
research_query_input = st.text_input("Resarch Query")
|
37 |
+
if st.button("Send"):
|
38 |
+
robowiz_output = research_apprentice.research(research_query_input)
|
39 |
+
|
40 |
+
st.session_state["user"].append(research_query_input)
|
41 |
+
st.session_state["apprentice"].append(robowiz_output)
|
42 |
+
|
43 |
+
if st.session_state["apprentice"]:
|
44 |
+
display_conversation(st.session_state)
|
config.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PROMPT_TEMPLATE = """
|
2 |
+
As an AI researcher, your primary goal is to seek and provide accurate answers based on reliable sources. It is crucial to prioritize factual information and avoid making things up. Your role is to assist users by presenting well-researched and verified knowledge. Remember to cite your sources whenever possible and maintain a high standard of integrity in your research. If you encounter questions outside the scope of software development, kindly remind users that your expertise lies in programming and related topics.
|
3 |
+
|
4 |
+
Context: {context}
|
5 |
+
Question: {question}
|
6 |
+
Do provide helpful answers and avoid making things up. If you are unsure about a question, it is better to skip it. Remember to cite your sources whenever possible and maintain a high standard of integrity in your research.
|
7 |
+
|
8 |
+
Answer:
|
9 |
+
"""
|
10 |
+
|
11 |
+
INPUT_VARIABLES = ["context", "question"]
|
12 |
+
SEPARATORS = "\n"
|
13 |
+
CHUNK_SIZE = 10000
|
14 |
+
CHUNK_OVERLAP = 1000
|
15 |
+
EMBEDDER = 'BAAI/bge-base-en-v1.5'
|
16 |
+
CHAIN_TYPE = 'stuff'
|
17 |
+
SEARCH_KWARGS = {'k':3}
|
requirements.txt
ADDED
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
async-timeout==4.0.3
|
2 |
+
attrs==23.2.0
|
3 |
+
autopep8==1.7.0
|
4 |
+
azure-core==1.25.0
|
5 |
+
azure-storage-blob==12.13.1
|
6 |
+
Babel==2.14.0
|
7 |
+
backcall==0.2.0
|
8 |
+
backoff==2.2.1
|
9 |
+
bcrypt==4.1.2
|
10 |
+
beautifulsoup4==4.11.1
|
11 |
+
bleach==5.0.1
|
12 |
+
blinker==1.7.0
|
13 |
+
bs4==0.0.2
|
14 |
+
build==1.1.1
|
15 |
+
cachetools==5.3.3
|
16 |
+
certifi==2024.2.2
|
17 |
+
cffi==1.15.1
|
18 |
+
chardet==5.2.0
|
19 |
+
charset-normalizer==3.3.2
|
20 |
+
chroma-hnswlib==0.7.3
|
21 |
+
chromadb==0.4.24
|
22 |
+
click==8.1.7
|
23 |
+
click-plugins==1.1.1
|
24 |
+
cligj==0.7.2
|
25 |
+
colorama==0.4.6
|
26 |
+
coloredlogs==15.0.1
|
27 |
+
comm==0.2.1
|
28 |
+
cryptography==37.0.4
|
29 |
+
cssselect==1.2.0
|
30 |
+
cycler==0.11.0
|
31 |
+
dataclasses-json==0.6.4
|
32 |
+
datasets==2.17.1
|
33 |
+
debugpy==1.6.3
|
34 |
+
decorator==5.1.1
|
35 |
+
defusedxml==0.7.1
|
36 |
+
Deprecated==1.2.14
|
37 |
+
deta==1.2.0
|
38 |
+
dill==0.3.8
|
39 |
+
distro==1.9.0
|
40 |
+
docker-pycreds==0.4.0
|
41 |
+
docstring-parser==0.15
|
42 |
+
emoji==2.10.1
|
43 |
+
entrypoints==0.4
|
44 |
+
enum-compat==0.0.3
|
45 |
+
evaluate==0.4.1
|
46 |
+
exceptiongroup==1.2.0
|
47 |
+
executing==0.10.0
|
48 |
+
faiss-cpu==1.8.0
|
49 |
+
fake-useragent==1.4.0
|
50 |
+
fastapi==0.110.0
|
51 |
+
fastjsonschema==2.16.1
|
52 |
+
feedparser==6.0.11
|
53 |
+
filelock==3.13.1
|
54 |
+
filetype==1.2.0
|
55 |
+
fiona==1.9.6
|
56 |
+
flatbuffers==23.5.26
|
57 |
+
fonttools==4.36.0
|
58 |
+
fqdn==1.5.1
|
59 |
+
frozendict==2.4.0
|
60 |
+
frozenlist==1.4.1
|
61 |
+
fsspec==2023.10.0
|
62 |
+
geopandas==0.14.3
|
63 |
+
gitdb==4.0.11
|
64 |
+
GitPython==3.1.42
|
65 |
+
google-auth==2.28.1
|
66 |
+
googleapis-common-protos==1.62.0
|
67 |
+
graphviz==0.20.1
|
68 |
+
greenlet==3.0.3
|
69 |
+
groq==0.4.2
|
70 |
+
grpcio==1.62.0
|
71 |
+
h11==0.14.0
|
72 |
+
html5lib==1.1
|
73 |
+
httpcore==1.0.4
|
74 |
+
httptools==0.6.1
|
75 |
+
httpx==0.27.0
|
76 |
+
huggingface-hub==0.21.4
|
77 |
+
humanfriendly==10.0
|
78 |
+
idna==3.6
|
79 |
+
importlib-metadata==6.11.0
|
80 |
+
importlib_resources==6.1.2
|
81 |
+
iniconfig==1.1.1
|
82 |
+
ipykernel==6.15.1
|
83 |
+
ipython==8.4.0
|
84 |
+
ipython-genutils==0.2.0
|
85 |
+
ipywidgets==8.1.2
|
86 |
+
isodate==0.6.1
|
87 |
+
isoduration==20.11.0
|
88 |
+
jedi==0.18.1
|
89 |
+
Jinja2==3.1.2
|
90 |
+
joblib==1.1.0
|
91 |
+
json5==0.9.22
|
92 |
+
jsonpatch==1.33
|
93 |
+
jsonpath-python==1.0.6
|
94 |
+
jsonpointer==2.4
|
95 |
+
jsonschema==4.21.1
|
96 |
+
jsonschema-specifications==2023.12.1
|
97 |
+
jupyter==1.0.0
|
98 |
+
jupyter-console==6.6.3
|
99 |
+
jupyter-events==0.9.0
|
100 |
+
jupyter-lsp==2.2.4
|
101 |
+
jupyter_client==8.6.0
|
102 |
+
jupyter_core==5.7.1
|
103 |
+
jupyter_server==2.13.0
|
104 |
+
jupyter_server_terminals==0.5.2
|
105 |
+
jupyterlab==4.1.4
|
106 |
+
jupyterlab-pygments==0.2.2
|
107 |
+
jupyterlab_server==2.25.3
|
108 |
+
jupyterlab_widgets==3.0.10
|
109 |
+
kiwisolver==1.4.4
|
110 |
+
kubernetes==29.0.0
|
111 |
+
langchain==0.1.10
|
112 |
+
langchain-community==0.0.25
|
113 |
+
langchain-core==0.1.28
|
114 |
+
langchain-groq==0.0.1
|
115 |
+
langchain-openai==0.0.8
|
116 |
+
langchain-text-splitters==0.0.1
|
117 |
+
langchainhub==0.1.14
|
118 |
+
langdetect==1.0.9
|
119 |
+
langsmith==0.1.13
|
120 |
+
lxml==4.9.1
|
121 |
+
markdown-it-py==3.0.0
|
122 |
+
MarkupSafe==2.1.1
|
123 |
+
marshmallow==3.21.0
|
124 |
+
matplotlib==3.5.3
|
125 |
+
matplotlib-inline==0.1.6
|
126 |
+
mdurl==0.1.2
|
127 |
+
mistune==0.8.4
|
128 |
+
mmh3==4.1.0
|
129 |
+
monai==1.3.0
|
130 |
+
monotonic==1.6
|
131 |
+
mpmath==1.3.0
|
132 |
+
msal==1.18.0
|
133 |
+
msrest==0.7.1
|
134 |
+
multidict==6.0.5
|
135 |
+
multiprocess==0.70.16
|
136 |
+
multitasking==0.0.11
|
137 |
+
mypy-extensions==1.0.0
|
138 |
+
nbclient==0.6.6
|
139 |
+
nbconvert==6.5.3
|
140 |
+
nbformat==5.4.0
|
141 |
+
nest-asyncio==1.5.5
|
142 |
+
networkx==3.2.1
|
143 |
+
nibabel==5.2.0
|
144 |
+
nltk==3.8.1
|
145 |
+
notebook==7.1.1
|
146 |
+
notebook_shim==0.2.4
|
147 |
+
numpy==1.23.2
|
148 |
+
oauthlib==3.2.2
|
149 |
+
onnxruntime==1.16.3
|
150 |
+
openai==1.13.3
|
151 |
+
opencv-python==4.9.0.80
|
152 |
+
opentelemetry-api==1.23.0
|
153 |
+
opentelemetry-exporter-otlp-proto-common==1.23.0
|
154 |
+
opentelemetry-exporter-otlp-proto-grpc==1.23.0
|
155 |
+
opentelemetry-instrumentation==0.44b0
|
156 |
+
opentelemetry-instrumentation-asgi==0.44b0
|
157 |
+
opentelemetry-instrumentation-fastapi==0.44b0
|
158 |
+
opentelemetry-proto==1.23.0
|
159 |
+
opentelemetry-sdk==1.23.0
|
160 |
+
opentelemetry-semantic-conventions==0.44b0
|
161 |
+
opentelemetry-util-http==0.44b0
|
162 |
+
orjson==3.9.15
|
163 |
+
overrides==7.7.0
|
164 |
+
packaging==23.2
|
165 |
+
pandas==2.2.1
|
166 |
+
pandocfilters==1.5.0
|
167 |
+
parse==1.20.1
|
168 |
+
parso==0.8.3
|
169 |
+
peewee==3.17.1
|
170 |
+
pexpect==4.8.0
|
171 |
+
pickleshare==0.7.5
|
172 |
+
Pillow==9.2.0
|
173 |
+
platformdirs==4.2.0
|
174 |
+
pluggy==1.0.0
|
175 |
+
portalocker==2.8.2
|
176 |
+
posthog==3.4.2
|
177 |
+
prometheus-client==0.14.1
|
178 |
+
prompt-toolkit==3.0.30
|
179 |
+
protobuf==4.25.3
|
180 |
+
psutil==5.9.1
|
181 |
+
ptyprocess==0.7.0
|
182 |
+
pulsar-client==3.4.0
|
183 |
+
pure-eval==0.2.2
|
184 |
+
py==1.11.0
|
185 |
+
pyarrow==15.0.0
|
186 |
+
pyarrow-hotfix==0.6
|
187 |
+
pyasn1==0.5.1
|
188 |
+
pyasn1-modules==0.3.0
|
189 |
+
pycodestyle==2.9.1
|
190 |
+
pycparser==2.21
|
191 |
+
pydantic==2.6.3
|
192 |
+
pydantic_core==2.16.3
|
193 |
+
pydeck==0.8.1b0
|
194 |
+
pyee==11.1.0
|
195 |
+
Pygments==2.13.0
|
196 |
+
PyJWT==2.4.0
|
197 |
+
Pympler==1.0.1
|
198 |
+
pyparsing==3.0.9
|
199 |
+
PyPika==0.48.9
|
200 |
+
pyppeteer==2.0.0
|
201 |
+
pyproj==3.6.1
|
202 |
+
pyproject_hooks==1.0.0
|
203 |
+
pyquery==2.0.0
|
204 |
+
pyrsistent==0.18.1
|
205 |
+
pytest==7.1.2
|
206 |
+
python-dateutil==2.8.2
|
207 |
+
python-dotenv==1.0.1
|
208 |
+
python-iso639==2024.2.7
|
209 |
+
python-json-logger==2.0.7
|
210 |
+
python-magic==0.4.27
|
211 |
+
pytz==2024.1
|
212 |
+
PyYAML==6.0.1
|
213 |
+
pyzmq==25.1.2
|
214 |
+
qtconsole==5.5.1
|
215 |
+
QtPy==2.4.1
|
216 |
+
rapidfuzz==3.6.1
|
217 |
+
referencing==0.33.0
|
218 |
+
regex==2023.12.25
|
219 |
+
requests==2.31.0
|
220 |
+
requests-html==0.10.0
|
221 |
+
requests-oauthlib==1.3.1
|
222 |
+
responses==0.18.0
|
223 |
+
rfc3339-validator==0.1.4
|
224 |
+
rfc3986-validator==0.1.1
|
225 |
+
rich==13.7.0
|
226 |
+
rpds-py==0.18.0
|
227 |
+
rsa==4.9
|
228 |
+
sacrebleu==2.4.0
|
229 |
+
sacremoses==0.1.1
|
230 |
+
safetensors==0.4.2
|
231 |
+
scikit-learn==1.1.2
|
232 |
+
scipy==1.9.0
|
233 |
+
semver==3.0.2
|
234 |
+
Send2Trash==1.8.2
|
235 |
+
sentence-transformers==2.5.1
|
236 |
+
sentencepiece==0.2.0
|
237 |
+
sentry-sdk==1.40.6
|
238 |
+
setproctitle==1.3.3
|
239 |
+
sgmllib3k==1.0.0
|
240 |
+
shapely==2.0.3
|
241 |
+
shtab==1.7.0
|
242 |
+
six==1.16.0
|
243 |
+
sklearn==0.0
|
244 |
+
smmap==5.0.1
|
245 |
+
sniffio==1.3.1
|
246 |
+
soupsieve==2.3.2.post1
|
247 |
+
SQLAlchemy==2.0.27
|
248 |
+
stack-data==0.4.0
|
249 |
+
starlette==0.36.3
|
250 |
+
streamlit==1.31.1
|
251 |
+
streamlit-chat==0.1.1
|
252 |
+
sympy==1.12
|
253 |
+
tableauserverclient==0.19.0
|
254 |
+
tabulate==0.9.0
|
255 |
+
tenacity==8.2.3
|
256 |
+
terminado==0.15.0
|
257 |
+
threadpoolctl==3.1.0
|
258 |
+
tiktoken==0.6.0
|
259 |
+
tinycss2==1.1.1
|
260 |
+
tokenizers==0.15.2
|
261 |
+
toml==0.10.2
|
262 |
+
tomli==2.0.1
|
263 |
+
toolz==0.12.1
|
264 |
+
torch==2.2.0
|
265 |
+
torch-model-archiver==0.9.0
|
266 |
+
torch-workflow-archiver==0.2.11
|
267 |
+
torchaudio==2.2.0
|
268 |
+
torchinfo==1.8.0
|
269 |
+
torchserve==0.9.0
|
270 |
+
torchvision==0.17.0
|
271 |
+
tornado==6.4
|
272 |
+
tqdm==4.66.2
|
273 |
+
traitlets==5.14.1
|
274 |
+
transformers==4.38.1
|
275 |
+
trl==0.7.11
|
276 |
+
typer==0.9.0
|
277 |
+
types-python-dateutil==2.8.19.20240106
|
278 |
+
types-requests==2.31.0.20240218
|
279 |
+
typing-inspect==0.9.0
|
280 |
+
typing_extensions==4.9.0
|
281 |
+
tyro==0.7.3
|
282 |
+
tzdata==2024.1
|
283 |
+
tzlocal==5.2
|
284 |
+
unstructured==0.12.5
|
285 |
+
unstructured-client==0.21.0
|
286 |
+
uri-template==1.3.0
|
287 |
+
urllib3==1.26.18
|
288 |
+
uvicorn==0.27.1
|
289 |
+
uvloop==0.19.0
|
290 |
+
validators==0.22.0
|
291 |
+
w3lib==2.1.2
|
292 |
+
wandb==0.16.3
|
293 |
+
watchfiles==0.21.0
|
294 |
+
wcwidth==0.2.5
|
295 |
+
webcolors==1.13
|
296 |
+
webencodings==0.5.1
|
297 |
+
websocket-client==1.7.0
|
298 |
+
websockets==10.4
|
299 |
+
widgetsnbextension==4.0.10
|
300 |
+
wrapt==1.16.0
|
301 |
+
xxhash==3.4.1
|
302 |
+
yahoo-fin==0.8.9.1
|
303 |
+
yarl==1.9.4
|
304 |
+
yfinance==0.2.37
|
305 |
+
zipp==3.17.0
|
306 |
+
accelerate==0.27.2
|
307 |
+
aiohttp==3.9.3
|
308 |
+
aiosignal==1.3.1
|
309 |
+
altair==5.2.0
|
310 |
+
annotated-types==0.6.0
|
311 |
+
anyio==4.3.0
|
312 |
+
appdirs==1.4.4
|
313 |
+
appnope==0.1.3
|
314 |
+
argon2-cffi==21.3.0
|
315 |
+
argon2-cffi-bindings==21.2.0
|
316 |
+
arrow==1.3.0
|
317 |
+
asgiref==3.7.2
|
318 |
+
asttokens==2.0.8
|
319 |
+
async-lru==2.0.4
|