You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openai-cookbook/apps/file-q-and-a/nextjs/README.md

2.2 KiB

File Q&A

File Q&A is a Next.js app that lets you find answers in your files using OpenAI APIs. You can upload files and ask questions related to their content, and the app will use embeddings and GPT to generate answers from the most relevant files.

Requirements

To run the app, you need an OpenAI API key. You can create a new API key here.

Set Up

If you don't have Node.js and npm already, install them from https://nodejs.org/en/download/.

Otherwise you can run the project inside a Dev Container. If you are using VS Code, open the Command Pallette (ctrl+shift+p on Windows / cmd+shift+p on Mac), and run the command Dev Containers: Open Folder in Container. Then select the folder apps/file-q-and-a/nextjs, and VS Code will take care of booting a container with Node.js and npm ready to go. You may need to install the Dev Containers extension.

In your terminal, navigate to the nextjs directory of this example app, and then install dependencies:

npm install

Copy the .env.local.example file into a .env.local file and fill out the OpenAI API key field.

Development

Run the development server:

npm run dev

Open http://localhost:3000 with your browser to see the app.

Deployment

You can deploy the app on Vercel, the platform from the creators of Next.js. Check out the Next.js deployment documentation for more details.

Limitations

Uploaded files and generated embeddings don't persist on browser refresh. If you want to store more embeddings, we recommend using a vector database (e.g. Pinecone, Weaviate, Milvus, Qdrant, Redis, FAISS, etc.). The nextjs-with-flask-server version of this demo uses a Pinecone vector database.

The app may sometimes generate answers that are not in the files, or hallucinate about the existence of files that are not uploaded.