-
-
Notifications
You must be signed in to change notification settings - Fork 6
Fix system prompt defaults and user ID retrieval #517
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 |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import { SearchSection } from '@/components/search-section' | |
| import SearchRelated from '@/components/search-related' | ||
| import { GeoJsonLayer } from '@/components/map/geojson-layer' | ||
| import { ResolutionCarousel } from '@/components/resolution-carousel' | ||
| import { getCurrentUserIdOnServer } from '@/lib/auth/get-current-user' | ||
| import { ResolutionImage } from '@/components/resolution-image' | ||
| import { CopilotDisplay } from '@/components/copilot-display' | ||
| import RetrieveSection from '@/components/retrieve-section' | ||
|
|
@@ -397,7 +398,7 @@ async function submit(formData?: FormData, skip?: boolean) { | |
| } as CoreMessage) | ||
| } | ||
|
|
||
| const userId = 'anonymous' | ||
| const userId = (await getCurrentUserIdOnServer()) || 'anonymous' | ||
| const currentSystemPrompt = (await getSystemPrompt(userId)) || '' | ||
|
Comment on lines
400
to
402
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. Fetching the user ID on every Also consider whether SuggestionConsider caching the user ID for the lifetime of the request, and ensure anonymous prompts are not globally shared unless that’s intentional. Example approach:
Reply with "@CharlieHelps yes please" if you'd like me to add a commit implementing request-scoped caching and/or a safer anonymous-keying strategy. |
||
| const mapProvider = formData?.get('mapProvider') as 'mapbox' | 'google' | ||
|
Comment on lines
400
to
403
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.
Consider moving user/system-prompt resolution behind the branch that actually needs it, or at least behind SuggestionIf let currentSystemPrompt = ''
if (!skip) {
const userId = (await getCurrentUserIdOnServer()) || 'anonymous'
currentSystemPrompt = (await getSystemPrompt(userId)) || ''
}If you still need the prompt in skip mode, consider documenting why with an inline comment, or caching the userId/prompt at a higher level if Reply with "@CharlieHelps yes please" if you’d like me to add a commit with this refactor. |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,7 @@ export type SettingsFormValues = z.infer<typeof settingsFormSchema> | |
| // Default values | ||
| const defaultValues: Partial<SettingsFormValues> = { | ||
| systemPrompt: | ||
| "You are a planetary copilot, an AI assistant designed to help users with information about planets, space exploration, and astronomy. Provide accurate, educational, and engaging responses about our solar system and beyond.", | ||
| "You are an AI assistant designed to help users with geospatial data, mapping, and environment-aware insights. Provide accurate and helpful responses based on the available tools and context.", | ||
| selectedModel: "Grok 4.2", | ||
| users: [], | ||
| } | ||
|
Comment on lines
54
to
59
Contributor
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. Minor terminology inconsistency with surrounding UI text. The default prompt now describes a "geospatial data, mapping, and environment-aware insights" assistant, but 🤖 Prompt for AI Agents |
||
|
|
||
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.
🛠️ Refactor suggestion | 🟠 Major
Redundant dynamic import —
getCurrentUserIdOnServeris already statically imported.Line 25 adds a static import, but lines 641–643 in
onSetAIStatestill dynamically import the same module. The dynamic import is now unnecessary overhead and a maintenance inconsistency.♻️ Suggested fix
Also applies to: 641-643
🤖 Prompt for AI Agents