emacs-用gptel配合beancount分析记账
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. 使用说明
- 打开你的beancount账本
*.bean
- 选中想要发送到LLM的区域
M-x
gptel-menu
- 按
g
设置输出到单独的gpt-session
- 按
s
选择prompt
- 按
RET
确认发送