-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
* updated docs * adding a few tests
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
"gptoolsjs", | ||
"llmrequest", | ||
"localai", | ||
"mardownify", | ||
"millis", | ||
"ollama", | ||
"openai", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { describe, beforeEach, test } from "node:test" | ||
import assert from "node:assert/strict" | ||
import { createParsers } from "./parsers" | ||
import { MarkdownTrace } from "./trace" | ||
|
||
describe("parsers", () => { | ||
let trace: MarkdownTrace | ||
let model: string | ||
let parsers: ReturnType<typeof createParsers> | ||
|
||
beforeEach(() => { | ||
trace = new MarkdownTrace() | ||
model = "test model" | ||
parsers = createParsers({ trace, model }) | ||
}) | ||
|
||
test("JSON5", () => { | ||
const result = parsers.JSON5('{"key": "value"}') | ||
assert.deepStrictEqual(result, { key: "value" }) | ||
}) | ||
|
||
test("YAML", () => { | ||
const result = parsers.YAML("key: value") | ||
assert.deepStrictEqual(result, { key: "value" }) | ||
}) | ||
|
||
test("XML parser", () => { | ||
const result = parsers.XML("<key>value</key>") | ||
assert.deepStrictEqual(result, { key: "value" }) | ||
}) | ||
|
||
test("TOML", () => { | ||
const result = parsers.TOML('key = "value"') | ||
assert.equal(result.key, "value") | ||
}) | ||
|
||
test("frontmatter", () => { | ||
const result = parsers.frontmatter("---\nkey: value\n---\n") | ||
assert.deepStrictEqual(result, { key: "value" }) | ||
}) | ||
|
||
test("math", () => { | ||
const res = parsers.math("1 + 3") | ||
assert.strictEqual(res, 4) | ||
}) | ||
|
||
test("validateJSON", () => { | ||
const res = parsers.validateJSON( | ||
{ | ||
type: "object", | ||
properties: { | ||
key: { type: "string" }, | ||
}, | ||
required: ["key"], | ||
}, | ||
{ key: "value" } | ||
) | ||
assert.strictEqual(res.valid, true) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.