promptfoo / promptfoo

Test your prompts, agents, and RAGs. Redteaming, pentesting, vulnerability scanning for LLMs. Improve your app's quality and catch problems. Compare performance of GPT, Claude, Gemini, Llama, and more. Simple declarative configs with command line and CI/CD integration.

Home Page:https://www.promptfoo.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Cannot GET /` Error in View page

sangwoo-joh opened this issue · comments

After I ran some tests, I suddenly got this error on the view page.
I've tried to evaluate other tests and view again, but it is still the same.
Where can I investigate this issue?

This only seems to happen when I clone the promptfoo repository locally, install it with npm install ../promptfoo and run it.

It sounds like there might be a build error with the next.js app that creates the static web view. Can you have a look at the build output from npm install?

I see this error as well, but doing the npm run local:web is a workaround to see the evals. But since that workflow is for development it's not stable, for e.g. I run into issues such as:

  • error Failed to handle request for /
    TypeError: fetch failed
    at Object.fetch (/usr/src/app/src/web/nextui/node_modules/next/dist/compiled/undici/index.js:1:26669)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async invokeRequest (/usr/src/app/src/web/nextui/node_modules/next/dist/server/lib/server-ipc/invoke-request.js:21:12)
    at async requestHandler (/usr/src/app/src/web/nextui/node_modules/next/dist/server/lib/start-server.js:336:33)
    at async Server. (/usr/src/app/src/web/nextui/node_modules/next/dist/server/lib/start-server.js:152:13) {
    cause: Error: connect ECONNREFUSED 127.0.0.1:44845
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 44845
    }
    }

and sometimes I don't

It sounds like there might be a build error with the next.js app that creates the static web view. Can you have a look at the build output from npm install?

Oh indeed, I had a build error.
I read the readme thoroughly again and found out that setting NEXT_PUBLIC_SUPABASE_URL=http:// and NEXT_PUBLIC_SUPABASE_ANON_KEY=abc fixed this issue.
Thanks a lot!

It sounds like there might be a build error with the next.js app that creates the static web view. Can you have a look at the build output from npm install?

Oh indeed, I had a build error. I read the readme thoroughly again and found out that setting NEXT_PUBLIC_SUPABASE_URL=http:// and NEXT_PUBLIC_SUPABASE_ANON_KEY=abc fixed this issue. Thanks a lot!

Actually, this could not resolve my issue.

Here is my build log:

λ npm install             

> promptfoo@0.51.0 prepare
> npm run install:nextui && npm run build:clean && npm run build


> promptfoo@0.51.0 install:nextui
> cd src/web/nextui && npm install


up to date, audited 611 packages in 1s

211 packages are looking for funding
  run `npm fund` for details

3 vulnerabilities (1 low, 2 moderate)

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

> promptfoo@0.51.0 build:clean
> rm -rf dist


> promptfoo@0.51.0 build
> tsc && cp src/*.html dist/src && cp src/python/wrapper.py dist/src/python && cp -r drizzle/ dist/ && npm run build:nextui && chmod +x dist/src/main.js


> promptfoo@0.51.0 build:nextui
> cd src/web/nextui && npm run build && { [ -z "$NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER" ] && cp -r out/ ../../../dist/src/web/nextui; } || true


> nextui@0.1.0 build
> next build

- warn Compiled with warnings

../../../node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/home/sangwoo-joh/type/work/promptfoo/node_modules/node-fetch/lib'

Import trace for requested module:
../../../node_modules/node-fetch/lib/index.js
../../fetch.ts
../../assertions.ts
../../index.ts
./src/app/api/eval/job/route.ts

../../../node_modules/nunjucks/src/node-loaders.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
../../../node_modules/nunjucks/src/node-loaders.js
../../../node_modules/nunjucks/src/loaders.js
../../../node_modules/nunjucks/index.js
../../util.ts
./src/app/api/progress/route.ts

../../evaluator.ts
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
../../evaluator.ts
../../index.ts
./src/app/api/eval/job/route.ts

../../testCases.ts
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
../../testCases.ts
../../index.ts
./src/app/api/eval/job/route.ts

./node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/home/sangwoo-joh/type/work/promptfoo/src/web/nextui/node_modules/node-fetch/lib'

Import trace for requested module:
./node_modules/node-fetch/lib/index.js
./node_modules/cross-fetch/dist/node-ponyfill.js
./node_modules/@supabase/supabase-js/dist/main/lib/fetch.js
./node_modules/@supabase/supabase-js/dist/main/SupabaseClient.js
./node_modules/@supabase/supabase-js/dist/main/index.js
./node_modules/@supabase/auth-helpers-shared/dist/index.js
./node_modules/@supabase/auth-helpers-nextjs/dist/index.js
./src/app/api/eval/job/[id]/route.ts

./node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/home/sangwoo-joh/type/work/promptfoo/src/web/nextui/node_modules/node-fetch/lib'

Import trace for requested module:
./node_modules/node-fetch/lib/index.js
./node_modules/cross-fetch/dist/node-ponyfill.js
./node_modules/@supabase/supabase-js/dist/main/lib/fetch.js
./node_modules/@supabase/supabase-js/dist/main/SupabaseClient.js
./node_modules/@supabase/supabase-js/dist/main/index.js
./node_modules/@supabase/auth-helpers-shared/dist/index.js
./node_modules/@supabase/auth-helpers-nextjs/dist/index.js
./src/app/eval/Eval.tsx


./src/app/eval/ResultsTable.tsx
192:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
195:13  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/app/eval/ResultsView.tsx
203:6  Warning: React Hook React.useEffect has a missing dependency: 'columnData'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
- info Linting and checking validity of types  
- info Collecting page data .Using Memory store
Using Memory store
- info Collecting page data  
- info Creating an optimized production build ..- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
- info Creating an optimized production build ...- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
- info Creating an optimized production build .- warn Entire page /prompts deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /prompts
- warn Entire page /datasets deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /datasets
- info Creating an optimized production build ..- warn Entire page /eval deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /eval
- info Generating static pages (19/19)
- info Finalizing page optimization  

Route (app)                                Size     First Load JS
┌ ○ /                                      413 B          79.1 kB
├ ○ /api/config                            0 B                0 B
├ ○ /api/datasets                          0 B                0 B
├ λ /api/eval                              0 B                0 B
├ λ /api/eval/[id]                         0 B                0 B
├ λ /api/eval/job                          0 B                0 B
├ λ /api/eval/job/[id]                     0 B                0 B
├ ○ /api/progress                          0 B                0 B
├ ○ /api/prompts                           0 B                0 B
├ ○ /api/results                           0 B                0 B
├ λ /api/results/[filename]                0 B                0 B
├ λ /api/results/latest                    0 B                0 B
├ ○ /auth/callback                         0 B                0 B
├ ○ /auth/login                            2.79 kB         170 kB
├ ○ /auth/signup                           2.84 kB         171 kB
├ ○ /datasets                              2.12 kB         157 kB
├ ○ /eval                                  221 B           366 kB
├ ● /eval/[id]                             461 B           367 kB
├ ○ /progress                              3.85 kB         168 kB
├ ○ /prompts                               1.77 kB         144 kB
└ ○ /setup                                 20.1 kB         206 kB
+ First Load JS shared by all              78.6 kB
  ├ chunks/596-f3a131b7c336dd5d.js         26 kB
  ├ chunks/fd9d1056-a95b789c94c05ff6.js    50.5 kB
  ├ chunks/main-app-c05d2391a71b89e6.js    211 B
  └ chunks/webpack-e02a742b401be2a0.js     1.9 kB

Route (pages)                              Size     First Load JS
─ ○ /404                                   182 B            76 kB
+ First Load JS shared by all              75.8 kB
  ├ chunks/framework-8883d1e9be70c3da.js   45 kB
  ├ chunks/main-b311752d7554d977.js        28.7 kB
  ├ chunks/pages/_app-52924524f99094ab.js  195 B
  └ chunks/webpack-e02a742b401be2a0.js     1.9 kB

ƒ Middleware                               107 kB

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)
●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)

- info Creating an optimized production build ...- warn 
metadata.metadataBase is not set for resolving social open graph or twitter images, using "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase
- info Creating an optimized production build ..
up to date, audited 831 packages in 37s

88 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Oh... so it is not possible to run promptfoo view with locally built binary for the result of promptfoo eval with remote(npm) installed binary? I mean,

  • eval with promptfoo (from npm) -> view with locally built promptfoo: Got Cannot GET / Error
  • eval & view with both locally built promptfoo : Success

I thought they were both accessing the same internal data but it seems not.
I used the same 0.51.0 version for both npm installed and locally built ones.