V 2.2.6 增加了MJ的api

This commit is contained in:
2024-06-01 15:08:22 +08:00
parent 941a86d07a
commit 8b011856c2
52 changed files with 3255 additions and 2376 deletions
+56
View File
@@ -0,0 +1,56 @@
let apiUrl = [{
label: "openai-hk",
value: "3d64e50e-79c0-49ec-a72d-7dfdf508dd04",
gpt_url: "https://api.openai-hk.com/v1/chat/completions",
mj_url: null,
buy_url: "https://openai-hk.com/?i=10196"
}, {
label: "通义千问",
value: "b630c69a-99e9-46bc-8d88-39a00bcc3d2a",
gpt_url: "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation",
mj_url: null,
buy_url: null
}, {
label: "DrawAPI(MJ)",
value: "2cabf684-ac48-4733-a427-8c41626f7d8f",
gpt_url: null,
mj_url: {
imagine: "https://mjapi.deepwl.net/api/mj/submit/imagine",
describe: "https://mjapi.deepwl.net/api/mj/submit/describe",
update_file: "https://mjapi.deepwl.net/api/mj/submit/upload-discord-images",
once_get_task: "https://mjapi.deepwl.net/api/mj/query/task/${id}",
get_task_list: "https://mjapi.deepwl.net/api/mj/task/list-by-condition"
},
d3_url: null,
buy_url: "https://mjapi.deepwl.net/#/home"
}, {
label: "ePhoneAPI",
value: "b8866543-8c27-4888-869c-00aa1eb31272",
gpt_url: "https://api.ephone.ai/v1/chat/completions",
mj_url: {
imagine: "https://api.ephone.ai/mj/submit/imagine",
describe: "https://api.ephone.ai/mj/submit/describe",
update_file: "https://api.ephone.ai/mj/submit/upload-discord-images",
once_get_task: "https://api.ephone.ai/mj/task/${id}/fetch",
},
d3_url: {
image: "https://api.ephone.ai/v1/images/generations"
},
buy_url: "https://ephone.ai/register?aff=55XT"
}]
/**
* 通过ID获取指定的数据(value)
* @param {*} id
*/
function getApiMessageByID(id) {
let mj_api_url_index = apiUrl.findIndex(item => item.value == id)
if (mj_api_url_index == -1) {
throw new Error("没有找到对应的MJ API的配置,请先检查配置")
}
}
export {
apiUrl,
getApiMessageByID
}
+7 -1
View File
@@ -132,6 +132,7 @@ export const DEFINE_STRING = {
TRANSLATE_RETURN_NOW_TASK: "TRANSLATE_RETURN_NOW_TASK",
IMAGE_SAVE_TO_OTHER_FOLDER: "IMAGE_SAVE_TO_OTHER_FOLDER",
SAVE_FILE_QUEUE: "SAVE_FILE_QUEUE",
AUTO_SAVE_DATA_JSON: "AUTO_SAVE_DATA_JSON"
},
PERMISSIONS: {
NORMAL_PERMISSION: "NORMAL_PERMISSION",
@@ -156,7 +157,9 @@ export const DEFINE_STRING = {
ADD_MJ_BAD_PROMPT: "ADD_MJ_BAD_PROMPT",
MJ_BAD_PROMPT_CHECK: "MJ_BAD_PROMPT_CHECK",
GET_GENERATED_MJ_IMAGE_AND_SPLIT: "GET_GENERATED_MJ_IMAGE_AND_SPLIT",
DOWNLOAD_IMAGE_URL_AND_SPLIT: "DOWNLOAD_IMAGE_URL_AND_SPLIT"
DOWNLOAD_IMAGE_URL_AND_SPLIT: "DOWNLOAD_IMAGE_URL_AND_SPLIT",
GET_MJ_IMAGE_SCALE: 'GET_MJ_IMAGE_SCALE',
GET_MJ_IMAGE_ROBOT_MODEL: "GET_MJ_IMAGE_ROBOT_MODEL"
},
DISCORD: {
OPERATE_REFRASH_DISCORD_URL: "OPERATE_REFRASH_DISCORD_URL",
@@ -175,5 +178,8 @@ export const DEFINE_STRING = {
},
MAIN: {
OPEN_DISCORD_WINDOW: "OPEN_DISCORD_WINDOW"
},
IMG: {
ONE_SPLIT_FOUR: "ONE_SPLIT_FOUR"
}
}
+5 -8
View File
@@ -2,6 +2,7 @@ let fspromises = require('fs').promises;
import { cloneDeep, get } from "lodash";
import { define } from "./define";
const { v4: uuidv4 } = require('uuid');
import { apiUrl } from "./api/apiUrlDefine";
// Create a shared object
export const gptDefine = {
@@ -271,13 +272,7 @@ export const gptDefine = {
}
},
gpt_options: [{
label: "openai-hk",
value: "https://api.openai-hk.com/v1/chat/completions"
}, {
label: "通义千问",
value: "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation"
}],
gpt_options: apiUrl,
gpt_model_options: [{
label: "gpt-3.5-turbo-16k",
@@ -377,7 +372,9 @@ export const gptDefine = {
gpt[index] = value;
}
} else {
value.id = uuidv4();
let tmp_id = uuidv4();
value.id = tmp_id;
value.value = tmp_id;
gpt.push(value);
}
tmp_gpt[property] = gpt;
+90 -13
View File
@@ -1,16 +1,89 @@
import { Tools } from "../../main/tools";
import { define } from "../define";
import path from "path";
import { DEFINE_STRING } from "../define_string";
import { get, has } from "lodash";
let tools = new Tools();
const { v4: uuidv4 } = require('uuid'); // 引入UUID库来生成唯一标识符
import { successMessage } from "../../main/generalTools";
export class MjSetting {
constructor(golbal) {
this.golbal = golbal;
}
/**
* 获取MJ生成图片的机器人模型
*/
GetMJImageRobotModel() {
return successMessage([
{
label: "MJ V6.0",
text: "v 6",
type: "mj",
value: "3e6473ab-9a64-4574-9a38-f5c75af552b6"
},
{
label: "MJ V5.2",
text: "v 5.2",
type: "mj",
value: "27a0d30e-f46c-4684-96c8-d91334deb94f"
},
{
label: "MJ V5.1",
text: "v 5.1",
type: "mj",
value: "e1226715-e969-44c4-b18b-f2ad5dae5d2f"
}, {
label: "MJ V5.0",
text: "v 5",
type: "mj",
value: "afb7bea1-4eda-46ea-8165-34701b4566bf"
}, {
label: "MJ V4.0",
text: "v 4",
type: "mj",
value: "d05b8497-7f4a-4890-8fac-89f1803984d2"
}, {
label: "NIJI V6",
text: "niji 6",
type: "niji",
value: "99377cad-c103-4cee-a958-86a104879328"
}, {
label: "NIJI V5",
text: "niji 5",
type: "niji",
value: "53cec077-9885-4635-ab18-e021066b2c4c"
}, {
label: "NIJI V4",
text: "niji 4",
type: "niji",
value: "6a7199fe-6e0d-40a9-9772-b5eb3d2e2e66"
},
])
}
/**
* 获取生图的比例
* @returns
*/
GetMJImageScale() {
return successMessage([{
label: "1:1",
text: "1:1",
value: "3e2772f2-041c-49c6-ba13-d0ed120310b8"
}, {
label: "4:3",
text: "4:3",
value: "fcef555c-1958-4082-88fe-434782aa8151"
}, {
label: "3:4",
text: "3:4",
value: "13f71d53-73a3-4c9b-9c1e-6e7e939aee73"
}, {
label: "16:9",
text: "16:9",
value: "bf33ce1a-15cd-4901-b38e-89543cf14a1f"
}, {
label: "9:16",
text: "9:16",
value: "fd4641e2-97f4-4a86-8616-4965e05f3348"
}])
}
/**
* 返回mj生成图片方式的分类
*/
@@ -18,20 +91,24 @@ export class MjSetting {
return {
code: 1,
data: [{
label: "本地MJ",
value: "local_mj"
label: "本地MJ(待开发)",
value: "local_mj",
disable: true
},
{
label: "代理MJ(待开发)",
value: "remote_mj"
value: "remote_mj",
disable: true
},
{
label: "浏览器模式",
value: "browser_mj"
value: "browser_mj",
disable: false
},
{
label: "API模式(待开发)",
value: "api_mj"
label: "API模式",
value: "api_mj",
disable: false
}
]
}