Update roster fixtures and redact live provider keys (T90)
This commit is contained in:
@@ -5,7 +5,7 @@ export type Rule = { id: string; role: string; match: { kind?: string; text: str
|
||||
export const textOf = (content: any): string => typeof content === 'string' ? content : (content ?? []).filter((part: any) => part.type === 'text').map((part: any) => part.text).join('\n');
|
||||
export function answerFor(rules: Rule[], transcript: any) {
|
||||
const system = JSON.stringify(transcript.messages.filter((message: any) => message.role === 'system'));
|
||||
const role = /P3 role:([a-z]+)/.exec(system)?.[1];
|
||||
const role = /P3 role:([a-zA-Z0-9_-]+)/.exec(system)?.[1];
|
||||
const last = transcript.messages.findLast((message: any) => message.role !== 'system');
|
||||
const rule = rules.find(rule => rule.role === role && (!rule.match.kind || rule.match.kind === last?.role) && textOf(last?.content).includes(rule.match.text));
|
||||
if (!rule) throw new Error(`No scripted rule for ${role}: ${JSON.stringify(last)}`);
|
||||
|
||||
Reference in New Issue
Block a user