fix: fix enhance prompt to stop implementing full project instead of enhancing (#1383) #release

* fix: enhance prompt fix

* fix: added error capture on api error

* fix: replaced error with log for wrong files selected by bolt
This commit is contained in:
Anirban Kar
2025-03-01 01:34:35 +05:30
committed by GitHub
parent b98485d99f
commit 3c28e8ad88
9 changed files with 758 additions and 685 deletions

View File

@@ -3,11 +3,14 @@ import { streamText } from '~/lib/.server/llm/stream-text';
import { stripIndents } from '~/utils/stripIndent';
import type { ProviderInfo } from '~/types/model';
import { getApiKeysFromCookie, getProviderSettingsFromCookie } from '~/lib/api/cookies';
import { createScopedLogger } from '~/utils/logger';
export async function action(args: ActionFunctionArgs) {
return enhancerAction(args);
}
const logger = createScopedLogger('api.enhancher');
async function enhancerAction({ context, request }: ActionFunctionArgs) {
const { message, model, provider } = await request.json<{
message: string;
@@ -77,8 +80,32 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) {
env: context.cloudflare?.env as any,
apiKeys,
providerSettings,
options: {
system:
'You are a senior software principal architect, you should help the user analyse the user query and enrich it with the necessary context and constraints to make it more specific, actionable, and effective. You should also ensure that the prompt is self-contained and uses professional language. Your response should ONLY contain the enhanced prompt text. Do not include any explanations, metadata, or wrapper tags.',
/*
* onError: (event) => {
* throw new Response(null, {
* status: 500,
* statusText: 'Internal Server Error',
* });
* }
*/
},
});
(async () => {
for await (const part of result.fullStream) {
if (part.type === 'error') {
const error: any = part.error;
logger.error(error);
return;
}
}
})();
return new Response(result.textStream, {
status: 200,
headers: {