0-write_article.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // ==UserScript==
  2. // @name 写论文
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 根据题目或提纲写论文
  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. let RomanNumeralsMap = {
  12. 'III': 3,
  13. 'II': 2,
  14. 'IV': 4,
  15. 'IX': 9,
  16. 'XL': 40,
  17. 'XC': 90,
  18. 'CD': 400,
  19. 'CM': 900,
  20. 'I': 1,
  21. 'V': 5,
  22. 'X': 10,
  23. 'L': 50,
  24. 'C': 100,
  25. 'D': 500,
  26. 'M': 1000
  27. }
  28. function find_RomanNumerals(str) {
  29. let number = 0;
  30. for (var p in RomanNumeralsMap) {
  31. if (str.indexOf(p) != -1) {
  32. str = str.split(p).join("");
  33. number += RomanNumeralsMap[p];
  34. }
  35. }
  36. return number
  37. }
  38. func.push({
  39. name: "根据标题写论文",
  40. description: "根据主题撰写内容翔实、有信服力的论文",
  41. question: async () => {
  42. lsdh(false)
  43. Q = app.question
  44. app.max_length = 4096
  45. app.chat = []
  46. resp = (await send("根据以下主题,写一篇高度凝练且全面的论文提纲:" + Q, Q))
  47. .replace(/\n- /g, '\n1.')//兼容不同格式
  48. .split("\n")
  49. content = [resp.join("\n\n"), "------------------------------正文------------------------------"]
  50. for (let i in resp) {
  51. let line = resp[i]
  52. if (line == "") continue
  53. line = line.split(".")
  54. if (line.length < 2) {
  55. continue // 判断非提纲内容
  56. }
  57. content.push(resp[i]) // 保存提纲
  58. let num = find_RomanNumerals(line[0])
  59. if (num <= 0 || num == 100) {
  60. content.push(await send("根据主题:" + Q +
  61. "\n对下列段落进行详细的撰写:" + line[1], line[1]) + "\n\n")
  62. }
  63. }
  64. content = content.join("\n\n")
  65. add_conversation("user", Q )
  66. add_conversation("AI", content )
  67. console.log(content)
  68. copy(content)
  69. },
  70. })
  71. func.push({
  72. name: "根据提纲写论文",
  73. description: "根据主题撰写内容翔实、有信服力的论文",
  74. question: async () => {
  75. title = app.question
  76. app.max_length = 4096
  77. app.chat = []
  78. resp =title.split("\n")
  79. title=resp[0]
  80. content = [resp.join("\n\n"), "------------------------------正文------------------------------"]
  81. for (let i in resp) {
  82. let line = resp[i]
  83. if (line == "") continue
  84. line = line.split(".")
  85. if (line.length < 2) {
  86. continue // 判断非提纲内容
  87. }
  88. content.push(resp[i]) // 保存提纲
  89. let num = find_RomanNumerals(line[0])
  90. if (num <= 0 || num == 100) {
  91. content.push(await send("根据主题:" + title +
  92. "。对下列段落进行详细的撰写:" + line[1], line[1]))
  93. }
  94. }
  95. content = content.join("\n\n")
  96. add_conversation("user", title )
  97. add_conversation("AI", content )
  98. console.log(content)
  99. copy(content)
  100. },
  101. })
粤ICP备19079148号