mirror of
https://github.com/vegu-ai/talemate.git
synced 2025-09-01 18:09:08 +00:00
missing files
This commit is contained in:
parent
3a1ac54b90
commit
5b88700660
2 changed files with 76 additions and 0 deletions
17
docs/user-guide/agents/editor/revisions.md
Normal file
17
docs/user-guide/agents/editor/revisions.md
Normal 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:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Click the :material-message-text-outline: icon to open the Agent Messages dialog to view the changes.
|
||||||
|
|
||||||
|

|
59
src/talemate/agents/editor/websocket_handler.py
Normal file
59
src/talemate/agents/editor/websocket_handler.py
Normal 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)
|
Loading…
Add table
Reference in a new issue