From 906c9765b52bcaf953bb39b6bbb7759f5cf1fc14 Mon Sep 17 00:00:00 2001 From: Marios Antonoudiou Date: Tue, 16 Sep 2025 09:35:17 +0300 Subject: [PATCH] Update prompt and model --- server/api/tasks/generate-content.post.ts | 16 +-------- server/utils/create-content.ts | 41 +++++++---------------- 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/server/api/tasks/generate-content.post.ts b/server/api/tasks/generate-content.post.ts index 4a1b3e4..c2edef9 100644 --- a/server/api/tasks/generate-content.post.ts +++ b/server/api/tasks/generate-content.post.ts @@ -1,11 +1,8 @@ -import { get } from "radash"; import { createActivityContent } from "~~/server/utils/create-content"; export default defineEventHandler(async (event) => { await validateHookdeck(event); - const posthog = event.context.posthog; - const body = await readBody(event); const db = useDrizzle(); @@ -25,7 +22,7 @@ export default defineEventHandler(async (event) => { const currentActivity = await strava!(`/activities/${body.object_id}`); const [, ...previousActivities] = await strava!(`/activities`, { query: { - per_page: 20, + per_page: 10, }, }); @@ -53,15 +50,4 @@ export default defineEventHandler(async (event) => { message: `Strava API: ${error.message}`, }); }); - - posthog.captureImmediate({ - distinctId: String(user.id), - event: "content generated", - properties: { - activity: currentActivity.id, - activityType: get(currentActivity, "sport_type", "unknown"), - highlight: stravaRequestBody.meta.highlight, - tone: stravaRequestBody.meta.tone, - }, - }); }); diff --git a/server/utils/create-content.ts b/server/utils/create-content.ts index 2722d53..560ac21 100644 --- a/server/utils/create-content.ts +++ b/server/utils/create-content.ts @@ -99,26 +99,6 @@ export const createActivityContent = async ({ const highlight = isEmpty(user.preferences.data?.highlights) ? (draw(availableHighlights) as string) : draw(user.preferences.data!.highlights!); - const highlightInstructions = match({ highlight, activity: currentActivity }) - .when( - ({ highlight, activity }) => - highlight === "Area Exploration" && - movingActivityTypes.includes(get(activity, "type")), - () => - "Focus on places visited and areas explored. Highlight any previous or new visits.", - ) - .with( - { highlight: "Athletic" }, - () => - "Highlight athletic properties and performance. Highlight PR's as well but only if available.", - ) - .with( - { highlight: "Mood" }, - () => - "Focus on how mood was swinging through the activity, ie I was feeling exhausted because of climb, I was feeling super happy on that descent!", - ) - .with({ highlight: "Conditions" }, () => "Highlight on weather conditions") - .otherwise(() => ""); const length = match({ tone }) .with({ tone: "Minimalist" }, () => "short") @@ -127,11 +107,17 @@ export const createActivityContent = async ({ const prompt = ` Generate a short title and a ${length}-lengthed description for my strava activity. Use my preferred language and unit system. Use first person, as this will be posting for myself. Try to not exaggerate as I am using Strava often and I want my activites to be unique and easy to read. Don't use repeative language. - Use a little bit of ${tone} tone to make things less boring. - ${highlightInstructions} + + Depending the activity conditions and achievements, use one of the following tones to make things less boring: + ${availableTones.join(", ")}. Accordingly, depending on the activity's conditions, highlight area exploration, athletic achievements, mood swings or weather conditions. + If there is nothing interesting to say, try making a mild joke or say an interesting fact about the route. + + Take heart data, suffer score and weather into consideration if available, combine them to understand the effort. + Maybe comment if any interesting fact in comparison to previous activities. - Add #${tone} and #${highlight} at the end of the description. Depending the length of the description, maybe add more hashtags. + NEVER use em dash symbol. + Depending the length of the description, maybe add hashtags. Language: ${user?.preferences.data!.language} Unit system: ${user?.preferences.data!.units} @@ -151,8 +137,11 @@ export const createActivityContent = async ({ `; const aiResponse = await openai.responses.create({ - model: "gpt-5-mini", + model: "gpt-5", input: [{ role: "user", content: prompt }], + reasoning: { + effort: "minimal", + }, text: { format: { type: "json_schema", @@ -184,10 +173,6 @@ export const createActivityContent = async ({ const stravaRequestBody = { name: responseObject!.title, description: responseObject!.description, - meta: { - highlight, - tone, - }, }; return [parseError, stravaRequestBody] as const;