Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈老铁
chatbot-api
提交
ed3b0f86
chatbot-api
项目概览
陈老铁
/
chatbot-api
与 Fork 源项目一致
Fork自
fuzhengwei / chatbot-api
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
chatbot-api
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ed3b0f86
编写于
1月 28, 2023
作者:
小傅哥
⛹
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
小傅哥,feat:新增silenced参数配置
上级
ef3f5a23
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
13 addition
and
8 deletion
+13
-8
chatbot-api-application/src/main/java/cn/bugstack/chatbot/api/application/ext/TaskRegistrarAutoConfig.java
.../chatbot/api/application/ext/TaskRegistrarAutoConfig.java
+2
-1
chatbot-api-application/src/main/java/cn/bugstack/chatbot/api/application/job/ChatbotTask.java
.../cn/bugstack/chatbot/api/application/job/ChatbotTask.java
+4
-2
chatbot-api-interfaces/src/main/resources/application.yml
chatbot-api-interfaces/src/main/resources/application.yml
+3
-1
chatbot-api-interfaces/src/test/java/cn/bugstack/chatbot/api/test/ApiTest.java
...s/src/test/java/cn/bugstack/chatbot/api/test/ApiTest.java
+4
-4
docs/images/docker配置.png
docs/images/docker配置.png
+0
-0
未找到文件。
chatbot-api-application/src/main/java/cn/bugstack/chatbot/api/application/ext/TaskRegistrarAutoConfig.java
浏览文件 @
ed3b0f86
...
...
@@ -65,9 +65,10 @@ public class TaskRegistrarAutoConfig implements EnvironmentAware, SchedulingConf
String
openAiKey
=
taskGroup
.
get
(
"openAiKey"
).
toString
();
String
cronExpressionBase64
=
taskGroup
.
get
(
"cronExpression"
).
toString
();
String
cronExpression
=
new
String
(
Base64
.
getDecoder
().
decode
(
cronExpressionBase64
),
StandardCharsets
.
UTF_8
);
boolean
silenced
=
Boolean
.
parseBoolean
(
taskGroup
.
get
(
"silenced"
).
toString
());
logger
.
info
(
"创建任务 groupName:{} groupId:{} cronExpression:{}"
,
groupName
,
groupId
,
cronExpression
);
// 添加任务
taskRegistrar
.
addCronTask
(
new
ChatbotTask
(
groupName
,
groupId
,
cookie
,
openAiKey
,
zsxqApi
,
openAI
),
cronExpression
);
taskRegistrar
.
addCronTask
(
new
ChatbotTask
(
groupName
,
groupId
,
cookie
,
openAiKey
,
zsxqApi
,
openAI
,
silenced
),
cronExpression
);
}
}
...
...
chatbot-api-application/src/main/java/cn/bugstack/chatbot/api/application/job/ChatbotTask.java
浏览文件 @
ed3b0f86
...
...
@@ -27,17 +27,19 @@ public class ChatbotTask implements Runnable {
private
String
groupId
;
private
String
cookie
;
private
String
openAiKey
;
private
boolean
silenced
;
private
IZsxqApi
zsxqApi
;
private
IOpenAI
openAI
;
public
ChatbotTask
(
String
groupName
,
String
groupId
,
String
cookie
,
String
openAiKey
,
IZsxqApi
zsxqApi
,
IOpenAI
openAI
)
{
public
ChatbotTask
(
String
groupName
,
String
groupId
,
String
cookie
,
String
openAiKey
,
IZsxqApi
zsxqApi
,
IOpenAI
openAI
,
boolean
silenced
)
{
this
.
groupName
=
groupName
;
this
.
groupId
=
groupId
;
this
.
cookie
=
cookie
;
this
.
openAiKey
=
openAiKey
;
this
.
zsxqApi
=
zsxqApi
;
this
.
openAI
=
openAI
;
this
.
silenced
=
silenced
;
}
@Override
...
...
@@ -68,7 +70,7 @@ public class ChatbotTask implements Runnable {
Topics
topic
=
topics
.
get
(
topics
.
size
()
-
1
);
String
answer
=
openAI
.
doChatGPT
(
openAiKey
,
topic
.
getQuestion
().
getText
().
trim
());
// 3. 问题回复
boolean
status
=
zsxqApi
.
answer
(
groupId
,
cookie
,
topic
.
getTopic_id
(),
answer
,
false
);
boolean
status
=
zsxqApi
.
answer
(
groupId
,
cookie
,
topic
.
getTopic_id
(),
answer
,
silenced
);
logger
.
info
(
"{} 编号:{} 问题:{} 回答:{} 状态:{}"
,
groupName
,
topic
.
getTopic_id
(),
topic
.
getQuestion
().
getText
(),
answer
,
status
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"{} 自动回答问题异常"
,
groupName
,
e
);
...
...
chatbot-api-interfaces/src/main/resources/application.yml
浏览文件 @
ed3b0f86
...
...
@@ -10,9 +10,11 @@ chatbot-api:
cookie
:
# 知识星球个人cookie信息
openAiKey
:
# 自行申请 https://beta.openai.com/overview 或者联系小傅哥 fustack 付费申请【购买虚拟号码等需要支付】。
cronExpression
:
0/30 * * * * ?
# 执行的频次配置,参考:cron.qqe2.com
silenced
:
false
group02
:
groupName
:
码农会锁
groupId
:
28885518425541
# 知识星球ID
cookie
:
# 知识星球个人cookie信息
openAiKey
:
# 自行申请 https://beta.openai.com/overview 或者联系小傅哥 fustack 付费申请【购买虚拟号码等需要支付】。
cronExpression
:
0/30 * * * * ?
# 执行的频次配置,参考:cron.qqe2.com
\ No newline at end of file
cronExpression
:
0/30 * * * * ?
# 执行的频次配置,参考:cron.qqe2.com
silenced
:
true
\ No newline at end of file
chatbot-api-interfaces/src/test/java/cn/bugstack/chatbot/api/test/ApiTest.java
浏览文件 @
ed3b0f86
...
...
@@ -33,9 +33,9 @@ public class ApiTest {
public
void
query_unanswered_questions
()
throws
IOException
{
CloseableHttpClient
httpClient
=
HttpClientBuilder
.
create
().
build
();
HttpGet
get
=
new
HttpGet
(
"https://api.zsxq.com/v2/groups/
28885518425541
/topics?scope=unanswered_questions&count=20"
);
HttpGet
get
=
new
HttpGet
(
"https://api.zsxq.com/v2/groups/
48411118851818
/topics?scope=unanswered_questions&count=20"
);
get
.
addHeader
(
"cookie"
,
""
);
get
.
addHeader
(
"cookie"
,
"
知识星球个人cookie信息
"
);
get
.
addHeader
(
"Content-Type"
,
"application/json;charset=utf8"
);
CloseableHttpResponse
response
=
httpClient
.
execute
(
get
);
...
...
@@ -52,7 +52,7 @@ public class ApiTest {
CloseableHttpClient
httpClient
=
HttpClientBuilder
.
create
().
build
();
HttpPost
post
=
new
HttpPost
(
"https://api.zsxq.com/v2/topics/412884248251548/answer"
);
post
.
addHeader
(
"cookie"
,
"
__cuid=5330a556392a4c5b8084b4cbc165e0f3; amp_fef1e8=930aec23-e22e-4f11-8864-0389bd5095d1R...1g55hl79m.1g55hl79t.1.1.2; UM_distinctid=183e61195d535b-0bddac94679c75-19525635-1aeaa0-183e61195d7c52; sensorsdata2015jssdkcross={\"distinct_id\":\"241858242255511\",\"first_id\":\"17ebd0b4317ecb-0b27f672c2d3af-133a6253-1296000-17ebd0b4318ba7\",\"props\":{\"$latest_traffic_source_type\":\"直接流量\",\"$latest_search_keyword\":\"未取到值_直接打开\",\"$latest_referrer\":\"\"},\"$device_id\":\"17ebd0b4317ecb-0b27f672c2d3af-133a6253-1296000-17ebd0b4318ba7\",\"identities\":\"eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTgwMmQ2YjZiOWIxZjMtMGQ4YzMzZjhmYTA3YmEtMzU3MzZhMDMtMTI5NjAwMC0xODAyZDZiNmI5YzEwODYiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIyNDE4NTgyNDIyNTU1MTEifQ==\",\"history_login_id\":{\"name\":\"$identity_login_id\",\"value\":\"241858242255511\"}}; abtest_env=product; zsxqsessionid=8fae9a083a4874ab833c2158a44deb82; zsxq_access_token=5D862869-1229-A9B6-1BC1-C662EC4B16DD_D625BA7FD9CBBDFA
"
);
post
.
addHeader
(
"cookie"
,
"
知识星球个人cookie信息
"
);
post
.
addHeader
(
"Content-Type"
,
"application/json;charset=utf8"
);
String
paramJson
=
"{\n"
+
...
...
@@ -81,7 +81,7 @@ public class ApiTest {
HttpPost
post
=
new
HttpPost
(
"https://api.openai.com/v1/completions"
);
post
.
addHeader
(
"Content-Type"
,
"application/json"
);
post
.
addHeader
(
"Authorization"
,
"Bearer
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
"
);
post
.
addHeader
(
"Authorization"
,
"Bearer
自行申请 https://beta.openai.com/overview
"
);
String
paramJson
=
"{\"model\": \"text-davinci-003\", \"prompt\": \"帮我写一个java冒泡排序\", \"temperature\": 0, \"max_tokens\": 1024}"
;
...
...
docs/images/docker配置.png
查看替换文件 @
ef3f5a23
浏览文件 @
ed3b0f86
255.7 KB
|
W:
|
H:
180.9 KB
|
W:
|
H:
2-up
Swipe
Onion skin
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录