bstraehle commited on
Commit
12178fd
·
verified ·
1 Parent(s): e9f64ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -5,7 +5,7 @@ from custom_utils import connect_to_database, rag_ingestion, rag_retrieval, rag_
5
 
6
  lock = threading.Lock()
7
 
8
- RAG_INGESTION = True
9
 
10
  RAG_OFF = "Off"
11
  RAG_NAIVE = "Naive RAG"
@@ -64,48 +64,48 @@ def invoke(openai_api_key, prompt, rag_option):
64
  additional_stages = [projection_stage]
65
  """
66
  ###
67
- review_average_stage = {
68
- "$addFields": {
69
- "averageReviewScore": {
70
- "$divide": [
71
- {
72
- "$add": [
73
- "$review_scores.review_scores_accuracy",
74
- "$review_scores.review_scores_cleanliness",
75
- "$review_scores.review_scores_checkin",
76
- "$review_scores.review_scores_communication",
77
- "$review_scores.review_scores_location",
78
- "$review_scores.review_scores_value",
79
- ]
80
- },
81
- 6 # Divide by the number of review score types to get the average
82
- ]
83
- },
84
- # Calculate a score boost factor based on the number of reviews
85
- "reviewCountBoost": "$number_of_reviews"
86
- }
87
- }
88
 
89
- weighting_stage = {
90
- "$addFields": {
91
- "combinedScore": {
92
- # Example formula that combines average review score and review count boost
93
- "$add": [
94
- {"$multiply": ["$averageReviewScore", 0.9]}, # Weighted average review score
95
- {"$multiply": ["$reviewCountBoost", 0.1]} # Weighted review count boost
96
- ]
97
- }
98
- }
99
- }
100
 
101
  # Apply the combinedScore for sorting
102
- sorting_stage_sort = {
103
- "$sort": {"combinedScore": -1} # Descending order to boost higher combined scores
104
- }
105
 
106
- additional_stages = [review_average_stage, weighting_stage, sorting_stage_sort]
107
  ###
108
- #additional_stages = []
109
  ###
110
 
111
  search_results = rag_retrieval(openai_api_key, prompt, db, collection, additional_stages)
 
5
 
6
  lock = threading.Lock()
7
 
8
+ RAG_INGESTION = False
9
 
10
  RAG_OFF = "Off"
11
  RAG_NAIVE = "Naive RAG"
 
64
  additional_stages = [projection_stage]
65
  """
66
  ###
67
+ #review_average_stage = {
68
+ # "$addFields": {
69
+ # "averageReviewScore": {
70
+ # "$divide": [
71
+ # {
72
+ # "$add": [
73
+ # "$review_scores.review_scores_accuracy",
74
+ # "$review_scores.review_scores_cleanliness",
75
+ # "$review_scores.review_scores_checkin",
76
+ # "$review_scores.review_scores_communication",
77
+ # "$review_scores.review_scores_location",
78
+ # "$review_scores.review_scores_value",
79
+ # ]
80
+ # },
81
+ # 6 # Divide by the number of review score types to get the average
82
+ # ]
83
+ # },
84
+ # # Calculate a score boost factor based on the number of reviews
85
+ # "reviewCountBoost": "$number_of_reviews"
86
+ # }
87
+ #}
88
 
89
+ #weighting_stage = {
90
+ # "$addFields": {
91
+ # "combinedScore": {
92
+ # # Example formula that combines average review score and review count boost
93
+ # "$add": [
94
+ # {"$multiply": ["$averageReviewScore", 0.9]}, # Weighted average review score
95
+ # {"$multiply": ["$reviewCountBoost", 0.1]} # Weighted review count boost
96
+ # ]
97
+ # }
98
+ # }
99
+ #}
100
 
101
  # Apply the combinedScore for sorting
102
+ #sorting_stage_sort = {
103
+ # "$sort": {"combinedScore": -1} # Descending order to boost higher combined scores
104
+ #}
105
 
106
+ #additional_stages = [review_average_stage, weighting_stage, sorting_stage_sort]
107
  ###
108
+ additional_stages = []
109
  ###
110
 
111
  search_results = rag_retrieval(openai_api_key, prompt, db, collection, additional_stages)