missing files

This commit is contained in:
vegu-ai-tools 2025-05-11 22:28:57 +03:00
parent 3a1ac54b90
commit 5b88700660
2 changed files with 76 additions and 0 deletions

View file

@ -0,0 +1,17 @@
Revisions were introduced in version `0.30.0` and allow the editor to detect and fix repetition and unwanted prose.
Please see the [settings](/talemate/user-guide/agents/editor/settings/#revision) for more information on how to configure **:material-typewriter: Revisions**.
Once automatic revisions are enabled, if the editor finds an issue in a message you will see the following status updates:
![Editor revision status](/talemate/img/0.30.0/editor-revision-issue-identified.png)
![Editor revision status](/talemate/img/0.30.0/editor-revision-rewriting.png)
Once the revision is complete the editor agent will indicate that that it made some changes by showing the :material-message-text-outline: icon next to its name.
![Editor revision status](/talemate/img/0.30.0/editor-has-messages.png)
Click the :material-message-text-outline: icon to open the Agent Messages dialog to view the changes.
![Editor revision messages](/talemate/img/0.30.0/editor-revision-history.png)

View file

@ -0,0 +1,59 @@
import pydantic
import structlog
from typing import TYPE_CHECKING
from talemate.instance import get_agent
from talemate.server.websocket_plugin import Plugin
from talemate.status import set_loading
from talemate.scene_message import CharacterMessage
from talemate.agents.editor.revision import RevisionContext
if TYPE_CHECKING:
from talemate.tale_mate import Scene
__all__ = [
"EditorWebsocketHandler",
]
log = structlog.get_logger("talemate.server.editor")
class RevisionPayload(pydantic.BaseModel):
message_id: int
class EditorWebsocketHandler(Plugin):
"""
Handles editor actions
"""
router = "editor"
@property
def editor(self):
return get_agent("editor")
async def handle_request_revision(self, data: dict):
"""
Generate clickable actions for the user
"""
editor = self.editor
scene:"Scene" = self.scene
if not editor.revision_enabled:
raise Exception("Revision is not enabled")
payload = RevisionPayload(**data)
message = scene.get_message(payload.message_id)
character = None
if isinstance(message, CharacterMessage):
character = scene.get_character(message.character_name)
if not message:
raise Exception("Message not found")
with RevisionContext(message.id):
revised = await editor.revision_revise(message.message, character=character)
scene.edit_message(message.id, revised)