feat: support appending request hints to prompt (#965)

This commit is contained in:
Jeremy 2025-04-29 16:18:46 -07:00 committed by GitHub
parent 845b40f7fe
commit 23964e3392
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 53 additions and 8 deletions

View file

@ -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: