mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
feat: 新增Gemini 和 GPT 的临时对话开关 (closes #85)
This commit is contained in:
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- 修复 ChatGPT 缺少系统提示词的问题
|
||||
- 尝试修复 ChatGPT 选择模型的问题 (目前应该是灰度测试,有些账号界面不一样,并且作者没有会员账号仅为猜测修复)
|
||||
|
||||
### ✨ Added
|
||||
- **WebUI**
|
||||
- Gemini 和 ChatGPT 的临时对话模式开关(现可以在适配器设置中单独开关)
|
||||
|
||||
## [3.6.6] - 2026-04-12
|
||||
|
||||
### 🐛 Fixed
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
import { logger } from '../../utils/logger.js';
|
||||
|
||||
// --- 配置常量 ---
|
||||
const TARGET_URL = 'https://chatgpt.com/?temporary-chat=true'; // 感谢 @zhongjianhua163 提供方案
|
||||
const TARGET_URL = 'https://chatgpt.com/'; // 基础URL
|
||||
const INPUT_SELECTOR = '.ProseMirror';
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,10 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) {
|
||||
const sendBtnLocator = page.getByRole('button', { name: 'Send prompt' });
|
||||
|
||||
try {
|
||||
const useTemp = config?.backend?.adapter?.chatgpt_text?.temporaryChat || false;
|
||||
const targetUrl = useTemp ? 'https://chatgpt.com/?temporary-chat=true' : 'https://chatgpt.com/'; // 感谢 @zhongjianhua163 提供临时对话方案
|
||||
logger.info('适配器', '开启新会话...', meta);
|
||||
await gotoWithCheck(page, TARGET_URL);
|
||||
await gotoWithCheck(page, targetUrl);
|
||||
|
||||
// 1. 等待输入框加载
|
||||
await waitForInput(page, INPUT_SELECTOR, { click: false });
|
||||
@@ -258,9 +260,21 @@ export const manifest = {
|
||||
displayName: 'ChatGPT (文本生成)',
|
||||
description: '使用 ChatGPT 官网生成文本,支持多模型切换和图片上传。需要已登录的 ChatGPT 账户,若需要选择模型,请使用会员账号 (包含 K12 教室认证账号)。',
|
||||
|
||||
// 配置项模式
|
||||
configSchema: [
|
||||
{
|
||||
key: 'temporaryChat',
|
||||
label: '临时对话',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
note: '开启后将使用临时对话模式 (?temporary-chat=true)'
|
||||
}
|
||||
],
|
||||
|
||||
// 入口 URL
|
||||
getTargetUrl(config, workerConfig) {
|
||||
return TARGET_URL;
|
||||
const useTemp = config?.backend?.adapter?.chatgpt_text?.temporaryChat || false;
|
||||
return useTemp ? 'https://chatgpt.com/?temporary-chat=true' : 'https://chatgpt.com/';
|
||||
},
|
||||
|
||||
// 模型列表
|
||||
|
||||
@@ -41,12 +41,15 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) {
|
||||
logger.info('适配器', '开启新会话...', meta);
|
||||
await gotoWithCheck(page, TARGET_URL);
|
||||
|
||||
try {
|
||||
logger.debug('适配器', '尝试点击 Temporary chat...', meta);
|
||||
const tempChatBtn = page.getByRole('button', { name: 'Temporary chat' });
|
||||
await safeClick(page, tempChatBtn, { bias: 'button', timeout: 3000 });
|
||||
} catch (e) {
|
||||
logger.debug('适配器', '未找到 Temporary chat 按钮或点击失败,忽略', meta);
|
||||
const useTempChat = config?.backend?.adapter?.gemini?.temporaryChat || false;
|
||||
if (useTempChat) {
|
||||
try {
|
||||
logger.debug('适配器', '尝试点击 Temporary chat...', meta);
|
||||
const tempChatBtn = page.getByRole('button', { name: 'Temporary chat' });
|
||||
await safeClick(page, tempChatBtn, { bias: 'button', timeout: 3000 });
|
||||
} catch (e) {
|
||||
logger.debug('适配器', '未找到 Temporary chat 按钮或点击失败,忽略', meta);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 等待输入框加载
|
||||
@@ -226,6 +229,17 @@ export const manifest = {
|
||||
displayName: 'Google Gemini (图片、视频生成)',
|
||||
description: '使用 Google Gemini 官网生成图片和视频,支持参考图片上传。需要已登录的 Google 账户,免费账户图片生成有速率限制,视频生成必须为会员账户才可使用。',
|
||||
|
||||
// 配置项模式
|
||||
configSchema: [
|
||||
{
|
||||
key: 'temporaryChat',
|
||||
label: '临时对话',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
note: '开启后将使用临时对话模式'
|
||||
}
|
||||
],
|
||||
|
||||
// 入口 URL
|
||||
getTargetUrl(config, workerConfig) {
|
||||
return TARGET_URL;
|
||||
|
||||
@@ -39,12 +39,15 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) {
|
||||
logger.info('适配器', '开启新会话...', meta);
|
||||
await gotoWithCheck(page, TARGET_URL);
|
||||
|
||||
try {
|
||||
logger.debug('适配器', '尝试点击 Temporary chat...', meta);
|
||||
const tempChatBtn = page.getByRole('button', { name: 'Temporary chat' });
|
||||
await safeClick(page, tempChatBtn, { bias: 'button', timeout: 3000 });
|
||||
} catch (e) {
|
||||
logger.debug('适配器', '未找到 Temporary chat 按钮或点击失败,忽略', meta);
|
||||
const useTempChat = config?.backend?.adapter?.gemini_text?.temporaryChat || false;
|
||||
if (useTempChat) {
|
||||
try {
|
||||
logger.debug('适配器', '尝试点击 Temporary chat...', meta);
|
||||
const tempChatBtn = page.getByRole('button', { name: 'Temporary chat' });
|
||||
await safeClick(page, tempChatBtn, { bias: 'button', timeout: 3000 });
|
||||
} catch (e) {
|
||||
logger.debug('适配器', '未找到 Temporary chat 按钮或点击失败,忽略', meta);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 等待输入框加载
|
||||
@@ -206,6 +209,17 @@ export const manifest = {
|
||||
displayName: 'Google Gemini (文本生成)',
|
||||
description: '使用 Google Gemini 官网生成文本,支持多模型切换和图片上传。需要已登录的 Google 账户。',
|
||||
|
||||
// 配置项模式
|
||||
configSchema: [
|
||||
{
|
||||
key: 'temporaryChat',
|
||||
label: '临时对话',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
note: '开启后将使用临时对话模式'
|
||||
}
|
||||
],
|
||||
|
||||
getTargetUrl(config, workerConfig) {
|
||||
return TARGET_URL;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user