vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
9.31k stars 1.35k forks source link

examples/next-huggingface doesn't work. #1338

Open JDiegoRojas opened 4 months ago

JDiegoRojas commented 4 months ago

Description

Description: When entering any entry in the chat, the request does not materialize and you get the errors "failed to pipe response" and "ECONNRESET".

Environment: OS: Windows 10 Pro 22H2 Node version: v20.11.0 Next.js version: 14.1.1 AI SDK version: 3.0.22

How to reproduce the bug:

  1. pnpm create next-app --example https://github.com/vercel/ai/tree/main/examples/next-huggingface next-huggingface-app
  2. cd next-huggingface-app
  3. Set HUGGINGFACE_API_KEY in .env.local
  4. pnpm dev
  5. go to http://localhost:3000/
  6. Write something in the input.

Code example

> next-huggingface@0.0.0 dev C:\Users\USER\Desktop\chatlab2\next-huggingface-app
> next dev

  ▲ Next.js 14.1.1
   - Local:        http://localhost:3000
   - Environments: .env.local

 ✓ Ready in 4.1s
 ○ Compiling / ...
 ✓ Compiled / in 7.9s (485 modules)
 ✓ Compiled in 917ms (232 modules)
 ○ Compiling /favicon.ico ...
 ✓ Compiled /api/chat in 7.5s (670 modules)
 ⨯ Error: failed to pipe response
    at pipeToNodeResponse (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\pipe-readable.js:111:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DevServer.runEdgeFunction (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\next-server.js:1214:13)
    at async NextNodeServer.handleCatchallRenderRequest (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\next-server.js:245:37)
    at async DevServer.handleRequestImpl (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\base-server.js:808:17)
    at async C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\dev\next-dev-server.js:331:20
    at async Span.traceAsyncFn (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\trace\trace.js:151:20)
    at async DevServer.handleRequest (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\dev\next-dev-server.js:328:24)
    at async invokeRender (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\lib\router-server.js:136:21)
    at async handleRequest (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\lib\router-server.js:315:24)
    at async requestHandlerImpl (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\lib\router-server.js:339:13)
    at async Server.requestListener (C:\Users\USER\Desktop\chatlab2\next-huggingface-app\node_modules\.pnpm\next@14.1.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\lib\start-server.js:140:13) {
  [cause]: Error: Model requires a Pro subscription; check out hf.co/pricing to learn more. Make sure to include your HF token in your query.
      at streamingRequest (webpack-internal:///(rsc)/./node_modules/.pnpm/@huggingface+inference@2.6.7/node_modules/@huggingface/inference/dist/index.js:329:23)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async textGenerationStream (webpack-internal:///(rsc)/./node_modules/.pnpm/@huggingface+inference@2.6.7/node_modules/@huggingface/inference/dist/index.js:653:5)
      at async Object.pull (webpack-internal:///(rsc)/./node_modules/.pnpm/ai@3.0.22_react@18.2.0_solid-js@1.8.16_svelte@4.2.14_vue@3.4.21_zod@3.22.4/node_modules/ai/dist/index.mjs:2214:37)
}
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'
}
 ○ Compiling /_error ...

Additional context

No response

georgegiosue commented 4 months ago

same problem

yasdev08 commented 4 months ago

Same !!! i didn't know what was the issue exactly i tried changing the api key but it's still giving the same error.