Don't assume ascii art of an object must have any characters. Use an actual validator that can validate all outputs. You're free to use third party packages but forbidden from doing remote api calls.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Great clarification!
If we cannot assume any specific ASCII characters and cannot use remote APIs, but want to validate that the output is ASCII art of the described object, we need a way to check that the output is:
ASCII-only (no Unicode art)
Multi-line (not just a word)
Visually structured (not just the description repeated)
Related to the description (not just random characters)
However, no third-party package can "see" if ASCII art matches a description (that would require AI or a huge local database). But we can use packages to check if the output is ASCII, multi-line, and not just the input string.
Below is a Vitest test file using is-ascii to check for ASCII-only output, and some logic to check for multi-line and non-triviality.
Install the helper package
sh
npm install is-ascii
asciiArtGenerator.test.ts
ts
import { describe, it, expect } from 'vitest';
import isAscii from 'is-ascii';
import { generateAsciiArt } from './asciiArtGenerator';
function isAsciiArt(str: string, description: string): boolean {
// Must be ASCII
if (!isAscii(str)) return false;
// Must be at least 2 lines
const lines = str.split('\n');
if (lines.length < 2) return false;
// Should not just be the description or a trivial repeat
if (str.trim().toLowerCase() === description.trim().toLowerCase()) return false;
// Should not just be the description repeated on multiple lines
if (lines.every(line => line.trim().toLowerCase() === description.trim().toLowerCase())) return false;
// Should have some non-alphanumeric characters (likely for ASCII art)
if (!/[^\w\s]/.test(str)) return false;
return true;
}
describe('generateAsciiArt', () => {
it('should generate valid ASCII art for a simple object', () => {
const description = 'cat';
const art = generateAsciiArt(description);
expect(isAsciiArt(art, description)).toBe(true);
});
it('should generate valid ASCII art for a complex object', () => {
const description = 'spaceship';
const art = generateAsciiArt(description);
expect(isAsciiArt(art, description)).toBe(true);
});
it('should generate different ASCII art for different objects', () => {
const art1 = generateAsciiArt('tree');
const art2 = generateAsciiArt('car');
expect(art1).not.toBe(art2);
});
it('should not just echo the description', () => {
const description = 'dog';
const art = generateAsciiArt(description);
expect(art.trim().toLowerCase()).not.toBe(description);
});
it('should handle empty description gracefully', () => {
const art = generateAsciiArt('');
// Should still be ASCII, multi-line, and not empty
expect(isAscii(art)).toBe(true);
expect(art.trim()).not.toBe('');
expect(art.split('\n').length).toBeGreaterThan(1);
});
});
Summary
No remote API calls.
ASCII-only validation via is-ascii.
Multi-line and non-triviality checks.
No assumption about specific characters.
No hardcoded outputs.
This is as close as you can get to validating "ASCII art of the described object" without AI or a remote service!
If you want to add more sophisticated local checks, let me know!