Spaces:
Sleeping
Sleeping
Commit
·
93b3dfc
1
Parent(s):
57ca96a
Oracle weight assigning update
Browse files- Oracle/deepfundingoracle.py +15 -3
Oracle/deepfundingoracle.py
CHANGED
@@ -231,6 +231,8 @@ def timeout_handler(signum, frame):
|
|
231 |
# logging.info(f"[INFO] Base weights assigned successfully in {end_time - start_time:.2f} seconds.")
|
232 |
# return df
|
233 |
|
|
|
|
|
234 |
def assign_base_weight(df, max_workers=32):
|
235 |
"""
|
236 |
Assign base weights using a single LLM call to determine feature weights,
|
@@ -257,12 +259,22 @@ def assign_base_weight(df, max_workers=32):
|
|
257 |
)
|
258 |
try:
|
259 |
response = llama.predict(prompt)
|
260 |
-
feature_weights =
|
261 |
print(f"[INFO] Feature weights from LLM: {feature_weights}", flush=True)
|
262 |
-
except Exception as e:
|
263 |
print(f"[ERROR] Failed to fetch feature weights from LLM: {e}", flush=True)
|
264 |
logging.error(f"[ERROR] Failed to fetch feature weights from LLM: {e}")
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
# Step 2: Programmatically calculate weights for each repository
|
268 |
def calculate_weight(row):
|
|
|
231 |
# logging.info(f"[INFO] Base weights assigned successfully in {end_time - start_time:.2f} seconds.")
|
232 |
# return df
|
233 |
|
234 |
+
import json
|
235 |
+
|
236 |
def assign_base_weight(df, max_workers=32):
|
237 |
"""
|
238 |
Assign base weights using a single LLM call to determine feature weights,
|
|
|
259 |
)
|
260 |
try:
|
261 |
response = llama.predict(prompt)
|
262 |
+
feature_weights = json.loads(response) # Safely parse JSON
|
263 |
print(f"[INFO] Feature weights from LLM: {feature_weights}", flush=True)
|
264 |
+
except (json.JSONDecodeError, Exception) as e:
|
265 |
print(f"[ERROR] Failed to fetch feature weights from LLM: {e}", flush=True)
|
266 |
logging.error(f"[ERROR] Failed to fetch feature weights from LLM: {e}")
|
267 |
+
# Fallback to default weights
|
268 |
+
feature_weights = {
|
269 |
+
"stars": 0.3,
|
270 |
+
"forks": 0.2,
|
271 |
+
"watchers": 0.2,
|
272 |
+
"open_issues": 0.1,
|
273 |
+
"pulls": 0.1,
|
274 |
+
"activity": 0.05,
|
275 |
+
"contributors": 0.05
|
276 |
+
}
|
277 |
+
print(f"[INFO] Using default feature weights: {feature_weights}", flush=True)
|
278 |
|
279 |
# Step 2: Programmatically calculate weights for each repository
|
280 |
def calculate_weight(row):
|