Spaces:
Runtime error
Runtime error
Commit
·
ebd1014
1
Parent(s):
eb52977
Update app.py
Browse files
app.py
CHANGED
@@ -86,35 +86,36 @@ def distance_to_similarity(distances, temp=1e-4):
|
|
86 |
def calculate_rewards(subscription, num_generations, author_share, ro_share, num_users_k, similarities, num_authors=1800):
|
87 |
"""Calculate rewards based on user inputs and similarities"""
|
88 |
num_users = num_users_k * 1000
|
89 |
-
|
90 |
# Monthly revenue allocated to authors
|
91 |
authors_monthly_revenue = subscription * num_users * (author_share / 100)
|
92 |
-
|
93 |
rewards = []
|
94 |
for sim in similarities[0]:
|
95 |
-
# Attribution bonus based on similarity score (sim) and number of neighbors
|
96 |
attribution_bonus = sim * len(similarities[0])
|
97 |
-
|
98 |
# Calculate monthly rewards
|
99 |
author_month_reward = (authors_monthly_revenue / num_authors) * attribution_bonus
|
100 |
ro_month_reward = author_month_reward / (author_share / 100) * (ro_share / 100)
|
101 |
-
|
102 |
try:
|
103 |
-
|
104 |
except Exception as e:
|
105 |
-
|
106 |
-
|
107 |
|
108 |
rewards.append({
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
})
|
115 |
|
116 |
return rewards
|
117 |
|
|
|
118 |
# Global variables for model and index
|
119 |
model = None
|
120 |
index = None
|
|
|
86 |
def calculate_rewards(subscription, num_generations, author_share, ro_share, num_users_k, similarities, num_authors=1800):
|
87 |
"""Calculate rewards based on user inputs and similarities"""
|
88 |
num_users = num_users_k * 1000
|
89 |
+
|
90 |
# Monthly revenue allocated to authors
|
91 |
authors_monthly_revenue = subscription * num_users * (author_share / 100)
|
92 |
+
|
93 |
rewards = []
|
94 |
for sim in similarities[0]:
|
95 |
+
# Attribution bonus based on similarity score (sim) and number of neighbors
|
96 |
attribution_bonus = sim * len(similarities[0])
|
97 |
+
|
98 |
# Calculate monthly rewards
|
99 |
author_month_reward = (authors_monthly_revenue / num_authors) * attribution_bonus
|
100 |
ro_month_reward = author_month_reward / (author_share / 100) * (ro_share / 100)
|
101 |
+
|
102 |
try:
|
103 |
+
sim_value = float(sim.item()) if hasattr(sim, "item") else float(sim)
|
104 |
except Exception as e:
|
105 |
+
print("Erreur de conversion de sim:", e)
|
106 |
+
sim_value = 0.0 # valeur par défaut en cas d'erreur
|
107 |
|
108 |
rewards.append({
|
109 |
+
'paid_per_month': f"{subscription:.0f}€",
|
110 |
+
'attribution': f"{sim * 100:.0f}%",
|
111 |
+
'author_month_reward': f"{author_month_reward:.0f}€",
|
112 |
+
'ro_month_reward': f"{ro_month_reward:.0f}€",
|
113 |
+
'raw_similarity': sim_value
|
114 |
+
})
|
115 |
|
116 |
return rewards
|
117 |
|
118 |
+
|
119 |
# Global variables for model and index
|
120 |
model = None
|
121 |
index = None
|