Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
if (!window.imagePatterns) {
window.imagePatterns = [
{ pattern: /```image\n([\s\S]*?)\n```/i, group: 1 },
{ pattern: /image:\s*(.+)/i, group: 1 },
{ pattern: /show me\s+(.+)/i, group: 1 },
{ pattern: /generate (?:an |a )?image of\s+(.+)/i, group: 1 },
{ pattern: /picture of\s+(.+)/i, group: 1 },
];
}
if (!window.audioPatterns) {
Expand All @@ -51,6 +47,16 @@
{ pattern: /```ui\n([\s\S]*?)\n```/i, group: 1 },
];
}
if (!window.voicePatterns) {
window.voicePatterns = [
{ pattern: /```voice\n([\s\S]*?)\n```/i, group: 1 },
];
}
if (!window.videoPatterns) {
window.videoPatterns = [
{ pattern: /```video\n([\s\S]*?)\n```/i, group: 1 },
];
}
}
} catch (e) { console.warn('polliLib configure failed', e); }
})();
Expand Down
31 changes: 31 additions & 0 deletions js/chat/chat-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,37 @@ document.addEventListener("DOMContentLoaded", () => {
});
}

const videoPatterns = window.videoPatterns || [];
for (const { pattern, group } of videoPatterns) {
const grpIndex = typeof group === 'number' ? group : 1;
const p = pattern.global ? pattern : new RegExp(pattern.source, pattern.flags + 'g');
aiContent = aiContent.replace(p, function () {
const args = arguments;
const prompt = args[grpIndex] && args[grpIndex].trim();
if (!prompt) return '';
// Video handling to be implemented
return '';
});
}

const voicePatterns = window.voicePatterns || [];
for (const { pattern, group } of voicePatterns) {
const grpIndex = typeof group === 'number' ? group : 1;
const p = pattern.global ? pattern : new RegExp(pattern.source, pattern.flags + 'g');
const matches = Array.from(aiContent.matchAll(p));
for (const match of matches) {
const text = match[grpIndex] && match[grpIndex].trim();
if (!text) continue;
try {
const sentences = text.split(/(?<=[.!?])\s+/).filter(s => s.trim().length > 0);
speakSentences(sentences);
} catch (e) {
console.warn('speakSentences failed', e);
}
}
aiContent = aiContent.replace(p, '');
}

aiContent = aiContent.replace(/\n{2,}/g, '\n').trim();
}

Expand Down
Loading