@istarry/spoon-companion 0.6.3 → 0.7.1
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/appraise.js +9 -4
- package/lib/catalog.js +416 -378
- package/lib/prompt.js +24 -10
- package/lib/react.js +118 -43
- package/lib/state.js +175 -13
- package/package.json +1 -1
- package/plugin.js +19 -8
package/lib/appraise.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
// compassion 对方在难受(共情通道:温柔/心疼/担心)
|
|
25
25
|
// play 玩笑/逗乐通道
|
|
26
26
|
// social 孤独感(没人理我)
|
|
27
|
+
// desire 身体想要的程度(由驱动和场景算出来的,不从字面判断)
|
|
27
28
|
// hunger/energy/load 内部驱动(饿/困/心累)
|
|
28
29
|
//
|
|
29
30
|
// 每个情绪在目录里带一份 signal(哪些维度、落在什么区间),这里负责打分选最像的那个。
|
|
@@ -57,6 +58,7 @@ const WEIGHTS = {
|
|
|
57
58
|
selfAgency: 0.9,
|
|
58
59
|
selfEsteem: 0.6,
|
|
59
60
|
social: 1.5,
|
|
61
|
+
desire: 1.8,
|
|
60
62
|
hunger: 1.6,
|
|
61
63
|
energy: 1.5,
|
|
62
64
|
load: 1.3,
|
|
@@ -81,12 +83,12 @@ function rangeFit(value, [lo, hi]) {
|
|
|
81
83
|
const NEUTRAL = {
|
|
82
84
|
valence: 0, arousal: 0.45, relevance: 0.5, norm: 0, fairness: 0, expectation: 0,
|
|
83
85
|
novelty: 0.3, certainty: 0.7, intimacy: 0.2, recognition: 0, spotlight: 0, benefit: 0,
|
|
84
|
-
resolution: 0, rivalry: 0, compassion: 0, play: 0, social: 0, hunger: 0, load: 0,
|
|
86
|
+
resolution: 0, rivalry: 0, compassion: 0, play: 0, social: 0, desire: 0, hunger: 0, load: 0,
|
|
85
87
|
attention: 0.5, selfEsteem: 0.55, coping: 0.5, energy: 0.5,
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
/** 这些维度是引擎按她的状态算出来的,任何时候都算数(不是「事件没说」) */
|
|
89
|
-
export const DERIVED_DIMS = ['coping', 'selfEsteem', 'intimacy', 'energy', 'hunger', 'load', 'social']
|
|
91
|
+
export const DERIVED_DIMS = ['coping', 'selfEsteem', 'intimacy', 'energy', 'hunger', 'load', 'social', 'desire']
|
|
90
92
|
|
|
91
93
|
/** 单个维度的吻合度:数值维度落在区间里 = 1,越远越掉;分类维度(agency 这类)只认相等 */
|
|
92
94
|
function fitOf(value, range) {
|
|
@@ -164,6 +166,7 @@ export function normalizeDims(input = {}, context = {}) {
|
|
|
164
166
|
compassion: clamp01(input.compassion ?? 0),
|
|
165
167
|
play: clamp01(input.play ?? 0),
|
|
166
168
|
social: clamp01(input.social ?? 0),
|
|
169
|
+
desire: clamp01(input.desire ?? context.desire ?? 0),
|
|
167
170
|
hunger: clamp01(input.hunger ?? context.hunger ?? 0),
|
|
168
171
|
energy: clamp01(energy),
|
|
169
172
|
load: clamp01(input.load ?? context.load ?? 0),
|
|
@@ -216,6 +219,7 @@ export function appraise(event = {}, context = {}) {
|
|
|
216
219
|
traits: context.traits,
|
|
217
220
|
energy: context.energy,
|
|
218
221
|
hunger: context.hunger,
|
|
222
|
+
desire: context.desire,
|
|
219
223
|
load: context.load,
|
|
220
224
|
intimacy,
|
|
221
225
|
})
|
|
@@ -235,8 +239,9 @@ export function appraise(event = {}, context = {}) {
|
|
|
235
239
|
if (evidence === 0 && emo.family !== 'drive') continue
|
|
236
240
|
ranked.push({ emo, score, hits })
|
|
237
241
|
}
|
|
238
|
-
// 分数接近时,「约束更多而且都符合」的那个更贴切(平局用命中数破)
|
|
239
|
-
|
|
242
|
+
// 分数接近时,「约束更多而且都符合」的那个更贴切(平局用命中数破);
|
|
243
|
+
// 还是平局就看 priority —— 欲望家族带 2,这样「想要」不会被「感激」压掉
|
|
244
|
+
ranked.sort((a, b) => (b.score - a.score) || (b.hits - a.hits) || ((b.emo.priority ?? 0) - (a.emo.priority ?? 0)))
|
|
240
245
|
const best = ranked[0]
|
|
241
246
|
const runnerUp = ranked[1]
|
|
242
247
|
|