CoolFace
Apppublic

Exched/DeepSeek_Coder

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
rewrite-prompt.ts36 linesDownload Raw Back to lib
1import { EnhancedSettings } from "@/types";2import { InferenceClient } from "@huggingface/inference";3import { PROMPT_FOR_REWRITE_PROMPT, PROMPT_FOR_REWRITE_PROMPT_END } from "./prompts";4 5export async function rewritePrompt(prompt: string, enhancedSettings: EnhancedSettings, options: { token: string, billTo: string | null }, model: string, provider: string) {6  const { token, billTo } = options;7 8  const client = new InferenceClient(token);9  const response = await client.chatCompletion(10    {11      model,12      provider: provider as any,13      messages: [14        {15          role: "system",16          content: `You will be given a prompt and a set of enhanced settings. You will need to rewrite the prompt to include the enhanced settings.17IMPORTANT: ALWAYS KEEP THE ORIGINAL IDEA OF THE USER'S PROMPT. DO NOT CHANGE THE ORIGINAL IDEA OF THE USER'S PROMPT.18Make sure to add a lot of details to the prompt, and make it more specific, to create the best prompt possible.19REQUIRED: If in the original prompt, the user asks for multiple pages, make sure to keep the multiple pages in the rewritten prompt.20ALWAYS RETURN THE REWRITTEN PROMPT, DO NOT ADD ANYTHING ELSE.`,21        },22        {23          role: "user",24          content: `Here is my prompt: ${prompt}. IMPORTANT: ALWAYS KEEP THE ORIGINAL IDEA OF MY PROMPT. Here are the enhanced settings:251. I want to use the following primary color: ${enhancedSettings.primaryColor} (eg: bg-${enhancedSettings.primaryColor}-500).262. I want to use the following secondary color: ${enhancedSettings.secondaryColor} (eg: bg-${enhancedSettings.secondaryColor}-500).273. I want to use the following theme: ${enhancedSettings.theme} mode.28Make sure to include the enhanced settings in the rewritten prompt.`,29        },30      ],31    },32    billTo ? { billTo } : {}33  );34 35  return response.choices[0]?.message?.content;36}