feat: 智能模式,添加群管、试图、联网搜索、发图、发音乐和视频等功能 (#488)

* fix: 2.7 dev start

* feat: 初步支持function call(WIP)

* fix: syntax error

* fix: syntax error

* feat: 群聊上下文

* fix: 暂时阉割掉全员禁言功能

* fix: 修改禁言时间范围

* fix: 修复一些功能易用性

* fix: 只有管理员和群主才能用jinyan和kickout

* fix: 加回来禁言和踢出

* fix: 修复管理员权限判断问题(可能吧)

* fix: 试图优化逻辑

* fix: fuck openai documents

* fix: 删掉认主不然一直禁言我烦死了

* fix: 哔哩哔哩封面损坏问题

* fix: 加个天气小工具

* fix: 天气不存在城市

* fix: website工具用浏览器

* feat: serp tool

* feat: 增加一个google搜索源

* fix: 加一句描述

* feat: 增加搜索来源选项

* feat: 搜图和发图

* fix: groupId format error

* fix: add a image caption tool

* fix: 修改一些提示。tool太多机器人开始混乱了

* fix: 一些极端的措施

* fix: 增加一些提示和一个暂时的公共接口

* fix: 收拾一下

* fix: 修改命令正则

* fix: 修改一些提示

* fix: move send avatar into send picture tool

* fix: 修复解除禁言的bug
This commit is contained in:
ikechan8370 2023-06-25 01:09:29 +08:00 committed by GitHub
parent 2c5b084b04
commit b7427e74c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 18987 additions and 58 deletions

View file

@ -0,0 +1,49 @@
import { AbstractTool } from './AbstractTool.js'
import fetch, { File, FormData } from 'node-fetch'
import { Config } from '../config.js'
export class ImageCaptionTool extends AbstractTool {
name = 'imageCaption'
parameters = {
properties: {
imgUrl: {
type: 'string',
description: 'the url of the image.'
},
qq: {
type: 'string',
description: 'if the picture is an avatar of a user, just give his qq number'
}
},
required: []
}
description = 'useful when you want to know what is inside a photo, such as user\'s avatar or other pictures'
func = async function (opts) {
let { imgUrl, qq } = opts
if (qq) {
imgUrl = `https://q1.qlogo.cn/g?b=qq&s=160&nk=${qq}`
}
if (!imgUrl) {
return 'you must give at least one parameter of imgUrl and qq'
}
const imageResponse = await fetch(imgUrl)
const blob = await imageResponse.blob()
const arrayBuffer = await blob.arrayBuffer()
const buffer = Buffer.from(arrayBuffer)
// await fs.writeFileSync(`data/chatgpt/${crypto.randomUUID()}`, buffer)
let formData = new FormData()
formData.append('file', new File([buffer], 'file.png', { type: 'image/png' }))
let captionRes = await fetch(`${Config.extraUrl}/image-captioning`, {
method: 'POST',
body: formData
})
if (captionRes.status === 200) {
let result = await captionRes.text()
return `the content of this picture is: ${result}`
} else {
return 'error happened'
}
}
}