Commit
·
f58ccf2
1
Parent(s):
44255d1
basic chrome
Browse files- app.py +8 -1
- web_search.py +0 -10
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
import logging
|
2 |
import os
|
|
|
3 |
from time import asctime
|
4 |
|
5 |
import gradio as gr
|
6 |
from llama_index.core import Document, VectorStoreIndex
|
7 |
|
8 |
-
|
9 |
from generate_response import generate_chat_response_with_history, set_llm, is_search_query, condense_question, \
|
10 |
generate_chat_response_with_history_rag_return_response
|
11 |
from web_search import search
|
@@ -106,8 +106,15 @@ if __name__ == '__main__':
|
|
106 |
# a task. Returns a maximum of 4,096 output tokens. Link:
|
107 |
# https://openai.com/blog/new-embedding-models-and-api-updates
|
108 |
set_llm(key=api_key, model="gpt-4-0125-preview", temperature=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
logger.info("Launching Gradio ChatInterface for searchbot...")
|
|
|
111 |
demo = gr.ChatInterface(fn=google_search_chat,
|
112 |
title="Search Assistant", retry_btn=None, undo_btn=None, clear_btn=None,
|
113 |
theme="soft")
|
|
|
1 |
import logging
|
2 |
import os
|
3 |
+
from subprocess import check_call, STDOUT
|
4 |
from time import asctime
|
5 |
|
6 |
import gradio as gr
|
7 |
from llama_index.core import Document, VectorStoreIndex
|
8 |
|
|
|
9 |
from generate_response import generate_chat_response_with_history, set_llm, is_search_query, condense_question, \
|
10 |
generate_chat_response_with_history_rag_return_response
|
11 |
from web_search import search
|
|
|
106 |
# a task. Returns a maximum of 4,096 output tokens. Link:
|
107 |
# https://openai.com/blog/new-embedding-models-and-api-updates
|
108 |
set_llm(key=api_key, model="gpt-4-0125-preview", temperature=0)
|
109 |
+
# apt-get install -y libglib2.0-0=2.50.3-2 \
|
110 |
+
# libnss3=2:3.26.2-1.1+deb9u1 \
|
111 |
+
# libgconf-2-4=3.2.6-4+b1 \
|
112 |
+
# libfontconfig1=2.11.0-6.7+b1
|
113 |
+
check_call(['apt-get', 'install', '-y', 'libglib2.0-0 libnss3 libgconf-2-4 libfontconfig1'],
|
114 |
+
stdout=open(os.devnull, 'wb'), stderr=STDOUT)
|
115 |
|
116 |
logger.info("Launching Gradio ChatInterface for searchbot...")
|
117 |
+
|
118 |
demo = gr.ChatInterface(fn=google_search_chat,
|
119 |
title="Search Assistant", retry_btn=None, undo_btn=None, clear_btn=None,
|
120 |
theme="soft")
|
web_search.py
CHANGED
@@ -8,7 +8,6 @@ import traceback
|
|
8 |
import urllib.parse as en
|
9 |
import warnings
|
10 |
from itertools import zip_longest
|
11 |
-
from subprocess import check_call, STDOUT
|
12 |
|
13 |
import requests
|
14 |
import selenium.common.exceptions
|
@@ -83,15 +82,6 @@ def process_url(url, timeout):
|
|
83 |
result = ""
|
84 |
# make driver exec
|
85 |
os.chmod('chromedriver-linux64/chromedriver', stat.S_IEXEC)
|
86 |
-
# apt-get install -y libglib2.0-0=2.50.3-2 \
|
87 |
-
# libnss3=2:3.26.2-1.1+deb9u1 \
|
88 |
-
# libgconf-2-4=3.2.6-4+b1 \
|
89 |
-
# libfontconfig1=2.11.0-6.7+b1
|
90 |
-
check_call(['apt-get', 'install', '-y', 'libglib2.0-0=2.50.3-2 \
|
91 |
-
libnss3=2:3.26.2-1.1+deb9u1 \
|
92 |
-
libgconf-2-4=3.2.6-4+b1 \
|
93 |
-
libfontconfig1=2.11.0-6.7+b1'],
|
94 |
-
stdout=open(os.devnull, 'wb'), stderr=STDOUT)
|
95 |
try:
|
96 |
driver = webdriver.Chrome(service=ChromeService(executable_path='chromedriver-linux64/chromedriver'),
|
97 |
options=options)
|
|
|
8 |
import urllib.parse as en
|
9 |
import warnings
|
10 |
from itertools import zip_longest
|
|
|
11 |
|
12 |
import requests
|
13 |
import selenium.common.exceptions
|
|
|
82 |
result = ""
|
83 |
# make driver exec
|
84 |
os.chmod('chromedriver-linux64/chromedriver', stat.S_IEXEC)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
try:
|
86 |
driver = webdriver.Chrome(service=ChromeService(executable_path='chromedriver-linux64/chromedriver'),
|
87 |
options=options)
|