mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
Note: The gemini-pro-vision model (for text-and-image input) is not yet optimized for multi-turn conversations. Make sure to use gemini-pro and text-only input for chat use cases.
This commit is contained in:
parent
4dc5d6fe77
commit
22dcb0405b
5 changed files with 185 additions and 111 deletions
|
|
@ -1030,6 +1030,25 @@ export function getUserSpeaker (userSetting) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取或者下载文件,如果文件存在则直接返回不会重新下载
|
||||
* @param destPath 相对路径,如received/abc.pdf
|
||||
* @param url
|
||||
* @param ignoreCertificateError 忽略证书错误
|
||||
* @return {Promise<string>} 最终下载文件的存储位置
|
||||
*/
|
||||
export async function getOrDownloadFile (destPath, url, ignoreCertificateError = true) {
|
||||
const _path = process.cwd()
|
||||
let dest = path.join(_path, 'data', 'chatgpt', destPath)
|
||||
const p = path.dirname(dest)
|
||||
mkdirs(p)
|
||||
if (fs.existsSync(dest)) {
|
||||
return dest
|
||||
} else {
|
||||
return await downloadFile(url, destPath, false, ignoreCertificateError)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url 要下载的文件链接
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export async function imageVariation (imageUrl, n = 1, size = '512x512') {
|
|||
return response.data.data?.map(pic => pic.b64_json)
|
||||
}
|
||||
|
||||
async function resizeAndCropImage (inputFilePath, outputFilePath, size = 512) {
|
||||
export async function resizeAndCropImage (inputFilePath, outputFilePath, size = 512) {
|
||||
// Determine the maximum dimension of the input image
|
||||
let sharp
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ export class SendPictureTool extends AbstractTool {
|
|||
|
||||
func = async function (opt, e) {
|
||||
let { urlOfPicture, targetGroupIdOrQQNumber } = opt
|
||||
if (typeof urlOfPicture === 'object') {
|
||||
urlOfPicture = urlOfPicture.join(' ')
|
||||
}
|
||||
const defaultTarget = e.isGroup ? e.group_id : e.sender.user_id
|
||||
const target = isNaN(targetGroupIdOrQQNumber) || !targetGroupIdOrQQNumber
|
||||
? defaultTarget
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue