-
Notifications
You must be signed in to change notification settings - Fork 79
Feature request: Allow creation of new chats using query params #232 #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ interface Props { | |
| isReadonly: boolean; | ||
| isNew: boolean; | ||
| workbench?: Workbench; | ||
| prefillQuery?: string; | ||
| autoSubmitQuery?: boolean; | ||
| } | ||
|
|
||
| export const Chat = async ({ | ||
|
|
@@ -25,6 +27,8 @@ export const Chat = async ({ | |
| isReadonly, | ||
| isNew, | ||
| workbench, | ||
| prefillQuery, | ||
| autoSubmitQuery, | ||
| }: Props) => { | ||
| const initialMessages = isNew | ||
| ? [] | ||
|
|
@@ -44,7 +48,7 @@ export const Chat = async ({ | |
| const initialPreferences = { | ||
| selectedChatModel: serverPreferences.selectedChatModel, | ||
| imageGenerationModel: serverPreferences.imageGenerationModel, | ||
| useNativeSearch: serverPreferences.useNativeSearch, | ||
| useNativeSearch: prefillQuery ? true : serverPreferences.useNativeSearch, // Enable web search when query is provided | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a need for this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking back at it now, i think this might be redundant now too, since web search is auto enabled based on model capabilities, so no need to actually specify this.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if web search is auto-enabled, that's correct yeah, this is redundant! I wasnt sure |
||
| toolkits: serverPreferences.toolkits | ||
| ?.map((persistedToolkit: PersistedToolkit) => { | ||
| const clientToolkit = | ||
|
|
@@ -112,6 +116,8 @@ export const Chat = async ({ | |
| initialVisibilityType={initialVisibilityType} | ||
| autoResume={!isNew} | ||
| workbench={workbench} | ||
| initialInput={prefillQuery} | ||
| autoSubmitInitialInput={autoSubmitQuery} | ||
| initialPreferences={initialPreferences} | ||
| > | ||
| <ChatContent | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the need for this page? Seems like we can keep the query param behavior in the index route
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we can, but the route was requested, that's why I created it, also following the pattern of I think two out of the three examples that were provided uses it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was part of the scope for the issue #232, to give it parity with the other providers and to reduce confusion about landing page vs. authed route, but maybe we dont need a /new? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { redirect } from "next/navigation"; | ||
|
|
||
| import { Chat } from "@/app/(general)/_components/chat"; | ||
| import { auth } from "@/server/auth"; | ||
| import { generateUUID } from "@/lib/utils"; | ||
|
|
||
| interface NewChatPageProps { | ||
| searchParams: Promise<{ | ||
| q?: string; | ||
| }>; | ||
| } | ||
|
|
||
| export default async function NewChatPage(props: NewChatPageProps) { | ||
| const searchParams = await props.searchParams; | ||
| const { q } = searchParams; | ||
|
|
||
| const session = await auth(); | ||
|
|
||
| if (!session) { | ||
| const redirectUrl = q | ||
| ? `/login?redirect=${encodeURIComponent(`/new?q=${encodeURIComponent(q)}`)}` | ||
| : "/login?redirect=/new"; | ||
| redirect(redirectUrl); | ||
| } | ||
|
|
||
| const id = generateUUID(); | ||
|
|
||
| return ( | ||
| <Chat | ||
| key={id} | ||
| id={id} | ||
| initialVisibilityType="private" | ||
| isReadonly={false} | ||
| isNew={true} | ||
| prefillQuery={q} | ||
| autoSubmitQuery={q ? true : false} | ||
| /> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
autoSubmitQueryever used? Feels to me like if prefillQuery is defined it should autosubmit as the user has been linked into thatThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, without it the query just sits in the box. I included it last, it was the last request of the issue. #232