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
|
|
@ -6,7 +6,7 @@ import {
|
|||
streamText,
|
||||
} from 'ai';
|
||||
import { auth, type UserType } from '@/app/(auth)/auth';
|
||||
import { systemPrompt } from '@/lib/ai/prompts';
|
||||
import { type RequestHints, systemPrompt } from '@/lib/ai/prompts';
|
||||
import {
|
||||
deleteChatById,
|
||||
getChatById,
|
||||
|
|
@ -25,6 +25,7 @@ import { isProductionEnvironment } from '@/lib/constants';
|
|||
import { myProvider } from '@/lib/ai/providers';
|
||||
import { entitlementsByUserType } from '@/lib/ai/entitlements';
|
||||
import { postRequestBodySchema, type PostRequestBody } from './schema';
|
||||
import { geolocation } from '@vercel/functions';
|
||||
|
||||
export const maxDuration = 60;
|
||||
|
||||
|
|
@ -85,6 +86,15 @@ export async function POST(request: Request) {
|
|||
message,
|
||||
});
|
||||
|
||||
const { longitude, latitude, city, country } = geolocation(request);
|
||||
|
||||
const requestHints: RequestHints = {
|
||||
longitude,
|
||||
latitude,
|
||||
city,
|
||||
country,
|
||||
};
|
||||
|
||||
await saveMessages({
|
||||
messages: [
|
||||
{
|
||||
|
|
@ -102,7 +112,7 @@ export async function POST(request: Request) {
|
|||
execute: (dataStream) => {
|
||||
const result = streamText({
|
||||
model: myProvider.languageModel(selectedChatModel),
|
||||
system: systemPrompt({ selectedChatModel }),
|
||||
system: systemPrompt({ selectedChatModel, requestHints }),
|
||||
messages,
|
||||
maxSteps: 5,
|
||||
experimental_activeTools:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue