fix message reversing
This commit is contained in:
@@ -32,7 +32,8 @@ async function router(
|
||||
const prompt = `You're a highly helpful AI assistant, tasked with routing the user's query to the appropriate tool.
|
||||
You should analyze the user's input, and choose the appropriate tool to use.`;
|
||||
|
||||
const recentHumanMessage = state.messages
|
||||
const messagesCopy = state.messages;
|
||||
const recentHumanMessage = messagesCopy
|
||||
.reverse()
|
||||
.find((m) => m.getType() === "human");
|
||||
|
||||
@@ -65,7 +66,11 @@ function handleRoute(
|
||||
|
||||
async function handleGeneralInput(state: GenerativeUIState) {
|
||||
const llm = new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 });
|
||||
const response = await llm.invoke(state.messages);
|
||||
const messagesCopy = state.messages;
|
||||
messagesCopy.reverse();
|
||||
console.log("messagesCopy", messagesCopy);
|
||||
|
||||
const response = await llm.invoke(messagesCopy);
|
||||
|
||||
return {
|
||||
messages: [response],
|
||||
|
||||
Reference in New Issue
Block a user