Pijush2023 commited on
Commit
08e3eec
·
verified ·
1 Parent(s): 800db56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -20
app.py CHANGED
@@ -1233,7 +1233,7 @@ def neo4j_retrieval_conversational(question: str):
1233
  structured_data = structured_retriever(question)
1234
  logging.debug(f"Structured data (Conversational): {structured_data}")
1235
  prompt = QA_CHAIN_PROMPT_NEO4J_CONVERSATIONAL.format(context=structured_data, question=question)
1236
- response = chat_model({"query": prompt})
1237
  return response, []
1238
 
1239
  # Neo4j Retrieval chain for detailed mode
@@ -1241,7 +1241,7 @@ def neo4j_retrieval_details(question: str):
1241
  structured_data = structured_retriever(question)
1242
  logging.debug(f"Structured data (Details): {structured_data}")
1243
  prompt = QA_CHAIN_PROMPT_NEO4J_DETAILS.format(context=structured_data, question=question)
1244
- response = chat_model({"query": prompt})
1245
  return response, extract_addresses(response)
1246
 
1247
  # Update the generate_answer function to include Neo4j retrieval modes
@@ -1270,16 +1270,7 @@ def generate_answer(message, choice, retrieval_mode):
1270
  else:
1271
  return "Invalid retrieval mode selected.", []
1272
 
1273
- # Full Text query Generator
1274
- def generate_full_text_query(input: str) -> str:
1275
- full_text_query = ""
1276
- words = [el for el in remove_lucene_chars(input).split() if el]
1277
- for word in words[:-1]:
1278
- full_text_query += f" {word}~2 AND"
1279
- full_text_query += f" {words[-1]}~2"
1280
- return full_text_query.strip()
1281
 
1282
- # Rest of the code remains the same
1283
 
1284
  def bot(history, choice, tts_choice, retrieval_mode):
1285
  if not history:
@@ -1653,7 +1644,7 @@ def fetch_local_events():
1653
  api_key = os.environ['SERP_API']
1654
  url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
1655
  response = requests.get(url)
1656
- if response.status_code == 200:
1657
  events_results = response.json().get("events_results", [])
1658
  events_html = """
1659
  <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
@@ -1864,11 +1855,3 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1864
 
1865
  demo.queue()
1866
  demo.launch(share=True)
1867
-
1868
-
1869
-
1870
-
1871
-
1872
-
1873
-
1874
-
 
1233
  structured_data = structured_retriever(question)
1234
  logging.debug(f"Structured data (Conversational): {structured_data}")
1235
  prompt = QA_CHAIN_PROMPT_NEO4J_CONVERSATIONAL.format(context=structured_data, question=question)
1236
+ response = chat_model(prompt)
1237
  return response, []
1238
 
1239
  # Neo4j Retrieval chain for detailed mode
 
1241
  structured_data = structured_retriever(question)
1242
  logging.debug(f"Structured data (Details): {structured_data}")
1243
  prompt = QA_CHAIN_PROMPT_NEO4J_DETAILS.format(context=structured_data, question=question)
1244
+ response = chat_model(prompt)
1245
  return response, extract_addresses(response)
1246
 
1247
  # Update the generate_answer function to include Neo4j retrieval modes
 
1270
  else:
1271
  return "Invalid retrieval mode selected.", []
1272
 
 
 
 
 
 
 
 
 
1273
 
 
1274
 
1275
  def bot(history, choice, tts_choice, retrieval_mode):
1276
  if not history:
 
1644
  api_key = os.environ['SERP_API']
1645
  url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
1646
  response = requests.get(url)
1647
+ if response.status_code == 200):
1648
  events_results = response.json().get("events_results", [])
1649
  events_html = """
1650
  <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
 
1855
 
1856
  demo.queue()
1857
  demo.launch(share=True)