Skip to content

Commit 0354c2a

Browse files
committed
Update doc for LLM chat
1 parent bd999ba commit 0354c2a

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ Surfingkeys is doing its best to make full use of keyboard for web browsing, but
8686
* Emoji completion in Insert mode
8787
* Rich hints for keystroke
8888
* Everything in Surfingkeys works for PDF
89+
* Regional Hints mode
90+
* Chat with LLM
8991

9092
## Quick start
9193

@@ -157,9 +159,11 @@ Hints are placed in center of target links, you could add below line in your set
157159

158160
Press `L` to enter regional Hints mode by picking a visually large element. There are some built-in actions in regional Hints mode,
159161

162+
* `Esc` to exit regional hints mode
160163
* `ct` to copy text from target element
161164
* `ch` to copy HTML from target element
162165
* `d` to delete target element
166+
* `l` to chat with AI about the text of the element
163167

164168
[Demo on YouTube](https://www.youtube.com/watch?v=pFPOzAZDO38)
165169

@@ -598,6 +602,66 @@ Some functionalities are also available when you're using original pdf viewer, b
598602
}
599603
}`;
600604

605+
## Chat with LLM
606+
There are several LLM providers integrated into Surfingkeys now, use `A` to call out a chat popup, and chat with your AI providers. The supported LLM providers now are
607+
608+
* Ollama
609+
* Bedrock
610+
* DeepSeek
611+
* Gemini
612+
613+
To use the feature, you need set up your credentials/API keys first, like
614+
615+
settings.defaultLLMProvider = "bedrock";
616+
settings.llm = {
617+
bedrock: {
618+
accessKeyId: '********************',
619+
secretAccessKey: '****************************************',
620+
// model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
621+
model: 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',
622+
},
623+
gemini: {
624+
apiKey: '***************************************',
625+
},
626+
ollama: {
627+
model: 'qwen2.5-coder:32b',
628+
},
629+
deepseek: {
630+
apiKey: '***********************************',
631+
model: 'deepseek-chat',
632+
}
633+
};
634+
635+
You can also use `A` in visual mode. Press `v` or `V` to enter visual mode, then `v` again to select the text you'd like to chat with AI about, then `A` to call out the LLM chat box. Now start to chat with AI about the selected text.
636+
637+
Another solution to select the content to chat with AI about is Regional Hints mode. Press `L` to pick an element, then `l` to call out the LLM chat box.
638+
639+
### To use LLM chat with specified system prompt
640+
641+
For example, you can designate your AI to be a translator with below snippets
642+
643+
api.mapkey('A', '#8Open llm chat', function() {
644+
api.Front.openOmnibar({type: "LLMChat", extra: {
645+
system: "You're a translator, whenever you got a message in Chinese, please just translate it into English, and if you got a message in English, please translate it to Chinese. You don't need to answer any question, just TRANSLATE."
646+
}});
647+
});
648+
649+
### 403 Forbidden with Ollama
650+
651+
To use Ollama with Chrome extension, you need run ollama with some modification on `OLLAMA_ORIGINS`
652+
653+
Under Windows
654+
655+
OLLAMA_ORIGINS=chrome-extension://* ollama serve
656+
657+
Under Mac
658+
659+
launchctl setenv OLLAMA_ORIGINS chrome-extension://gfbliohnnapiefjpjlpjnehglfpaknnc
660+
661+
Under Mac for both Chrome and Firefox
662+
663+
launchctl setenv OLLAMA_ORIGINS "chrome-extension://gfbliohnnapiefjpjlpjnehglfpaknnc,moz-extension://*"
664+
601665
## API Documentation
602666

603667
> The API documentation is currently a work in progress.

README_CN.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Surfingkeys尽量让用户使用键盘进行网页浏览,但有些限制是Goo
6868
* 插入模式下的表情下拉选项
6969
* 按键实时提示
7070
* 所有按键对PDF适用
71+
* Regional Hints mode
72+
* 大语言模型对话
7173

7274
## 快速上手
7375

@@ -139,9 +141,11 @@ Surfingkeys有三种模式:normal,visual和insert。
139141

140142
`L`键选择一个大块元素进入Regional Hints mode,目前自带的操作有
141143

144+
* `Esc` 退出Regional Hints mode
142145
* `ct` 复制该大块元素的文本
143146
* `ch` 复制该大块元素的HTML
144147
* `d` 删除该大块元素
148+
* `l` 与大语言模型讨论选中文本
145149

146150
[Demo on YouTube](https://www.youtube.com/watch?v=pFPOzAZDO38)
147151

@@ -583,6 +587,65 @@ Surfingkeys默认使用[这个markdown分析器](https://github.com/chjj/marked)
583587
}
584588
}`;
585589

590+
## 大语言模型对话
591+
目前集成了比较常用的几个大语言模型,可用`A`调出对话窗口,
592+
593+
* Ollama
594+
* Bedrock
595+
* DeepSeek
596+
* Gemini
597+
598+
使用之前,必须设置相应的密钥或者API key,比如
599+
600+
settings.defaultLLMProvider = "bedrock";
601+
settings.llm = {
602+
bedrock: {
603+
accessKeyId: '********************',
604+
secretAccessKey: '****************************************',
605+
// model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
606+
model: 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',
607+
},
608+
gemini: {
609+
apiKey: '***************************************',
610+
},
611+
ollama: {
612+
model: 'qwen2.5-coder:32b',
613+
},
614+
deepseek: {
615+
apiKey: '***********************************',
616+
model: 'deepseek-chat',
617+
}
618+
};
619+
620+
你也可以在Visual mode下使用大语言模型对话。按`v``V`进入Visual mode,再按`v`选中你关注的文本,最后`A`按调出对话窗口,开始和AI就选中文本进行探讨。
621+
另一个方式是使用Regional Hints mode选择需要与AI进行探讨的内容。按`L`选择一个区域,再按`l`调出对话窗口。
622+
623+
### 指定系统提示词
624+
625+
比如,你可以这样限定你的AI只做中英文互译
626+
627+
api.mapkey('A', '#8Open llm chat', function() {
628+
api.Front.openOmnibar({type: "LLMChat", extra: {
629+
system: "You're a translator, whenever you got a message in Chinese, please just translate it into English, and if you got a message in English, please translate it to Chinese. You don't need to answer any question, just TRANSLATE."
630+
}});
631+
});
632+
633+
### 403 Forbidden with Ollama
634+
635+
在Chrome扩展中使用Ollama,你需要在启动ollama时指定`OLLAMA_ORIGINS`
636+
637+
Windows下
638+
639+
OLLAMA_ORIGINS=chrome-extension://* ollama serve
640+
641+
Mac下
642+
643+
launchctl setenv OLLAMA_ORIGINS chrome-extension://gfbliohnnapiefjpjlpjnehglfpaknnc
644+
645+
Mac下同时允许在Chrome和Firefox里使用
646+
647+
launchctl setenv OLLAMA_ORIGINS "chrome-extension://gfbliohnnapiefjpjlpjnehglfpaknnc,moz-extension://*"
648+
586649
## 编译
587650

588651
npm install

0 commit comments

Comments
 (0)