ollama.js 773 B

123456789101112131415161718192021222324252627282930313233
  1. import { Ollama } from "ollama/browser";
  2. // const ollama = new Ollama({ host: 'http://192.168.9.61:11434' })
  3. const ollama = new Ollama({ host: 'http://192.168.0.25/answers' })
  4. export function chatWithHistory(model, userMsg, history, systemMsg) {
  5. return ollama.chat({
  6. model,
  7. messages: [
  8. { role: "system", content: systemMsg },
  9. ...history,
  10. { role: "user", content: userMsg },
  11. ],
  12. stream: true,
  13. });
  14. }
  15. export function chat(userMsg, systemMsg) {
  16. return ollama.chat({
  17. model: 'deepseek-r1:70b',
  18. messages: [
  19. { role: "system", content: systemMsg },
  20. { role: "user", content: userMsg },
  21. ],
  22. stream: true,
  23. });
  24. }
  25. export function listModels() {
  26. return ollama.list();
  27. }
  28. export function abort() {
  29. ollama.abort();
  30. }