mirror of
https://github.com/vegu-ai/talemate.git
synced 2025-12-16 11:47:48 +01:00
* some prompt cleanup * prompt tweaks * prompt tweaks * prompt tweaks * set 0.31.0 * relock * rag queries add brief analysis * brief analysis before building rag questions * rag improvements * prompt tweaks * address circular import issues * set 0.30.1 * docs * numpy to 2 * docs * prompt tweaks * prompt tweak * some template cleanup * prompt viewer increase height * fix codemirror highlighting not working * adjust details height * update default * change to log debug * allow response to scale to max height * template cleanup * prompt tweaks * first progress for installing modules to scene * package install logic * package install polish * package install polish * package install polish and fixes * refactor initial world state update and expose setting for it * add `num` property to ModuleProperty to control order of widgets * dynamic storyline package info * fix issue where deactivating player character would cause inconsistencies in the creative tools menui * cruft * add openrouter support * ollama support * refactor how model choices are loaded, so that can be done per client instance as opposed to just per client type * set num_ctx * remove debug messages * ollama tweaks * toggle for whether or not default character gets added to blank talemate scenes * narrator prompt tweaks and template cleanup * cleanup * prompt tweaks and template cleanup * prompt tweaks * fix instructor embeddings * add additional error handling to prevent broken world state templates from breaking the world editor side menu * fix openrouter breaking startup if not configured * remove debug message * promp tweaks * fix example dialogue generation no longer working * prompt tweaks and better showing of dialogue examples in conversation instructions * prompt tweak * add initial startup message * prompt tweaks * fix asset error * move complex acting instructions into the task block * fix content input socket on DynamicInstructions node * log.error with traceback over log.exception since that has a tendency to explode and hang everything * fix usse with number nodes where they would try to execute even if the incoming wire wasnt active * fix issue with editor revision events missing template_vars * DynamicInstruction node should only run if both header and content can resolve * removed remaining references to 90s adventure game writing style * prompt tweaks * support embeddings via client apis (koboldcpp) * fix label on client-api embeddings * fix issue where adding / removing an embedding preset would not be reflected immediately in the memory agent config * remove debug output * prompt tweaks * prompt tweaks * autocomplete passes message object * validate group names to be filename valid * embedded winsows env installs and up to poetry2 * version config * get-pip * relock * pin runpod * no longer needed * remove rapidfuzz dependency * nodejs directly into embedded_node without a versioned middleman dir - also remove defunct local-tts install script * fix update script * update script error handling * update.bat error handling * adjust wording * support loading jinja2 templates node modules in templates/modules * update google model list * client t/s and business indicator - also switch all clients to async streaming * formatting * support coercion for anthropic / google switch to the new google genai sdk upgrade websockets * more coercion fixes * gracefully handle keyboard interrupt * EmitSystemMessage node * allow visual prompt generation without image generation * relock * chromadb to v1 * fix error handling * fix issue where adding client model list would be empty * supress pip install warnings * allow overriding of base urls * remove key from log * add fade effect * tweak request info ux * further clarification of endpoint override api key * world state manager: fix issue that caused max changes setting to disappear from character progress config * fix issue with google safety settings off causing generation failures * update to base url should always reset the client * getattr * support v3 chara card version and attempt to future proof * client based embeddings improvements * more fixes for client based embeddings * use client icon * history management tools progress * history memory ids fixed and added validation * regenerate summary fixes * more history regeneration fixes * fix layered history gen and prompt twweaks * allow regeneration of individual layered history entries * return list of LayeredArchiveEntry * reorg for less code dupelication * new scene message renderer based on marked * add inspect functionality to history viewer * message if no history entries yet * allow adding of history entries manually * allow deletion of history * summarization unslop improvements * fix make charcter real action from worldstate listing * allow overriding length in all context generation isntructioon dialogs * fix issue where extract_list could fail with an unhandled error if the llm response didnt contain a list * update whats'new * fix issues with the new history management tools * fix check * Switch dependency handling to UV (#202) * Migrate from Poetry to uv package manager (#200) * migrate from poetry to uv package manager * Update all installation and startup scripts for uv migration * Fix pyproject.toml for uv - allow direct references for hatchling * Fix PR feedback: Restore removed functionality - Restored embedded Python/Node.js functionality in install.bat and update.bat - Restored environment variable exposure in docker-compose.yml (CUDA_AVAILABLE, port configs) - Fixed GitHub Actions branches (main, prep-* instead of main, dev) - Restored fail-fast: false and cache configuration in test.yml These changes preserve all the functionality that should not be removed during the migration from Poetry to uv. --------- Co-authored-by: Ztripez von Matérn <ztripez@bobby.se> * remove uv.lock from .gitignore * add lock file * fix install issues * warn if unable to remove legacy poetry virt env dir * uv needs to be explicitly installed into the .venv so its available * third time's the charm? * fix windows install scripts * add .venv guard to update.bat * call :die * fix docker venv install * node 21 * fix cuda install * start.bat calls install if needed * sync start-local to other startup scripts * no need to activate venv --------- Co-authored-by: Ztripez <reg@otherland.nu> Co-authored-by: Ztripez von Matérn <ztripez@bobby.se> * ignore hfhub symlink warnings * add openrouter and ollama mentions * update windows install documentation * docs * docs * fix issue with memory agent fingerprint * removing a client that supports embeddings will also remove any embedding functions it created * on invalid embeddings reset to default * docs * typo * formatting * docs * docs * install package * adjust topic * add more obvious way to exit creative mode * when importing character cards immediately persist a usable save after the restoration save --------- Co-authored-by: Ztripez <reg@otherland.nu> Co-authored-by: Ztripez von Matérn <ztripez@bobby.se>
134 lines
3.5 KiB
Python
134 lines
3.5 KiB
Python
import pytest
|
||
import types
|
||
|
||
from talemate.history import shift_scene_timeline
|
||
from talemate.util import iso8601_add
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Fixtures
|
||
# ---------------------------------------------------------------------------
|
||
|
||
|
||
@pytest.fixture()
|
||
def dummy_scene():
|
||
"""Return a minimal Scene-like object whose attributes can be adjusted by
|
||
individual tests. The fixture yields a *factory* so each test can create
|
||
its own independent instance without repeating boilerplate."""
|
||
|
||
def _factory(ts: str = "PT0S", archived=None, layered=None):
|
||
scene = types.SimpleNamespace()
|
||
scene.ts = ts
|
||
scene.archived_history = archived or []
|
||
scene.layered_history = layered or []
|
||
return scene
|
||
|
||
return _factory
|
||
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Tests
|
||
# ---------------------------------------------------------------------------
|
||
|
||
|
||
@pytest.mark.parametrize(
|
||
"initial_ts, archived_tss, layered_tss, shift_iso, expected_scene_ts, expected_archived_ts, expected_layered_ts",
|
||
[
|
||
# Hours / minutes
|
||
(
|
||
"PT2H", # initial
|
||
["PT1H", "PT90M"],
|
||
["PT30M"],
|
||
"PT1H", # +1 hour
|
||
"PT3H",
|
||
["PT2H", "PT2H30M"],
|
||
["PT1H30M"],
|
||
),
|
||
(
|
||
"PT2H",
|
||
["PT1H", "PT90M"],
|
||
["PT30M"],
|
||
"-PT30M", # -30 minutes
|
||
"PT1H30M",
|
||
["PT30M", "PT1H"],
|
||
["P0D"], # zero becomes P0D
|
||
),
|
||
# Months
|
||
(
|
||
"P2M",
|
||
["P1M", "P6M"],
|
||
["P3M"],
|
||
"P1M", # +1 month
|
||
"P3M",
|
||
["P2M", "P7M"],
|
||
["P4M"],
|
||
),
|
||
# Years
|
||
(
|
||
"P3Y",
|
||
["P1Y", "P2Y"],
|
||
["P6M"],
|
||
"-P1Y", # -1 year
|
||
"P2Y",
|
||
["P0D", "P1Y"],
|
||
["P0D"], # clamped to zero
|
||
),
|
||
# Huge shift – 1000 years
|
||
(
|
||
"P0D",
|
||
["P1Y"],
|
||
["P2Y"],
|
||
"P1000Y",
|
||
"P1000Y",
|
||
["P1001Y"],
|
||
["P1002Y"],
|
||
),
|
||
],
|
||
ids=[
|
||
"hour_plus", "hour_minus", "month_plus", "year_minus", "millennia_plus"
|
||
],
|
||
)
|
||
def test_shift_scene_timeline_basic(
|
||
dummy_scene,
|
||
initial_ts,
|
||
archived_tss,
|
||
layered_tss,
|
||
shift_iso,
|
||
expected_scene_ts,
|
||
expected_archived_ts,
|
||
expected_layered_ts,
|
||
):
|
||
"""Parametrised test verifying various time-unit shifts."""
|
||
|
||
archived = [{"ts": ts} for ts in archived_tss]
|
||
layered = [[{"ts": ts} for ts in layered_tss]]
|
||
|
||
scene = dummy_scene(initial_ts, archived, layered)
|
||
|
||
shift_scene_timeline(scene, shift_iso)
|
||
|
||
assert scene.ts == expected_scene_ts
|
||
assert [e["ts"] for e in scene.archived_history] == expected_archived_ts
|
||
assert [e["ts"] for e in scene.layered_history[0]] == expected_layered_ts
|
||
|
||
|
||
def test_shift_scene_timeline_noop(dummy_scene):
|
||
"""A shift of PT0S (and variants) should not mutate the scene."""
|
||
|
||
scene = dummy_scene(
|
||
"PT0S",
|
||
archived=[{"ts": "PT1H", "ts_start": "PT30M", "ts_end": "PT90M"}],
|
||
layered=[[{"ts": "PT15M"}]],
|
||
)
|
||
|
||
import copy
|
||
pre_state = (
|
||
scene.ts,
|
||
copy.deepcopy(scene.archived_history),
|
||
copy.deepcopy(scene.layered_history),
|
||
)
|
||
|
||
shift_scene_timeline(scene, "PT0S")
|
||
|
||
assert scene.ts == pre_state[0]
|
||
assert scene.archived_history == pre_state[1]
|
||
assert scene.layered_history == pre_state[2] |