fill.ts 493 B

123456789101112131415161718192021222324
  1. import ollama, { Message } from 'ollama'
  2. async function main(): Promise<void> {
  3. const prefix = `def remove_non_ascii(s: str) -> str:
  4. """
  5. `
  6. const suffix = `
  7. return result
  8. `
  9. const response = await ollama.generate({
  10. model: 'codellama:7b-code',
  11. prompt: `<PRE> ${prefix} <SUF>${suffix} <MID>`,
  12. options: {
  13. num_predict: 128,
  14. temperature: 0,
  15. top_p: 0.9,
  16. presence_penalty: 0,
  17. stop: ['<EOT>'],
  18. },
  19. })
  20. console.log(respose.response)
  21. }
  22. await main()