Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1838,12 +1838,12 @@ def chatbot_response(message, history):
|
|
| 1838 |
for statement in statements:
|
| 1839 |
top_scoring_statements += f"- {statement}\n"
|
| 1840 |
top_scoring_statements += "\n"
|
| 1841 |
-
last_top_scoring_statements = top_scoring_statements # Save for future use
|
| 1842 |
else:
|
| 1843 |
-
top_scoring_statements =
|
| 1844 |
|
| 1845 |
-
# Combine predefined prompt, top-scoring statements (only
|
| 1846 |
-
combined_prompt =
|
| 1847 |
combined_prompt += "\n\nUser Input:\n" + message
|
| 1848 |
trust_tip, suggestion = get_trust_tip_and_suggestion()
|
| 1849 |
trust_tip_and_suggestion = f"\n\n---\n\n**Trust Tip**: {trust_tip}\n\n**Suggestion**: {suggestion}"
|
|
@@ -1871,7 +1871,9 @@ def chatbot_response(message, history):
|
|
| 1871 |
|
| 1872 |
# Prepare the final response
|
| 1873 |
response = f"**Selected Dataset: {selected_dataset_ai}**\n\n"
|
| 1874 |
-
#
|
|
|
|
|
|
|
| 1875 |
response += f"\n{agent_output['output']}"
|
| 1876 |
response += trust_tip_and_suggestion
|
| 1877 |
|
|
@@ -1891,6 +1893,7 @@ def chatbot_response(message, history):
|
|
| 1891 |
logger.error(f"Unexpected error: {e}")
|
| 1892 |
return "Error occurred during response generation."
|
| 1893 |
|
|
|
|
| 1894 |
# def chatbot_response(message, history):
|
| 1895 |
# """
|
| 1896 |
# Generate chatbot response dynamically using selected dataset, user input, and maintaining history.
|
|
|
|
| 1838 |
for statement in statements:
|
| 1839 |
top_scoring_statements += f"- {statement}\n"
|
| 1840 |
top_scoring_statements += "\n"
|
| 1841 |
+
last_top_scoring_statements = top_scoring_statements # Save this for future use
|
| 1842 |
else:
|
| 1843 |
+
top_scoring_statements = "" # Don't include the top-scoring statements in subsequent messages
|
| 1844 |
|
| 1845 |
+
# Combine predefined prompt, top-scoring statements (only the first time), and user input
|
| 1846 |
+
combined_prompt = top_scoring_statements # Include top-scoring statements only once
|
| 1847 |
combined_prompt += "\n\nUser Input:\n" + message
|
| 1848 |
trust_tip, suggestion = get_trust_tip_and_suggestion()
|
| 1849 |
trust_tip_and_suggestion = f"\n\n---\n\n**Trust Tip**: {trust_tip}\n\n**Suggestion**: {suggestion}"
|
|
|
|
| 1871 |
|
| 1872 |
# Prepare the final response
|
| 1873 |
response = f"**Selected Dataset: {selected_dataset_ai}**\n\n"
|
| 1874 |
+
# Only include top-scoring statements once
|
| 1875 |
+
if top_scoring_statements:
|
| 1876 |
+
response += f"{top_scoring_statements}\n"
|
| 1877 |
response += f"\n{agent_output['output']}"
|
| 1878 |
response += trust_tip_and_suggestion
|
| 1879 |
|
|
|
|
| 1893 |
logger.error(f"Unexpected error: {e}")
|
| 1894 |
return "Error occurred during response generation."
|
| 1895 |
|
| 1896 |
+
|
| 1897 |
# def chatbot_response(message, history):
|
| 1898 |
# """
|
| 1899 |
# Generate chatbot response dynamically using selected dataset, user input, and maintaining history.
|