v0.2.0
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
const Perry = require("..");
|
||||
|
||||
test("Perry requires explicit provider and model settings", () => {
|
||||
assert.throws(() => Perry(), /settings are required/);
|
||||
assert.throws(() => Perry({ model: "gemma" }), /'provider' is required/);
|
||||
assert.throws(() => Perry({ provider: "lm-studio" }), /'model' is required/);
|
||||
assert.throws(() => Perry({ provider: "ollama", model: "gemma" }), /Unsupported LLM provider/);
|
||||
});
|
||||
|
||||
test("Perry is a lightweight independently configured instance", () => {
|
||||
const first = Perry({ provider: "lm-studio", model: "model-a" });
|
||||
const second = Perry({ provider: "lm-studio", model: "model-b" });
|
||||
|
||||
assert.equal(first.model(), "model-a");
|
||||
assert.equal(second.model(), "model-b");
|
||||
});
|
||||
|
||||
test("prepare assembles Perry-shaped conversation history", () => {
|
||||
const perry = Perry({ provider: "lm-studio", model: "model-a" });
|
||||
const agent = perry.prepare("Perry", "system", [{
|
||||
messages: [
|
||||
{ role: "user", content: "hello", providerSpecificThing: "discard me" },
|
||||
{ role: "assistant", content: "hi", reasoning: "private" }
|
||||
]
|
||||
}]);
|
||||
|
||||
assert.equal(agent.name, "Perry");
|
||||
assert.deepEqual(agent.conversation, {
|
||||
systemPrompt: "system",
|
||||
messages: [
|
||||
{ role: "user", content: "hello" },
|
||||
{ role: "assistant", content: "hi" }
|
||||
],
|
||||
add: agent.conversation.add
|
||||
});
|
||||
});
|
||||
|
||||
test("cleanText converts common LLM presentation markup without understanding project structure", () => {
|
||||
assert.equal(Perry.cleanText(String.raw`$\text{He}$ ($\text{ה}$)`), "He (ה)");
|
||||
assert.equal(Perry.cleanText(String.raw`left \rightarrow right`), "left → right");
|
||||
assert.equal(Perry.cleanText(String.raw`\textbf{bold} and \textit{italic}`), "**bold** and //italic//");
|
||||
assert.equal(Perry.cleanText("__bold__ and *italic*"), "**bold** and //italic//");
|
||||
assert.equal(Perry.cleanText(String.raw`unknown \mystery{thing}`), String.raw`unknown \mystery{thing}`);
|
||||
});
|
||||
Reference in New Issue
Block a user