mirror of
https://github.com/vegu-ai/talemate.git
synced 2026-09-01 19:48:52 +02:00
fiox regression with advance time no longer prompting for user guidance
This commit is contained in:
@@ -3,7 +3,6 @@ import pydantic
|
||||
from talemate.instance import get_agent
|
||||
from talemate.server.websocket_plugin import Plugin
|
||||
from talemate.status import set_loading
|
||||
from talemate.util.time import amount_unit_to_iso8601_duration
|
||||
|
||||
__all__ = [
|
||||
"WorldStateWebsocketHandler",
|
||||
@@ -19,24 +18,6 @@ class SummarizeAndPinPayload(pydantic.BaseModel):
|
||||
num_messages: int = 5
|
||||
|
||||
|
||||
class AdvanceTimePayload(pydantic.BaseModel):
|
||||
duration: str | None = None
|
||||
amount: int | None = None
|
||||
unit: str | None = None
|
||||
|
||||
@pydantic.model_validator(mode="after")
|
||||
def check_duration_or_amount_unit(self):
|
||||
if not self.duration and (self.amount is None or not self.unit):
|
||||
raise ValueError("Either 'duration' or 'amount' + 'unit' must be provided.")
|
||||
return self
|
||||
|
||||
@property
|
||||
def iso_duration(self) -> str:
|
||||
if self.duration:
|
||||
return self.duration
|
||||
return amount_unit_to_iso8601_duration(self.amount, self.unit)
|
||||
|
||||
|
||||
class WorldStateWebsocketHandler(Plugin):
|
||||
router = "world_state_agent"
|
||||
|
||||
@@ -66,9 +47,3 @@ class WorldStateWebsocketHandler(Plugin):
|
||||
message_id, num_messages=payload.num_messages
|
||||
)
|
||||
await self.signal_operation_done(allow_auto_save=False)
|
||||
|
||||
@set_loading("Advancing time", cancellable=True, as_async=True)
|
||||
async def handle_advance_time(self, data: dict):
|
||||
payload = AdvanceTimePayload(**data)
|
||||
await self.agent.advance_time(payload.iso_duration)
|
||||
await self.signal_operation_done()
|
||||
|
||||
@@ -139,13 +139,21 @@ export default {
|
||||
this.customTimeDialog = true;
|
||||
},
|
||||
|
||||
amountUnitToIso8601(amount, unit) {
|
||||
const n = Math.abs(amount);
|
||||
switch (unit) {
|
||||
case 'minutes': return `PT${n}M`;
|
||||
case 'hours': return `PT${n}H`;
|
||||
case 'days': return `P${n}D`;
|
||||
case 'weeks': return `P${n}W`;
|
||||
case 'months': return `P${n}M`;
|
||||
case 'years': return `P${n}Y`;
|
||||
default: throw new Error(`Invalid unit: ${unit}`);
|
||||
}
|
||||
},
|
||||
|
||||
submitCustomTime() {
|
||||
this.getWebsocket().send(JSON.stringify({
|
||||
type: 'world_state_agent',
|
||||
action: 'advance_time',
|
||||
amount: this.customTimeAmount,
|
||||
unit: this.customTimeUnit,
|
||||
}));
|
||||
this.advanceTime(this.amountUnitToIso8601(this.customTimeAmount, this.customTimeUnit));
|
||||
this.customTimeDialog = false;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user