merethom commited on
Commit
0c1ac7c
·
verified ·
1 Parent(s): b272ad2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -22,18 +22,23 @@ def respond(
22
  temperature,
23
  top_p,
24
  ):
25
- # First, attempt to find a response in the dataset
26
- closest_match = None
27
- for entry in dataset:
28
- if message.lower() in entry["question"].lower(): # Adjust "question" to the actual column name
29
- closest_match = entry["answer"] # Adjust "answer" to the actual column name
30
- break
 
31
 
32
- # If a match is found, return the dataset answer
33
- if closest_match:
34
- return closest_match
35
 
36
- # If no match is found, use the chatbot model
 
 
 
 
37
  messages = [{"role": "system", "content": system_message}]
38
 
39
  for val in history:
 
22
  temperature,
23
  top_p,
24
  ):
25
+ # Attempt to find a response in the dataset
26
+ try:
27
+ closest_match = None
28
+ for entry in dataset:
29
+ if message.lower() in entry["question"].lower(): # Adjust based on actual column names
30
+ closest_match = entry["answer"] # Adjust based on actual column names
31
+ break
32
 
33
+ # If a match is found, return the dataset answer
34
+ if closest_match:
35
+ return closest_match
36
 
37
+ except Exception as e:
38
+ # Log errors during dataset querying
39
+ print(f"Dataset Query Error: {e}")
40
+
41
+ # If no match is found, or there's an error, fall back to chatbot model
42
  messages = [{"role": "system", "content": system_message}]
43
 
44
  for val in history: