* Add a unique_id field to the conversation object - This helps us keep track of the unique identity of the conversation without expose the internal id - Create three staged migrations in order to first add the field, then add unique values to pre-fill, and then set the unique constraint. Without this, it tries to initialize all the existing conversations with the same ID. * Parse and utilize the unique_id field in the query parameters of the front-end view - Handle the unique_id field when creating a new conversation from the home page - Parse the id field with a lightweight parameter called v in the chat page - Share page should not be affected, as it uses the public slug * Fix suggested card category
This is a Next.js project.
Getting Started
First, install the dependencies:
yarn install
In case you run into any dependency linking issues, you can try running:
yarn add next
Run the development server:
yarn dev
Make sure the rewrites in next.config.mjs are set up correctly for your environment. The rewrites are used to proxy requests to the API server.
rewrites: async () => {
return [
{
source: '/api/:path*',
destination: 'http://localhost:42110/api/:path*',
},
];
},
The destination should be the URL of the API server.
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying any of the .tsx pages. The page auto-updates as you edit the file.
Testing built files
We've setup a utility command for building and serving the built files. This is useful for testing the production build locally.
- Exporting code To build the files once and serve them, run:
yarn export
If you're using Windows:
yarn windowsexport
- Continuously building code
To keep building the files and serving them, run:
yarn watch
If you're using Windows:
yarn windowswatch
Now you should be able to load your custom pages from the Khoj app at http://localhost:42110/. To server any of the built files, you should update the routes in the web_client.py like so, where new_file is the new page you've added in this repo:
@web_client.post("/new_route", response_class=FileResponse)
@requires(["authenticated"], redirect="login_page")
def index_post(request: Request):
return templates.TemplateResponse(
"new_file/index.html",
context={
"request": request,
},
)
Learn More
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Next.js App Router - learn about the Next.js router.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!