arabellastrange
commited on
Commit
·
9d67042
1
Parent(s):
2ff58bd
removed zenrows params + updated google question prompt
Browse files- app.py +4 -4
- generate_response.py +3 -3
- web_search.py +4 -4
app.py
CHANGED
@@ -5,7 +5,7 @@ from time import asctime
|
|
5 |
import gradio as gr
|
6 |
from llama_index.core import Document, VectorStoreIndex
|
7 |
|
8 |
-
from generate_response import generate_chat_response_with_history, set_llm, is_search_query,
|
9 |
generate_chat_response_with_history_rag_return_response
|
10 |
from read_write_index import read_write_index
|
11 |
from web_search import search
|
@@ -33,9 +33,9 @@ art_sources = ("1. https://en.wikipedia.org/wiki/Post-Impressionism"
|
|
33 |
|
34 |
|
35 |
def google_search_chat(message, history):
|
36 |
-
|
37 |
-
if is_search_query(
|
38 |
-
search_results = search(message,
|
39 |
print(f'Search results returned: {len(search_results)}')
|
40 |
relevant_content = ""
|
41 |
sources = ""
|
|
|
5 |
import gradio as gr
|
6 |
from llama_index.core import Document, VectorStoreIndex
|
7 |
|
8 |
+
from generate_response import generate_chat_response_with_history, set_llm, is_search_query, google_question, \
|
9 |
generate_chat_response_with_history_rag_return_response
|
10 |
from read_write_index import read_write_index
|
11 |
from web_search import search
|
|
|
33 |
|
34 |
|
35 |
def google_search_chat(message, history):
|
36 |
+
gquestion = google_question(message, history)
|
37 |
+
if is_search_query(gquestion):
|
38 |
+
search_results = search(message, gquestion)
|
39 |
print(f'Search results returned: {len(search_results)}')
|
40 |
relevant_content = ""
|
41 |
sources = ""
|
generate_response.py
CHANGED
@@ -151,11 +151,11 @@ def collect_history(message, history):
|
|
151 |
return messages
|
152 |
|
153 |
|
154 |
-
def
|
155 |
DEFAULT_TEMPLATE = """\
|
156 |
Given a conversation (between Human and Assistant) and a follow up message from Human, \
|
157 |
-
rewrite the message to be a standalone
|
158 |
-
from the conversation.
|
159 |
|
160 |
<Chat History>
|
161 |
{chat_history}
|
|
|
151 |
return messages
|
152 |
|
153 |
|
154 |
+
def google_question(message, history):
|
155 |
DEFAULT_TEMPLATE = """\
|
156 |
Given a conversation (between Human and Assistant) and a follow up message from Human, \
|
157 |
+
rewrite the message to be a standalone web engine search query that captures all relevant context \
|
158 |
+
from the conversation in keywords.
|
159 |
|
160 |
<Chat History>
|
161 |
{chat_history}
|
web_search.py
CHANGED
@@ -54,10 +54,10 @@ def process_url(url):
|
|
54 |
warnings.simplefilter("ignore")
|
55 |
try:
|
56 |
client = ZenRowsClient(os.getenv('zenrows_api_key'))
|
57 |
-
params = {"js_render": "true", "json_response": "true",
|
58 |
-
|
59 |
-
|
60 |
-
response = client.get(url
|
61 |
print(f'got response, status: {response.status_code}')
|
62 |
result = response.text
|
63 |
if len(result) > 0:
|
|
|
54 |
warnings.simplefilter("ignore")
|
55 |
try:
|
56 |
client = ZenRowsClient(os.getenv('zenrows_api_key'))
|
57 |
+
# params = {"js_render": "true", "json_response": "true",
|
58 |
+
# "js_instructions": "%5B%7B%22click%22%3A%22.selector%22%7D%2C%7B%22wait%22%3A500%7D%2C%7B%22fill%22%3A%5B%22.input%22%2C%22value%22%5D%7D%2C%7B%22wait_for%22%3A%22.slow_selector%22%7D%5D",
|
59 |
+
# "autoparse": "true"}
|
60 |
+
response = client.get(url)
|
61 |
print(f'got response, status: {response.status_code}')
|
62 |
result = response.text
|
63 |
if len(result) > 0:
|