Skip to content

Commit f7f58cf

Browse files
rgambeegithub-actions[bot]
authored andcommitted
Simple heuristic for forecast effort level (#5510)
If you're forecasting a single question, default to HIGH effort. Otherwise, default to LOW effort. The user can still specify which effort level they want: we don't override that. We can consider more intelligent heuristics in the future. But this seems like a good 80:20 solution to me. I chose to do this behind the API. That means SDK users also get the benefit of it. And it's more reliable than prompt-engineering Claude to pick correctly. Claude is aware of the logic though. Sourced from commit 4001c869222fde8da4aae7a2ee91a97d13011c35
1 parent b250a57 commit f7f58cf

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

futuresearch-mcp/src/futuresearch_mcp/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,9 @@ class ForecastInput(_SingleSourceInput):
423423
)
424424
effort_level: ForecastEffortLevel | None = Field(
425425
default=None,
426-
description="Affects accuracy and cost of forecast. Default: low.",
426+
description="Effort level for the forecast. 'LOW' tends to be faster and cheaper. "
427+
"'HIGH' tends to be more accurate. When not specified, defaults to 'HIGH' for "
428+
"single-question forecasts and 'LOW' for multi-question forecasts.",
427429
)
428430
output_field: str | None = Field(
429431
default=None,

src/futuresearch/generated/models/forecast_operation.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class ForecastOperation:
3535
when forecast_type is 'numeric'. Output columns will be named {output_field}_p10 through {output_field}_p90.
3636
units (None | str | Unset): Units for the numeric forecast (e.g. 'USD per barrel', 'thousands'). Required when
3737
forecast_type is 'numeric'.
38-
effort_level (ForecastEffortLevel | Unset):
38+
effort_level (ForecastEffortLevel | None | Unset): Effort level for the forecast. 'LOW' tends to be faster and
39+
cheaper. 'HIGH' tends to be more accurate. When not specified, defaults to 'HIGH' for single-question forecasts
40+
and 'LOW' for multi-question forecasts.
3941
"""
4042

4143
input_: ForecastOperationInputType2 | list[ForecastOperationInputType1Item] | UUID
@@ -45,7 +47,7 @@ class ForecastOperation:
4547
webhook_url: None | str | Unset = UNSET
4648
output_field: None | str | Unset = UNSET
4749
units: None | str | Unset = UNSET
48-
effort_level: ForecastEffortLevel | Unset = UNSET
50+
effort_level: ForecastEffortLevel | None | Unset = UNSET
4951
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
5052

5153
def to_dict(self) -> dict[str, Any]:
@@ -91,9 +93,13 @@ def to_dict(self) -> dict[str, Any]:
9193
else:
9294
units = self.units
9395

94-
effort_level: str | Unset = UNSET
95-
if not isinstance(self.effort_level, Unset):
96+
effort_level: None | str | Unset
97+
if isinstance(self.effort_level, Unset):
98+
effort_level = UNSET
99+
elif isinstance(self.effort_level, ForecastEffortLevel):
96100
effort_level = self.effort_level.value
101+
else:
102+
effort_level = self.effort_level
97103

98104
field_dict: dict[str, Any] = {}
99105
field_dict.update(self.additional_properties)
@@ -202,12 +208,22 @@ def _parse_units(data: object) -> None | str | Unset:
202208

203209
units = _parse_units(d.pop("units", UNSET))
204210

205-
_effort_level = d.pop("effort_level", UNSET)
206-
effort_level: ForecastEffortLevel | Unset
207-
if isinstance(_effort_level, Unset):
208-
effort_level = UNSET
209-
else:
210-
effort_level = ForecastEffortLevel(_effort_level)
211+
def _parse_effort_level(data: object) -> ForecastEffortLevel | None | Unset:
212+
if data is None:
213+
return data
214+
if isinstance(data, Unset):
215+
return data
216+
try:
217+
if not isinstance(data, str):
218+
raise TypeError()
219+
effort_level_type_0 = ForecastEffortLevel(data)
220+
221+
return effort_level_type_0
222+
except (TypeError, ValueError, AttributeError, KeyError):
223+
pass
224+
return cast(ForecastEffortLevel | None | Unset, data)
225+
226+
effort_level = _parse_effort_level(d.pop("effort_level", UNSET))
211227

212228
forecast_operation = cls(
213229
input_=input_,

0 commit comments

Comments
 (0)