chatglm3_tools_example.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // ==UserScript==
  2. // @name chatglm3_tools_example
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description chatglm3工具使用示例
  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. if (app.llm_type == 'glm6b') {
  12. tools = [
  13. {
  14. "name": "track",
  15. "description": "追踪指定股票的实时价格",
  16. "parameters": {
  17. "type": "object",
  18. "properties": {
  19. "symbol": {
  20. "description": "需要追踪的股票代码"
  21. }
  22. },
  23. "required": ['symbol']
  24. }
  25. },
  26. {
  27. "name": "text-to-speech",
  28. "description": "将文本转换为语音",
  29. "parameters": {
  30. "type": "object",
  31. "properties": {
  32. "text": {
  33. "description": "需要转换成语音的文本"
  34. },
  35. "voice": {
  36. "description": "要使用的语音类型(男声、女声等)"
  37. },
  38. "speed": {
  39. "description": "语音的速度(快、中等、慢等)"
  40. }
  41. },
  42. "required": ['text']
  43. }
  44. }
  45. ]
  46. app.buttons.push({
  47. icon: "tools",
  48. click: async () => {
  49. lsdh(true)
  50. app.chat = []
  51. add_conversation("system", JSON.stringify(tools))
  52. let result = await send("帮我查询股票10111的价格")
  53. await send("observation!" + JSON.stringify({ "price": 12412 }))
  54. },
  55. color: () => app.color,
  56. description: "chatglm3工具使用示例"
  57. })
  58. }
粤ICP备19079148号