You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add checks for empty completions in sampling methods
Added explicit checks to ensure that valid completions are generated in both best_of_n_sampling and mixture_of_agents functions. If no completions are available, the functions now raise exceptions or return error messages, improving robustness against provider failures.
return"Error: Could not generate any completions", 0
78
82
79
83
logger.info(f"Generated {len(completions)} completions using fallback method. Total tokens used: {bon_completion_tokens}")
80
-
84
+
85
+
# Double-check we have completions before rating
86
+
ifnotcompletions:
87
+
logger.error("No completions available for rating")
88
+
return"Error: Could not generate any completions", bon_completion_tokens
89
+
81
90
# Rate the completions
82
91
rating_messages=messages.copy()
83
92
rating_messages.append({"role": "system", "content": "Rate the following responses on a scale from 0 to 10, where 0 is poor and 10 is excellent. Consider factors such as relevance, coherence, and helpfulness. Respond with only a number."})
0 commit comments