Shreyas094 commited on
Commit
e19ec1b
·
verified ·
1 Parent(s): b463127

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -69,7 +69,7 @@ def rephrase_query(previous_response: str, new_query: str) -> str:
69
  response = client.text_generation(prompt, max_new_tokens=30, temperature=0.3)
70
 
71
  # Extract only the rephrased query from the response
72
- rephrased_query = response.split(":")[-1].strip()
73
  return rephrased_query
74
 
75
  def respond(message, chat_history, model, temperature, num_api_calls):
@@ -82,6 +82,10 @@ def respond(message, chat_history, model, temperature, num_api_calls):
82
 
83
  final_summary = ""
84
  for _ in range(num_api_calls):
 
 
 
 
85
  search_results = get_web_search_results(rephrased_query)
86
 
87
  # If no results or error, try rephrasing and searching again
 
69
  response = client.text_generation(prompt, max_new_tokens=30, temperature=0.3)
70
 
71
  # Extract only the rephrased query from the response
72
+ rephrased_query = response.split("\n")[-1].strip()
73
  return rephrased_query
74
 
75
  def respond(message, chat_history, model, temperature, num_api_calls):
 
82
 
83
  final_summary = ""
84
  for _ in range(num_api_calls):
85
+ if not rephrased_query or not isinstance(rephrased_query, str):
86
+ print(f"Invalid rephrased query: {rephrased_query}")
87
+ break
88
+
89
  search_results = get_web_search_results(rephrased_query)
90
 
91
  # If no results or error, try rephrasing and searching again