Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -252,12 +252,12 @@ def generate_answer(message, choice, retrieval_mode):
|
|
252 |
chain_type_kwargs={"prompt": prompt_template}
|
253 |
)
|
254 |
response = qa_chain({"query": message})
|
|
|
255 |
elif retrieval_mode == "Knowledge-Graph":
|
256 |
response = chain_neo4j.invoke({"question": message})
|
|
|
257 |
else:
|
258 |
-
|
259 |
-
|
260 |
-
return response['output'], extract_addresses(response['output'])
|
261 |
|
262 |
def bot(history, choice, tts_choice, retrieval_mode):
|
263 |
if not history:
|
@@ -338,7 +338,7 @@ def fetch_local_news():
|
|
338 |
api_key = os.environ['SERP_API']
|
339 |
url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
|
340 |
response = requests.get(url)
|
341 |
-
if response.status_code == 200:
|
342 |
results = response.json().get("news_results", [])
|
343 |
news_html = """
|
344 |
<h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
|
@@ -522,7 +522,7 @@ def preprocess(text):
|
|
522 |
abbreviations = re.findall(abbreviations_pattern, text)
|
523 |
for abv in abbreviations:
|
524 |
if abv in text:
|
525 |
-
text
|
526 |
return text
|
527 |
|
528 |
def chunk_text(text, max_length=250):
|
@@ -632,7 +632,7 @@ def fetch_local_events():
|
|
632 |
api_key = os.environ['SERP_API']
|
633 |
url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
|
634 |
response = requests.get(url)
|
635 |
-
if response.status_code == 200:
|
636 |
events_results = response.json().get("events_results", [])
|
637 |
events_html = """
|
638 |
<h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
|
|
|
252 |
chain_type_kwargs={"prompt": prompt_template}
|
253 |
)
|
254 |
response = qa_chain({"query": message})
|
255 |
+
return response['output'], extract_addresses(response['output'])
|
256 |
elif retrieval_mode == "Knowledge-Graph":
|
257 |
response = chain_neo4j.invoke({"question": message})
|
258 |
+
return response, extract_addresses(response)
|
259 |
else:
|
260 |
+
return "Invalid retrieval mode selected.", []
|
|
|
|
|
261 |
|
262 |
def bot(history, choice, tts_choice, retrieval_mode):
|
263 |
if not history:
|
|
|
338 |
api_key = os.environ['SERP_API']
|
339 |
url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
|
340 |
response = requests.get(url)
|
341 |
+
if response.status_code == 200):
|
342 |
results = response.json().get("news_results", [])
|
343 |
news_html = """
|
344 |
<h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
|
|
|
522 |
abbreviations = re.findall(abbreviations_pattern, text)
|
523 |
for abv in abbreviations:
|
524 |
if abv in text:
|
525 |
+
text is text.replace(abv, separate_abb(abv))
|
526 |
return text
|
527 |
|
528 |
def chunk_text(text, max_length=250):
|
|
|
632 |
api_key = os.environ['SERP_API']
|
633 |
url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
|
634 |
response = requests.get(url)
|
635 |
+
if response.status_code == 200):
|
636 |
events_results = response.json().get("events_results", [])
|
637 |
events_html = """
|
638 |
<h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
|