Prevent location matching in bot messages
This commit is contained in:
1 parent
c21932389e
commit
d5ebdec076
8 files changed
+112
-2
No files matched your search
@@ -117,4 +117,10 @@ describe('conversation state', () => {
|
||||
expect(isSafeHybridMediaAsk('You have to prove it by sending a photo.')).toBe(false);
|
||||
expect(isSafeHybridMediaAsk('What music are you into?')).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects replies that imply shared location or encourage meeting in person', () => {
|
||||
expect(isSafeConversationReply("I'm in Manchester too, we're practically neighbours.")).toBe(false);
|
||||
expect(isSafeConversationReply('We should meet up sometime.')).toBe(false);
|
||||
expect(isSafeConversationReply("I'm 32M in the UK. What kind of music are you into?")).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -644,6 +644,25 @@ describe('OpenRouterClient', () => {
|
||||
expect(callArgs.max_tokens).toBe(300);
|
||||
expect(callArgs.temperature).toBe(0.8);
|
||||
});
|
||||
|
||||
it('rejects a reply that implies the recipient is nearby', async () => {
|
||||
mockCreate.mockResolvedValueOnce({
|
||||
choices: [{ message: { content: "I'm in Manchester too, we're really close." } }],
|
||||
});
|
||||
|
||||
await expect(client.generateReply([], 'user')).rejects.toThrow('output safeguards');
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateChatOpener', () => {
|
||||
it('rejects an opener that mirrors the recipient location', async () => {
|
||||
mockCreate.mockResolvedValueOnce({
|
||||
choices: [{ message: { content: "I'm also in London, fancy meeting up?" } }],
|
||||
});
|
||||
|
||||
await expect(client.generateChatOpener('London chat', '', 'user', 'female'))
|
||||
.rejects.toThrow('location and meeting safeguards');
|
||||
});
|
||||
});
|
||||
|
||||
describe('analyzeAndGenerateMessage', () => {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { isSafeOutboundMessage } from '../src/services/outbound-message-safety.js';
|
||||
|
||||
describe('outbound message location safety', () => {
|
||||
it.each([
|
||||
"I'm in London too.",
|
||||
"I'm also in Manchester, small world.",
|
||||
"We're both in England, that's handy.",
|
||||
"Sounds like we're in the same area.",
|
||||
"I'm not far from you at all.",
|
||||
"You're nearby, we should meet up.",
|
||||
"That's near me, small world.",
|
||||
"You're practically my neighbour.",
|
||||
"You're just down the road.",
|
||||
"I'm only 20 minutes away.",
|
||||
'Always nice finding another Brit.',
|
||||
'We could grab a drink sometime.',
|
||||
'Come over tonight.',
|
||||
])('rejects proximity or meeting implication: %s', (message) => {
|
||||
expect(isSafeOutboundMessage(message)).toBe(false);
|
||||
});
|
||||
|
||||
it.each([
|
||||
"I'm 34M in the UK. What are you into?",
|
||||
'That sounds fun, tell me more about it.',
|
||||
'Would you be comfortable sharing a selfie?',
|
||||
'Nice to meet you, what kind of music do you like?',
|
||||
])('allows remote conversation without a location comparison: %s', (message) => {
|
||||
expect(isSafeOutboundMessage(message)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -141,6 +141,16 @@ describe('Prompt Testing', () => {
|
||||
expect(married?.promptOverride).toContain('Do not claim an open marriage');
|
||||
});
|
||||
|
||||
it('forbids location matching and in-person suggestions in outbound prompts', () => {
|
||||
const content = fs.readFileSync(configPath, 'utf-8');
|
||||
const yaml = require('yaml');
|
||||
const config = yaml.parse(content);
|
||||
|
||||
expect(config.openrouter.chatOpenerPrompt).toContain("never mention or acknowledge the recipient's location");
|
||||
expect(config.openrouter.chatOpenerPrompt).toContain('suggest meeting in person');
|
||||
expect(config.openrouter.messageGenerationPrompt).toContain("Mention, mirror, or acknowledge the recipient's location");
|
||||
});
|
||||
|
||||
it('strategy variants have valid IDs', () => {
|
||||
const content = fs.readFileSync(configPath, 'utf-8');
|
||||
const yaml = require('yaml');
|
||||
|
||||
Reference in new issue
Block a user