generated from tailored/router-template
temp
This commit is contained in:
@@ -19,7 +19,6 @@ taskApp
|
||||
if (res.code === 200) {
|
||||
const data = res.body;
|
||||
const unread_count = data.unread_count;
|
||||
console.log('unread_count====', data);
|
||||
if (unread_count > 0) {
|
||||
queue.add(
|
||||
'mention',
|
||||
@@ -69,21 +68,26 @@ taskApp
|
||||
console.log('queryMention', util.inspect(data, { depth: 10 }));
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const item = data[i];
|
||||
const note_id = item.note_id;
|
||||
const xsec_token = item.xsec_token;
|
||||
const comment_id = item.comment.comment_id;
|
||||
const content = item.comment?.content || 'test';
|
||||
const postData = {
|
||||
note_id,
|
||||
content,
|
||||
comment_id,
|
||||
};
|
||||
const res = await xhsApp.call({
|
||||
path: 'mention',
|
||||
key: 'addComment',
|
||||
payload: postData,
|
||||
});
|
||||
console.log('addComment', postData, 'res', res.body);
|
||||
queue.add(
|
||||
'mention-ai',
|
||||
{
|
||||
path: 'task',
|
||||
key: 'ai',
|
||||
payload: {
|
||||
data: item,
|
||||
},
|
||||
},
|
||||
{
|
||||
attempts: 3,
|
||||
delay: 0,
|
||||
removeOnComplete: true,
|
||||
removeOnFail: {
|
||||
age: 24 * 3600, // keep up to 24 hours
|
||||
},
|
||||
},
|
||||
);
|
||||
console.log('add mention task', item);
|
||||
await sleep(200);
|
||||
}
|
||||
}
|
||||
const postRead = await xhsApp.call({
|
||||
@@ -98,3 +102,28 @@ taskApp
|
||||
};
|
||||
})
|
||||
.addTo(taskApp);
|
||||
|
||||
taskApp
|
||||
.route({
|
||||
path: 'task',
|
||||
key: 'ai',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const data = ctx.query.data;
|
||||
const note_id = data.note_id;
|
||||
const xsec_token = data.xsec_token;
|
||||
const comment_id = data.comment.comment_id;
|
||||
const content = data.comment?.content || 'test';
|
||||
const postData = {
|
||||
note_id,
|
||||
content,
|
||||
comment_id,
|
||||
};
|
||||
const res = await xhsApp.call({
|
||||
path: 'mention',
|
||||
key: 'addComment',
|
||||
payload: postData,
|
||||
});
|
||||
console.log('addComment', postData, 'res', res.body);
|
||||
})
|
||||
.addTo(taskApp);
|
||||
|
||||
27
src/test/ai.ts
Normal file
27
src/test/ai.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { ProviderManager, SiliconFlowProvider } from '@kevisual/ai-center';
|
||||
import dotenv from 'dotenv';
|
||||
import util from 'node:util';
|
||||
dotenv.config();
|
||||
import { createQuestion, answer } from '@kevisual/social-prompts/xhs/answer.ts';
|
||||
const pm = new SiliconFlowProvider({
|
||||
model: 'Qwen/Qwen3-32B',
|
||||
apiKey: process.env.SILICONFLOW_API_KEY,
|
||||
});
|
||||
|
||||
const main = async () => {
|
||||
const usage = await pm.getUsageInfo();
|
||||
console.log('usage', usage);
|
||||
};
|
||||
|
||||
// main();
|
||||
const ques = async () => {
|
||||
// const msg = createQuestion('介绍一下如何安装node,在mac当中', '前端的node如何安装环境', answer);
|
||||
const msg = createQuestion('介绍一下如何安装node,在mac当中', '前端的node如何安装环境', answer);
|
||||
console.log('msg', msg);
|
||||
const res = await pm.chat(msg);
|
||||
console.log(util.inspect(res.choices, { depth: null }));
|
||||
const ans = res.choices[0].message.content;
|
||||
console.log('ans', ans, ans.length);
|
||||
};
|
||||
|
||||
ques();
|
||||
Reference in New Issue
Block a user