UP | HOME

emacs-用gptel配合beancount分析记账

[2024-06-05 周三 22:47]

1. gptel的配置

因为LLM返回的格式默认为markdown,所以需要安装markdown-mode

(use-package markdown-mode)

安装gptel,然后如下配置:

(use-package gptel
  :custom
  (gptel-use-curl nil)
  ;;因为我用Windows,没有内置curl
  (gptel-directives
   '((default . "You are a large language model living in Emacs and a helpful assistant. Respond concisely in Chinese.")
     (programming . "You are a large language model and a careful programmer. Provide code and only code as output without any additional text, prompt or note.")
     (writing . "You are a large language model and a writing assistant. Respond concisely in Chinese.")
     (chat . "You are a large language model and a conversation partner. Respond concisely in Chinese.")
     (bill . "You are a large language model and a financial advisor. 请帮我分析后续的记账细则,输出总收入、总支出、单次支出过高的子类及其金额,还有累计支出过高的大类及其累计金额"))
   )
  ;;在此处自定义你的prompt
  :config
  (add-hook 'gptel-post-response-functions 'gptel-end-of-response)
  ;;使gpt回复之后光标移至最后方
  )

然后配置LLM模型的API,这里用的deepseek

(setq gptel-model   "deepseek-chat"
      gptel-backend
      (gptel-make-openai "DeepSeek"
        :host "api.deepseek.com"
        :endpoint "/chat/completions"
        :key "YOUR-KEY"
        :stream t
        :models '("deepseek-chat")))

2. 使用说明

  1. 打开你的beancount账本 *.bean
  2. 选中想要发送到LLM的区域
  3. M-x gptel-menu
  4. g 设置输出到单独的 gpt-session
  5. s 选择 prompt
  6. RET 确认发送

▲ 编辑于 [2024-08-22 周四 11:09] | © Published by Emacs 30.0.50 (Org mode 9.7.10) on [2024-08-22 周四 11:25] | RSS