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
This commit is contained in:
ikechan8370 2024-03-05 14:12:50 +08:00 committed by GitHub
parent 58e6201e6e
commit cb3e57bea3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 610 additions and 126 deletions

40
apps/md.js Normal file
View file

@ -0,0 +1,40 @@
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
}