Unable to catch my response of newmessage within UseStream #5445
Unanswered
m99Tanishq
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Frontend
const { isLoading, submit, values, messages } = useStream<{
messages: Message[];
}>({
apiUrl: langgraphServerUrl,
defaultHeaders: { Authorization:
Bearer ${getToken()}
},assistantId: "payable-gpt",
threadId,
messagesKey: "messages",
});
const handleSubmit = async (
content: string,
files: File[],
agent_mode: string
) => {
if (isLoading) return;
};
useEffect(() => {
console.log("Messages:", messages);
}, [messages]);
---------------------------------Backend---------------------------------------
export const XYZcontroller = asyncHandler(async (req, res) => {
res.writeHead(200, {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache",
Connection: "keep-alive",
});
const { threadId } = req.params;
const { input, config } = req.body;
if (!threadId) throw new AppError("Thread ID is required");
const files = input?.messages?.[0]?.additional_kwargs?.component?.files || [];
const uploadedFiles = files.map((file: any) => ({
fileName: file.name,
type: file.type,
fileUrl: file.url,
}));
try {
const eventStream = payableGptGraph.streamEvents(
{
user_message: [new HumanMessage(input.messages[0].content, { files })],
},
{
...config,
configurable: {
...config?.configurable,
streamMode: ["messages", "values", "custom"],
thread_id:
pq-${req.clientId}-${req.userId}-${threadId}
,token: req.token,
uploadedFiles,
},
version: "v2",
}
);
} catch (error) {
console.error(error);
res.write("event: error\n\n");
res.end();
}
});
my Response is a plain simple text that I am recieving from backend
Beta Was this translation helpful? Give feedback.
All reactions