MCPcopy Create free account
hub / github.com/anus-dev/ANUS / validateHistory

Function validateHistory

packages/core/src/core/anusChat.ts:63–69  ·  view source on GitHub ↗

* Validates the history contains the correct roles. * * @throws Error if the history does not start with a user turn. * @throws Error if the history contains an invalid role.

(history: Content[])

Source from the content-addressed store, hash-verified

61 * @throws Error if the history contains an invalid role.
62 */
63function validateHistory(history: Content[]) {
64 for (const content of history) {
65 if (content.role !== 'user' && content.role !== 'model') {
66 throw new Error(`Role must be user or model, but got ${content.role}.`);
67 }
68 }
69}
70
71/**
72 * Extracts the curated (valid) history from a comprehensive history.

Callers 1

constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected