debug.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. const registerAPI = function (app) {
  2. const coversationList = [
  3. {
  4. id: '1',
  5. name: '梦的解析',
  6. inputs: {
  7. book: '《梦的解析》',
  8. callMe: '大师',
  9. },
  10. chats: []
  11. },
  12. {
  13. id: '2',
  14. name: '生命的起源',
  15. inputs: {
  16. book: '《x x x》',
  17. }
  18. },
  19. ]
  20. // site info
  21. app.get('/apps/site/info', async (req, res) => {
  22. // const id = req.params.id
  23. res.send({
  24. enable_site: true,
  25. appId: '1',
  26. site: {
  27. title: 'Story Bot',
  28. description: '这是一款解梦聊天机器人,你可以选择你喜欢的解梦人进行解梦,这句话是客户端应用说明',
  29. },
  30. prompt_public: true, //id === '1',
  31. prompt_template: '你是我的解梦小助手,请参考 {{book}} 回答我有关梦境的问题。在回答前请称呼我为 {{myName}}。',
  32. })
  33. })
  34. app.post('/apps/:id/chat-messages', async (req, res) => {
  35. const conversationId = req.body.conversation_id ? req.body.conversation_id : Date.now() + ''
  36. res.send({
  37. id: Date.now() + '',
  38. conversation_id: Date.now() + '',
  39. answer: 'balabababab'
  40. })
  41. })
  42. app.post('/apps/:id/completion-messages', async (req, res) => {
  43. res.send({
  44. id: Date.now() + '',
  45. answer: `做为一个AI助手,我可以为你提供随机生成的段落,这些段落可以用于测试、占位符、或者其他目的。以下是一个随机生成的段落:
  46. “随着科技的不断发展,越来越多的人开始意识到人工智能的重要性。人工智能已经成为我们生活中不可或缺的一部分,它可以帮助我们完成很多繁琐的工作,也可以为我们提供更智能、更便捷的服务。虽然人工智能带来了很多好处,但它也面临着很多挑战。例如,人工智能的算法可能会出现偏见,导致对某些人群不公平。此外,人工智能的发展也可能会导致一些工作的失业。因此,我们需要不断地研究人工智能的发展,以确保它能够为人类带来更多的好处。”`
  47. })
  48. })
  49. // share api
  50. // chat list
  51. app.get('/apps/:id/coversations', async (req, res) => {
  52. res.send({
  53. data: coversationList
  54. })
  55. })
  56. app.get('/apps/:id/variables', async (req, res) => {
  57. res.send({
  58. variables: [
  59. {
  60. key: 'book',
  61. name: '书',
  62. value: '《梦境解析》',
  63. type: 'string'
  64. },
  65. {
  66. key: 'myName',
  67. name: '称呼',
  68. value: '',
  69. type: 'string'
  70. }
  71. ],
  72. })
  73. })
  74. }
  75. module.exports = registerAPI
  76. // const chatList = [
  77. // {
  78. // id: 1,
  79. // content: 'AI 开场白',
  80. // isAnswer: true,
  81. // },
  82. // {
  83. // id: 2,
  84. // content: '梦见在山上手撕鬼子,大师解解梦',
  85. // more: { time: '5.6 秒' },
  86. // },
  87. // {
  88. // id: 3,
  89. // content: '梦境通常是个人内心深处的反映,很难确定每个人梦境的确切含义,因为它们可能会受到梦境者的文化背景、生活经验和情感状态等多种因素的影响。',
  90. // isAnswer: true,
  91. // more: { time: '99 秒' },
  92. // },
  93. // {
  94. // id: 4,
  95. // content: '梦见在山上手撕鬼子,大师解解梦',
  96. // more: { time: '5.6 秒' },
  97. // },
  98. // {
  99. // id: 5,
  100. // content: '梦见在山上手撕鬼子,大师解解梦',
  101. // more: { time: '5.6 秒' },
  102. // },
  103. // {
  104. // id: 6,
  105. // content: '梦见在山上手撕鬼子,大师解解梦',
  106. // more: { time: '5.6 秒' },
  107. // },
  108. // ]