character-generator.ts 1.5 KB

1234567891011121314151617181920212223242526
  1. import { Ollama } from 'ollama-node'
  2. import fs from 'fs';
  3. import path from 'path';
  4. async function characterGenerator() {
  5. const character = process.argv[2];
  6. console.log(`You are creating a character for ${character}.`);
  7. const foldername = character.replace(/\s/g, '').toLowerCase();
  8. const directory = path.join(__dirname, foldername);
  9. if (!fs.existsSync(directory)) {
  10. fs.mkdirSync(directory, { recursive: true });
  11. }
  12. const ollama = new Ollama();
  13. ollama.setModel("stablebeluga2:70b-q4_K_M");
  14. const bio = await ollama.generate(`create a bio of ${character} in a single long paragraph. Instead of saying '${character} is...' or '${character} was...' use language like 'You are...' or 'You were...'. Then create a paragraph describing the speaking mannerisms and style of ${character}. Don't include anything about how ${character} looked or what they sounded like, just focus on the words they said. Instead of saying '${character} would say...' use language like 'You should say...'. If you use quotes, always use single quotes instead of double quotes. If there are any specific words or phrases you used a lot, show how you used them. `);
  15. const thecontents = `FROM llama2\nSYSTEM """\n${bio.response.replace(/(\r\n|\n|\r)/gm, " ").replace('would', 'should')} All answers to questions should be related back to what you are most known for.\n"""`;
  16. fs.writeFile(path.join(directory, 'Modelfile'), thecontents, (err: any) => {
  17. if (err) throw err;
  18. console.log('The file has been saved!');
  19. });
  20. }
  21. characterGenerator();