chatgpt-plugin/apps/md.js
ikechan8370 cb3e57bea3
feat: experimental markdown support (#658)
* feat: test button

* fix: enter

* fix: bing suggested

* fix: bing suggested

* fix: bing suggested

* fix: button under icqq

* fix: 删除suno心跳

* fix: add default md handler

* fix: duplicate this

* fix: add a button

* Update md.js

* Update md.js

* fix: api stream

* fix: claude.ai

* fix: md enhancement

* fix: optional buttons

* fix: mode name

* fix: ignore md while not enable md
2024-03-05 14:12:50 +08:00

40 lines
992 B
JavaScript

import plugin from '../../../lib/plugins/plugin.js'
import {Config} from '../utils/config.js'
export class ChatGPTMarkdownHandler extends plugin {
constructor () {
super({
name: 'chatgptmd处理器',
priority: -100,
namespace: 'chatgpt-plugin',
handler: [{
key: 'chatgpt.markdown.convert',
fn: 'mdHandler'
}]
})
}
async mdHandler (e, options, reject) {
const { content, prompt, use } = options
if (Config.enableMd) {
let mode = transUse(use)
return `> ${prompt}\n\n---\n${content}\n\n---\n*当前模式:${mode}*`
} else {
return content
}
}
}
function transUse (use) {
let useMap = {
api: Config.model,
bing: '必应(Copilot)' + Config.toneStyle,
gemini: Config.geminiModel,
xh: '讯飞星火 ' + Config.xhmode,
qwen: '通义千问 ' + Config.qwenModel,
claude2: 'Claude 3 Sonnet',
glm4: 'ChatGLM4',
chat3: 'ChatGPT官网'
}
return useMap[use] || use
}