koishi-plugin-openai-compatible 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/types.d.ts CHANGED
@@ -1,32 +1,37 @@
1
- export interface Message {
2
- role: 'system' | 'user' | 'assistant';
3
- content: string;
1
+ import { Schema } from 'koishi';
2
+ export type EmotionType = 'happy' | 'sad' | 'angry' | 'neutral' | 'surprised' | 'fearful' | 'disgusted' | 'excited' | 'calm' | 'confused' | string;
3
+ export interface EmojiConfig {
4
+ text: string;
5
+ image?: string;
4
6
  }
5
- export interface ChatCompletionRequest {
7
+ export interface Config {
8
+ endpoint: string;
9
+ apiKey: string;
6
10
  model: string;
7
- messages: Message[];
8
- temperature?: number;
9
- max_tokens?: number;
10
- top_p?: number;
11
- frequency_penalty?: number;
12
- presence_penalty?: number;
13
- }
14
- export interface ChatCompletionResponse {
15
- id: string;
16
- object: string;
17
- created: number;
18
- model: string;
19
- choices: Array<{
20
- index: number;
21
- message: {
22
- role: string;
23
- content: string;
24
- };
25
- finish_reason: string;
26
- }>;
27
- usage?: {
28
- prompt_tokens: number;
29
- completion_tokens: number;
30
- total_tokens: number;
11
+ prompt: string;
12
+ emotionAnalysis: {
13
+ enabled: boolean;
14
+ endpoint: string;
15
+ apiKey: string;
16
+ model: string;
17
+ prompt: string;
31
18
  };
19
+ emotionEmojis: Record<string, EmojiConfig>;
20
+ systemPrompt: string;
21
+ blacklist: string[];
22
+ cooldown: number;
23
+ showError: boolean;
24
+ maxTokens: number;
25
+ temperature: number;
26
+ topP: number;
27
+ presencePenalty: number;
28
+ frequencyPenalty: number;
29
+ emotionMaxTokens: number;
30
+ emotionTemperature: number;
31
+ timeout: number;
32
+ maxRetries: number;
33
+ emotionTimeout: number;
34
+ showEmotionImage: boolean;
35
+ imageAsMarkdown: boolean;
32
36
  }
37
+ export declare const Config: Schema<Config>;
package/lib/types.js CHANGED
@@ -1,2 +1,147 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Config = void 0;
4
+ const koishi_1 = require("koishi");
5
+ exports.Config = koishi_1.Schema.intersect([
6
+ koishi_1.Schema.object({
7
+ endpoint: koishi_1.Schema.string()
8
+ .description('OpenAI兼容API端点')
9
+ .default('https://api.openai.com/v1'),
10
+ apiKey: koishi_1.Schema.string()
11
+ .description('API密钥')
12
+ .role('secret'),
13
+ model: koishi_1.Schema.string()
14
+ .description('使用的模型')
15
+ .default('gpt-3.5-turbo'),
16
+ prompt: koishi_1.Schema.string()
17
+ .description('默认提示词(将被附加到用户消息前)')
18
+ .default(''),
19
+ }).description('基础配置'),
20
+ koishi_1.Schema.object({
21
+ emotionAnalysis: koishi_1.Schema.object({
22
+ enabled: koishi_1.Schema.boolean()
23
+ .description('是否启用情绪分析')
24
+ .default(true),
25
+ endpoint: koishi_1.Schema.string()
26
+ .description('情绪分析API端点(留空则使用主端点)')
27
+ .default(''),
28
+ apiKey: koishi_1.Schema.string()
29
+ .description('情绪分析API密钥(留空则使用主密钥)')
30
+ .role('secret')
31
+ .default(''),
32
+ model: koishi_1.Schema.string()
33
+ .description('情绪分析模型(建议使用较小较快的模型)')
34
+ .default('gpt-3.5-turbo'),
35
+ prompt: koishi_1.Schema.string()
36
+ .description('情绪分析提示词')
37
+ .default('请分析以下文本的情绪类型,只能返回以下情绪类型之一:happy(开心)、sad(悲伤)、angry(愤怒)、neutral(中性)、surprised(惊讶)、fearful(害怕)、disgusted(厌恶)、excited(兴奋)、calm(平静)、confused(困惑)。不要返回其他内容,只返回情绪类型单词。'),
38
+ }).description('情绪分析配置'),
39
+ }).description('情绪分析模块'),
40
+ koishi_1.Schema.object({
41
+ emotionEmojis: koishi_1.Schema.dict(koishi_1.Schema.object({
42
+ text: koishi_1.Schema.string()
43
+ .description('文本表情符号')
44
+ .required(),
45
+ image: koishi_1.Schema.string()
46
+ .description('图片链接(可选,支持jpg/png/gif)')
47
+ .default(''),
48
+ }))
49
+ .description('情绪类型对应的表情包配置')
50
+ .default({
51
+ 'happy': { text: '😊', image: '' },
52
+ 'sad': { text: '😢', image: '' },
53
+ 'angry': { text: '😠', image: '' },
54
+ 'neutral': { text: '😐', image: '' },
55
+ 'surprised': { text: '😲', image: '' },
56
+ 'fearful': { text: '😨', image: '' },
57
+ 'disgusted': { text: '🤢', image: '' },
58
+ 'excited': { text: '🤩', image: '' },
59
+ 'calm': { text: '😌', image: '' },
60
+ 'confused': { text: '😕', image: '' },
61
+ }),
62
+ showEmotionImage: koishi_1.Schema.boolean()
63
+ .description('是否显示情绪图片(如果配置了图片链接)')
64
+ .default(true),
65
+ imageAsMarkdown: koishi_1.Schema.boolean()
66
+ .description('是否使用Markdown格式显示图片(否则使用图片CQ码)')
67
+ .default(false),
68
+ }).description('情绪表情配置'),
69
+ koishi_1.Schema.object({
70
+ systemPrompt: koishi_1.Schema.string()
71
+ .description('系统提示词(用于system role)')
72
+ .default('你是一个有帮助的AI助手。'),
73
+ }).description('系统提示'),
74
+ koishi_1.Schema.object({
75
+ blacklist: koishi_1.Schema.array(String)
76
+ .description('黑名单用户ID')
77
+ .default([]),
78
+ cooldown: koishi_1.Schema.number()
79
+ .description('冷却时间(秒)')
80
+ .min(0)
81
+ .default(0),
82
+ showError: koishi_1.Schema.boolean()
83
+ .description('是否显示错误提示')
84
+ .default(true),
85
+ }).description('交互控制'),
86
+ koishi_1.Schema.object({
87
+ maxTokens: koishi_1.Schema.number()
88
+ .description('最大输出token数')
89
+ .min(1)
90
+ .max(4096)
91
+ .default(2048),
92
+ temperature: koishi_1.Schema.number()
93
+ .description('温度参数(0-2)')
94
+ .min(0)
95
+ .max(2)
96
+ .step(0.1)
97
+ .default(0.7),
98
+ topP: koishi_1.Schema.number()
99
+ .description('Top-p采样参数')
100
+ .min(0)
101
+ .max(1)
102
+ .step(0.1)
103
+ .default(1),
104
+ presencePenalty: koishi_1.Schema.number()
105
+ .description('存在惩罚(-2到2)')
106
+ .min(-2)
107
+ .max(2)
108
+ .step(0.1)
109
+ .default(0),
110
+ frequencyPenalty: koishi_1.Schema.number()
111
+ .description('频率惩罚(-2到2)')
112
+ .min(-2)
113
+ .max(2)
114
+ .step(0.1)
115
+ .default(0),
116
+ }).description('模型参数'),
117
+ koishi_1.Schema.object({
118
+ emotionMaxTokens: koishi_1.Schema.number()
119
+ .description('情绪分析最大token数')
120
+ .min(1)
121
+ .max(100)
122
+ .default(10),
123
+ emotionTemperature: koishi_1.Schema.number()
124
+ .description('情绪分析温度参数')
125
+ .min(0)
126
+ .max(1)
127
+ .step(0.1)
128
+ .default(0.1),
129
+ }).description('情绪分析参数'),
130
+ koishi_1.Schema.object({
131
+ timeout: koishi_1.Schema.number()
132
+ .description('主请求超时时间(毫秒)')
133
+ .min(1000)
134
+ .max(60000)
135
+ .default(30000),
136
+ emotionTimeout: koishi_1.Schema.number()
137
+ .description('情绪分析请求超时时间(毫秒)')
138
+ .min(1000)
139
+ .max(30000)
140
+ .default(5000),
141
+ maxRetries: koishi_1.Schema.number()
142
+ .description('最大重试次数')
143
+ .min(0)
144
+ .max(5)
145
+ .default(3),
146
+ }).description('网络设置'),
147
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-openai-compatible",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "这是一个适用于Koishi的OpenAI兼容聊天插件,支持与所有兼容OpenAI API的大模型进行聊天交互。",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {