mirror of
https://github.com/vegu-ai/talemate.git
synced 2025-09-17 01:19:44 +00:00
* cleanup * refactor clean_dialogue * prompt fixes * prompt fixes * conversation format types - movie script and chat (legacy) * stopping strings updated * mistral.ai client * prompt tweaks * mistral client return token counts * anthropic client * archive history emits whole object so we can inspectr time stamps * show timestamp in history dialog * openai compat fixes to stop trying to coerce openai url path schema and to never attempt to retrieve the model name automatically, hopefully improving compatibility with the various openai api implementations across the board * openai compat client let api control prompt template via config option * fix custom client configs and implement max backscroll * fix backscroll limit * remove debug message * prep 0.21.0 * include model name in prompt template selection label * use tabs for side nav in app config modal * readme / docs * fix issue where "No API key set" could be persisted as the selected model name to the config * deepinfra example * linting
40 lines
No EOL
2.5 KiB
Python
40 lines
No EOL
2.5 KiB
Python
import pytest
|
|
from talemate.util import ensure_dialog_format, clean_dialogue
|
|
|
|
@pytest.mark.parametrize("input, expected", [
|
|
('Hello how are you?', 'Hello how are you?'),
|
|
('"Hello how are you?"', '"Hello how are you?"'),
|
|
('"Hello how are you?" he asks "I am fine"', '"Hello how are you?" *he asks* "I am fine"'),
|
|
('Hello how are you? *he asks* I am fine', '"Hello how are you?" *he asks* "I am fine"'),
|
|
|
|
('Hello how are you?" *he asks* I am fine', '"Hello how are you?" *he asks* "I am fine"'),
|
|
('Hello how are you?" *he asks I am fine', '"Hello how are you?" *he asks I am fine*'),
|
|
('Hello how are you?" *he asks* "I am fine" *', '"Hello how are you?" *he asks* "I am fine"'),
|
|
|
|
('"Hello how are you *he asks* I am fine"', '"Hello how are you" *he asks* "I am fine"'),
|
|
('This is a string without any markers', 'This is a string without any markers'),
|
|
('This is a string with an ending quote"', '"This is a string with an ending quote"'),
|
|
('This is a string with an ending asterisk*', '*This is a string with an ending asterisk*'),
|
|
('"Mixed markers*', '*Mixed markers*'),
|
|
('*narrative.* dialogue" *more narrative.*', '*narrative.* "dialogue" *more narrative.*'),
|
|
('"*messed up dialogue formatting.*" *some narration.*', '"messed up dialogue formatting." *some narration.*'),
|
|
('*"messed up narration formatting."* "some dialogue."', '"messed up narration formatting." "some dialogue."'),
|
|
])
|
|
def test_dialogue_cleanup(input, expected):
|
|
assert ensure_dialog_format(input) == expected
|
|
|
|
|
|
@pytest.mark.parametrize("input, expected, main_name", [
|
|
("bob: says a sentence", "bob: says a sentence", "bob"),
|
|
("bob: says a sentence\nbob: says another sentence", "bob: says a sentence\nsays another sentence", "bob"),
|
|
("bob: says a sentence with a colon: to explain something", "bob: says a sentence with a colon: to explain something", "bob"),
|
|
("bob: i have a riddle for you, alice: the riddle", "bob: i have a riddle for you, alice: the riddle", "bob"),
|
|
("bob: says something\nalice: says something else", "bob: says something", "bob"),
|
|
("bob: says a sentence. then a", "bob: says a sentence.", "bob"),
|
|
("bob: first paragraph\n\nsecond paragraph", "bob: first paragraph\n\nsecond paragraph", "bob"),
|
|
# movie script new speaker cutoff
|
|
("bob: says a sentence\n\nALICE\nsays something else", "bob: says a sentence", "bob"),
|
|
])
|
|
def test_clean_dialogue(input, expected, main_name):
|
|
others = ["alice", "charlie"]
|
|
assert clean_dialogue(input, main_name) == expected |