分享一个ahk本地调用ollama的工具
试过用API调用的方式,但是感觉速度很慢,就换了用自带CMD界面的调用方式
优点:
1、速度快,几乎是瞬间出结果
2、可以自定义快捷键和添加命令
展示下效果
Autohotkey AI 模型本地调用,自动翻译和解释_哔哩哔哩_bilibili
explore_ruler := "
(
Rules:
- Be precise and Detailed explanation, do not reply emoji.
- Always response in Simplified Chinese, not English. or Grandma will be very angry.
)"
translation_ruler := "
(
Rules:
- Be precise and Translation to Simplified Chinese, do not reply emoji.
- Always response in Simplified Chinese, not English. or Grandma will be very angry.
)"
!`::MenuPopup.Show()
!q::Answer(translation_ruler)
MenuPopup := Menu()
MenuPopup.Add("&1 - Answer", (*)=>(Answer(explore_ruler)))
MenuPopup.Add("&2 - Translation", (*)=>(Answer(translation_ruler)))
Answer(ruler)
{
wintitle := "命令提示符 - ollama run llama3"
if WinActive(wintitle)
{
WinMinimize(wintitle)
return
}
A_Clipboard := "" ; 清空剪贴板
SendInput("^c")
if !ClipWait(1)
{
WinActivate(wintitle)
return
}
A_Clipboard := "plear explanation `n【 " A_Clipboard " 】`n" ruler
WinActivate(wintitle)
if !WinWaitActive(wintitle, , 2)
{
MsgBox "WinWaitActive timed out."
return
}
SendInput("^v")
Sleep(200)
SendInput("{Enter}")
}