Open apperside opened 7 months ago
@apperside Hello, I think you should modify your nestjs code like this:
@Post('chat')
async chat(@Req() request, @Res() response): Promise<void> {
const copilotKit = new CopilotBackend();
await copilotKit.streamHttpServerResponse(request, response, new OpenAIAdapter());
}
Because streamHttpServerResponse
returns Promise<void>
, you can't get anything using its return value.
You should completely delegate everything to the CopilotBackend
instance.
BTW, the above code is a simple version for demo. It'll be better to create the CopilotBackend
instance in a service instead, in case of creating a new instance every time a request comes.
Please refer to this demo I made. https://github.com/ikudev/copilotkit-nestjs-demo
Describe the bug Hi, first of all thanks a lot for this fantastic piece of software! I have managed to integrate it in my NextJS app, I can see the chat sidebar appearing and the chat content be posted to my NestJS backend, where I am handling the request this way
I also have tried this
and this
By in any case the chat waits for the response indefinitely. By adding some breakpoint, the response is properly generated, but for some reason the clients does not receive it. What am I missing?
Many thanks