feat: support appending request hints to prompt (#965)
This commit is contained in:
parent
845b40f7fe
commit
23964e3392
4 changed files with 53 additions and 8 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { ArtifactKind } from '@/components/artifact';
|
||||
import type { ArtifactKind } from '@/components/artifact';
|
||||
import type { Geo } from '@vercel/functions';
|
||||
|
||||
export const artifactsPrompt = `
|
||||
Artifacts is a special user interface mode that helps users with writing, editing, and other content creation tasks. When artifact is open, it is on the right side of the screen, while the conversation is on the left side. When creating or updating documents, changes are reflected in real-time on the artifacts and visible to the user.
|
||||
|
|
@ -34,15 +35,34 @@ Do not update document right after creating it. Wait for user feedback or reques
|
|||
export const regularPrompt =
|
||||
'You are a friendly assistant! Keep your responses concise and helpful.';
|
||||
|
||||
export interface RequestHints {
|
||||
latitude: Geo['latitude'];
|
||||
longitude: Geo['longitude'];
|
||||
city: Geo['city'];
|
||||
country: Geo['country'];
|
||||
}
|
||||
|
||||
export const getRequestPromptFromHints = (requestHints: RequestHints) => `\
|
||||
About the origin of user's request:
|
||||
- lat: ${requestHints.latitude}
|
||||
- lon: ${requestHints.longitude}
|
||||
- city: ${requestHints.city}
|
||||
- country: ${requestHints.country}
|
||||
`;
|
||||
|
||||
export const systemPrompt = ({
|
||||
selectedChatModel,
|
||||
requestHints,
|
||||
}: {
|
||||
selectedChatModel: string;
|
||||
requestHints: RequestHints;
|
||||
}) => {
|
||||
const requestPrompt = getRequestPromptFromHints(requestHints);
|
||||
|
||||
if (selectedChatModel === 'chat-model-reasoning') {
|
||||
return regularPrompt;
|
||||
return `${regularPrompt}\n\n${requestPrompt}`;
|
||||
} else {
|
||||
return `${regularPrompt}\n\n${artifactsPrompt}`;
|
||||
return `${regularPrompt}\n\n${requestPrompt}\n\n${artifactsPrompt}`;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue