fix: map input to source_data fallback and spread context vars into template variables
This commit is contained in:
parent
3bb9923255
commit
f1c1d107ca
@ -147,12 +147,18 @@ export async function completionRoute(fastify: FastifyInstance): Promise<void> {
|
|||||||
// Stage 5: Prompt assembly
|
// Stage 5: Prompt assembly
|
||||||
// Use taskType directly for template lookup (so tip_transceiver_enrich.yaml is used,
|
// Use taskType directly for template lookup (so tip_transceiver_enrich.yaml is used,
|
||||||
// not the generic_qa fallback from routing). The router only selects the model.
|
// not the generic_qa fallback from routing). The router only selects the model.
|
||||||
|
// Spread context fields so templates can reference {{source_data}}, {{source_url}}, etc.
|
||||||
|
// Fall back to input for {{source_data}} when not explicitly provided in context.
|
||||||
|
const contextVars = context
|
||||||
|
? Object.fromEntries(Object.entries(context).map(([k, v]) => [k, v as string]))
|
||||||
|
: {};
|
||||||
const resolved = resolvePrompt(
|
const resolved = resolvePrompt(
|
||||||
taskType ?? decision.prompt_template,
|
taskType ?? decision.prompt_template,
|
||||||
{
|
{
|
||||||
input,
|
input,
|
||||||
user_context: context,
|
user_context: context,
|
||||||
source_data: context?.['source_data'] as string | undefined,
|
source_data: (context?.['source_data'] as string | undefined) ?? input,
|
||||||
|
...contextVars,
|
||||||
},
|
},
|
||||||
language ?? 'en',
|
language ?? 'en',
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user