DEV Community

Cover image for Build an AI-powered blogging platform (Next.js, Langchain & CopilotKit)

Build an AI-powered blogging platform (Next.js, Langchain & CopilotKit)

Bonnie on April 11, 2024

TL;DR In this article, you will learn how to build an AI-powered blogging platform that can search the web and research any topic for a ...
Collapse
 
rahmanoff profile image
Kostiantyn Rakhmanov

Hi! Need help)
I do not have next.config.js file in main folder. I have next.config.mjs file.
And I have error after "next dev" - ReferenceError: module is not defined in ES module scope
at file:///Users/kr/PJ/FE/next-ai-blog/next.config.mjs:6:1

Any advice?

Collapse
 
the_greatbonnie profile image
Bonnie

Hey Kostiantyn,

Rename next.config.mjs to next.config.js

Collapse
 
rahmanoff profile image
Kostiantyn Rakhmanov

Sorry, but another error from me)
pls see pic
Image description

Thread Thread
 
the_greatbonnie profile image
Bonnie

Not sure what is the issue, but you can check the project demo repo and see where your code doesn't look good.

github.com/TheGreatBonnie/aipowere...

Thread Thread
 
rahmanoff profile image
Kostiantyn Rakhmanov

Did fork and try to use it with my env file, but no luck...
Image description

Thread Thread
 
rahmanoff profile image
Kostiantyn Rakhmanov

Got this in console:

Error: aborted
    at connResetException (node:internal/errors:787:14)
    at abortIncoming (node:_http_server:793:17)
    at socketOnClose (node:_http_server:787:3)
    at Socket.emit (node:events:530:35)
    at TCP.<anonymous> (node:net:337:12)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 'ECONNRESET'
}
 ⨯ uncaughtException: Error: aborted
    at connResetException (node:internal/errors:787:14)
    at abortIncoming (node:_http_server:793:17)
    at socketOnClose (node:_http_server:787:3)
    at Socket.emit (node:events:530:35)
    at TCP.<anonymous> (node:net:337:12)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 'ECONNRESET'
}
 ⨯ uncaughtException: Error: aborted
    at connResetException (node:internal/errors:787:14)
    at abortIncoming (node:_http_server:793:17)
    at socketOnClose (node:_http_server:787:3)
    at Socket.emit (node:events:530:35)
    at TCP.<anonymous> (node:net:337:12)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 'ECONNRESET'
}
 ⨯ Error: failed to pipe response
    at pipeToNodeResponse (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/pipe-readable.js:111:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DevServer.runEdgeFunction (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/next-server.js:1214:13)
    at async NextNodeServer.handleCatchallRenderRequest (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/next-server.js:245:37)
    at async DevServer.handleRequestImpl (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/base-server.js:791:17)
    at async /Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/dev/next-dev-server.js:331:20
    at async Span.traceAsyncFn (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/trace/trace.js:151:20)
    at async DevServer.handleRequest (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/dev/next-dev-server.js:328:24)
    at async invokeRender (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/lib/router-server.js:174:21)
    at async handleRequest (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/lib/router-server.js:353:24)
    at async requestHandlerImpl (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/lib/router-server.js:377:13)
    at async Server.requestListener (/Users/kr/PJ/FE/ai-next-blog/node_modules/next/dist/server/lib/start-server.js:140:13) {
  [cause]: NotFoundError: 404 The model `gpt-4-1106-preview` does not exist or you do not have access to it.
      at APIError.generate (webpack-internal:///(rsc)/./node_modules/openai/error.js:53:20)
      at OpenAI.makeStatusError (webpack-internal:///(rsc)/./node_modules/openai/core.js:264:33)
      at OpenAI.makeRequest (webpack-internal:///(rsc)/./node_modules/openai/core.js:307:30)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async ChatCompletionStream._createChatCompletion (webpack-internal:///(rsc)/./node_modules/openai/lib/ChatCompletionStream.js:53:24)
      at async ChatCompletionStream._runChatCompletion (webpack-internal:///(rsc)/./node_modules/openai/lib/AbstractChatCompletionRunner.js:314:16) {
    status: 404,
    headers: {
      'alt-svc': 'h3=":443"; ma=86400',
      'cf-cache-status': 'DYNAMIC',
      'cf-ray': '874c924abaaa5b8e-VIE',
      connection: 'keep-alive',
      'content-encoding': 'br',
      'content-type': 'application/json; charset=utf-8',
      date: 'Mon, 15 Apr 2024 14:19:35 GMT',
      server: 'cloudflare',
      'set-cookie': '__cf_bm=YnMJrep7yuKzt8JXS1LTWm_M2LLBnniVPFSVUrC5nN0-1713190775-1.0.1.1-XXcAmhUdgBcpxoVvN_h86_AKpgjDZNSLuuwdSf7PXqJliNQeDK2VpzqL3bX_bYwBkxwMa7W9r9P9fhSwwcun.A; path=/; expires=Mon, 15-Apr-24 14:49:35 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=6pWzLw_f2J3oPrQBtem9TXSd2iStv8JByfOA1OQXG00-1713190775725-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None',
      'strict-transport-security': 'max-age=15724800; includeSubDomains',
      'transfer-encoding': 'chunked',
      vary: 'Origin',
      'x-request-id': 'req_e998f2b6b4d3ef27634891323a1cae80'
    },
    error: {
      message: 'The model `gpt-4-1106-preview` does not exist or you do not have access to it.',
      type: 'invalid_request_error',
      param: null,
      code: 'model_not_found'
    },
    code: 'model_not_found',
    param: null,
    type: 'invalid_request_error'
  }
}
 ○ Compiling /_error ...
 ✓ Compiled /_error in 4.7s (6547 modules)
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
rahmanoff profile image
Kostiantyn Rakhmanov

Dear Bonnie, looks like in my region there some restrictions from Open AI. I am in Ukraine.
I try to use Germany via VPN and looks like it works.
Hope for some response soon.

Image description

Thread Thread
 
the_greatbonnie profile image
Bonnie

Happy to hear that.

Hope everything works fine now.

Thread Thread
 
rahmanoff profile image
Kostiantyn Rakhmanov

Yes, now it is ok!)

Collapse
 
rahmanoff profile image
Kostiantyn Rakhmanov

Oh! Thanks, it works now)

Thread Thread
 
the_greatbonnie profile image
Bonnie

I am happy to hear that.

Feel free to reach out if you come across any other issues.

Collapse
 
dyfet profile image
David Sugar • Edited

Of course when I initially read the title my first thought was to imagine a complete blogging site that uses ai to write everything ;). Maybe the comments generated by ai too! Too soon? Perhaps, thankfully, but one day artificial idiocy may reach the point that natural humans on the internet do become as rare as a bald eagle in the sky...

Collapse
 
uliyahoo profile image
uliyahoo

Part II idea?? @the_greatbonnie

Collapse
 
the_greatbonnie profile image
Bonnie

Sounds great.

Collapse
 
mampha profile image
Mampha • Edited

This is such a great project @the_greatbonnie. Wish you more successful projects. Please I have a question about copilotkit AI does it support gpt-3.5-turbo or it only supports gpt-4-turbo? Because I have tried to search online but no obvious answer coming through. I will be expecting your response about this. Thanks.

Collapse
 
the_greatbonnie profile image
Bonnie

Thanks, Mampha.

All GPT models are supported.

Collapse
 
envitab profile image
Ekemini Samuel

Well explained and detailed! Keep up the good work Bonnie.

Collapse
 
the_greatbonnie profile image
Bonnie

Thanks, Samuel.

Collapse
 
envitab profile image
Ekemini Samuel

You're welcome, Bonnie.

Collapse
 
uliyahoo profile image
uliyahoo

Another great Article Bonnie. Great job!

Collapse
 
the_greatbonnie profile image
Bonnie

Thanks, Uli.

Collapse
 
fernandezbaptiste profile image
Bap

Super insightful 🌟

Collapse
 
the_greatbonnie profile image
Bonnie

Thanks, Bap.

Collapse
 
nevodavid profile image
Nevo David

Great stuff!

Collapse
 
the_greatbonnie profile image
Bonnie

Thanks, David.

Collapse
 
thomas123 profile image
Thomas

Nice one

Collapse
 
the_greatbonnie profile image
Bonnie

Thanks, Thomas.

Collapse
 
jeremiah_the_dev_man profile image
Jeremiah

This look like a fun build, but at a glance, where is the Langchain part?

Collapse
 
the_greatbonnie profile image
Bonnie • Edited

The backend part.

You can learn more here.

docs.copilotkit.ai/getting-started...

Collapse
 
james0123 profile image
James

Where is the blog though?

Collapse
 
the_greatbonnie profile image
Bonnie

It is not deployed yet.

You can clone the GitHub repo, and deploy it.

Collapse
 
neurabot profile image
Neurabot

Exceptional. I have already heard about it without knowing how make it.

My main worry is how develop an AI-app which can respond efficiently to any social media post when you aren't connected. When solvely you're online, you suspend deserving.

Collapse
 
debchy profile image
Debashis Chowdhury

I have changed the ChatOpenAI model name to gpt-3.5-turbo-instruct.
Still the api/copilotkit is throwing error

"The model gpt-4o does not exist or you do not have access to it"

Collapse
 
mike_earley_2ac31f69e25a7 profile image
Mike Earley

What are folks thoughts about doing this in Astro and AstroDB instead of next.js?

Collapse
 
excel_raji_867783892636cb profile image
Excel Raji

hey y'all, please I keep getting this error

Image description