switch_lora.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // ==UserScript==
  2. // @name Lora切换测试
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description GLM-6B Lora在线切换api测试。注意要在配置中开启LORA
  6. // @author You
  7. // @match http://127.0.0.1:17860/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=0.1
  9. // @grant none
  10. // ==/UserScript==
  11. func.push({
  12. name: "Lora切换测试",
  13. question: async () => {
  14. lsdh(false)
  15. Q=app.question
  16. lora_name="model\\chatglm-6b-belle-zh-lora"//https://huggingface.co/shibing624/chatglm-6b-belle-zh-lora
  17. await lora_load_adapter(lora_name)
  18. sources = [{
  19. title: 'belle_lora',
  20. content: lora_name
  21. }]
  22. await send(Q, keyword = Q, show = true, sources = sources)
  23. lora_name="model\\chatglm-6b-csc-zh-lora"//https://huggingface.co/shibing624/chatglm-6b-csc-zh-lora
  24. await lora_load_adapter(lora_name)
  25. sources = [{
  26. title: '纠错_lora',
  27. content: lora_name
  28. }]
  29. await send(Q, keyword = Q, show = true, sources = sources)
  30. },
  31. })
  32. lora_load_adapter= async (lora_name) => {
  33. response = await fetch("/api/lora_load_adapter", {
  34. // signal: signal,
  35. method: 'post',
  36. body: JSON.stringify({
  37. lora_path: lora_name,
  38. adapter_name: lora_name,
  39. }),
  40. headers: {
  41. 'Content-Type': 'application/json'
  42. }
  43. })
  44. alert(await response.text())
  45. }
粤ICP备19079148号