Skip to content

Commit

Permalink
添加对话操作菜单,允许删除单条、删除下方、编辑、重试、复制操作;在回复下方显示访问过的网页链接;适配谷歌学术、知网搜索、知乎热榜、B站搜索…
Browse files Browse the repository at this point in the history
…;版本号修改为1.6.2
  • Loading branch information
Skythinker616 committed Nov 12, 2023
1 parent 7c83e6b commit 0c42bf2
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 81 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A: 程序使用Android WebView加载网页,能用本机浏览器打开的网

**Q: GPT能获取网站中的什么内容?**

A: 对于一般网站,仅允许GPT获取纯文本内容,而对于下述特殊适配过的网站,GPT还可以获取到搜索结果链接:百度、必应、谷歌、知乎、微博、京东、GitHub
A: 对于一般网站,仅允许GPT获取纯文本内容,而对于下述特殊适配过的网站,GPT还可以获取到搜索结果链接:百度、必应、谷歌、谷歌学术、知乎、微博、京东、GitHub、B站、知网

> 如果你觉得有其他网站需要适配,可以提交Issue
Expand All @@ -215,9 +215,9 @@ A: 网页加载超时(15s)、需要登录、需要验证等原因都可能导致

A: 所使用的Markdown渲染器无法在测试中产生稳定的结果,因此暂不支持表格和图片

**Q: 提示获取失败,错误码为502或503**
**Q: 显示获取失败,提示请求超时,或产生错误码502/503**

A: 该错误由OpenAI接口产生,可能由于其服务器负载过高导致,可以等待一段时间后再尝试 [查看OpenAI实时状态](https://status.openai.com/)
A: 排除网络因素,该错误一般由OpenAI接口产生,可能由于其服务器负载过高导致,请重试或等待一段时间后再尝试 [查看OpenAI实时状态](https://status.openai.com/)

---

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk 26
targetSdk 32
versionCode 1
versionName "1.6.1"
versionName "1.6.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface OnReceiveListener {
void onMsgReceive(String message);
void onError(String message);
void onFunctionCall(String name, String arg);
void onFinished();
void onFinished(boolean completed);
}

public enum ChatRole {
Expand Down Expand Up @@ -142,7 +142,7 @@ public void onEvent(EventSource eventSource, @Nullable String id, @Nullable Stri
if(data.equals("[DONE]")){
Log.d("ChatApiClient", "onEvent: DONE");
if(callingFuncName.isEmpty()) {
listener.onFinished();
listener.onFinished(true);
} else {
listener.onFunctionCall(callingFuncName, callingFuncArg);
}
Expand Down Expand Up @@ -172,7 +172,7 @@ public void onFailure(EventSource eventSource, @Nullable Throwable throwable, @N
if(throwable != null) {
if(throwable instanceof StreamResetException) {
Log.d("ChatApiClient", "onFailure: Cancelled");
listener.onFinished();
listener.onFinished(false);
} else {
String err = throwable.toString();
Log.d("ChatApiClient", "onFailure: " + err);
Expand Down
262 changes: 188 additions & 74 deletions app/src/main/java/com/skythinker/gptassistant/MainActivity.java

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions app/src/main/java/com/skythinker/gptassistant/WebScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ public WebsiteRule timeout(int timeout) {
searchWebsiteJsTemplate.replace("<selector>", ".SearchResult-Card")
.replace("<linkIndex>", "0")
),
new WebsiteRule().url("^https://www.zhihu.com/hot").extraDelay(2000).js(
searchWebsiteJsTemplate.replace("<selector>", ".HotItem")
.replace("<linkIndex>", "0")
),
new WebsiteRule().url("^https://s.weibo.com/weibo/.*|^https://m.weibo.cn/search\\?.*").extraDelay(2000),
new WebsiteRule().url("^https://search.bilibili.com/all\\?.*").desktopMode(true).js(
searchWebsiteJsTemplate.replace("<selector>", ".bili-video-card")
.replace("<linkIndex>", "0")
),
new WebsiteRule().url("^https://search.jd.com/Search\\?.*").js(
searchWebsiteJsTemplate.replace("<selector>", ".gl-item")
.replace("<linkIndex>", "0")
Expand All @@ -95,6 +103,14 @@ public WebsiteRule timeout(int timeout) {
searchWebsiteJsTemplate.replace("<selector>", ".jUbAHB")
.replace("<linkIndex>", "0")
),
new WebsiteRule().url("^https://scholar.google.com/scholar\\?.*").js(
searchWebsiteJsTemplate.replace("<selector>", ".gs_ri")
.replace("<linkIndex>", "0")
),
new WebsiteRule().url("^https://kns.cnki.net/kns8s/defaultresult/index\\?.*").extraDelay(2000).js(
searchWebsiteJsTemplate.replace("<selector>", ".result-table-list tr")
.replace("<linkIndex>", "0")
),
new WebsiteRule()
);

Expand Down
Binary file added app/src/main/res/drawable/copy_btn.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/del_below_btn.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/edit_btn.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/retry_btn.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0c42bf2

Please sign in to comment.