feat(search-route): handle history processing after llm validation

This commit is contained in:
ItzCrazyKns
2025-11-13 11:52:12 +05:30
parent e499c0b96e
commit 3bcf646af1

View File

@@ -30,12 +30,6 @@ export const POST = async (req: Request) => {
body.optimizationMode = body.optimizationMode || 'balanced'; body.optimizationMode = body.optimizationMode || 'balanced';
body.stream = body.stream || false; body.stream = body.stream || false;
const history: BaseMessage[] = body.history.map((msg) => {
return msg[0] === 'human'
? new HumanMessage({ content: msg[1] })
: new AIMessage({ content: msg[1] });
});
const registry = new ModelRegistry(); const registry = new ModelRegistry();
const [llm, embeddings] = await Promise.all([ const [llm, embeddings] = await Promise.all([
@@ -46,6 +40,12 @@ export const POST = async (req: Request) => {
), ),
]); ]);
const history: BaseMessage[] = body.history.map((msg) => {
return msg[0] === 'human'
? new HumanMessage({ content: msg[1] })
: new AIMessage({ content: msg[1] });
});
const searchHandler: MetaSearchAgentType = searchHandlers[body.focusMode]; const searchHandler: MetaSearchAgentType = searchHandlers[body.focusMode];
if (!searchHandler) { if (!searchHandler) {