Skip to content

Commit

Permalink
update ux sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHallen122 committed Jan 8, 2025
1 parent 580f27d commit e5cc2ed
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
10 changes: 3 additions & 7 deletions backend/src/build-system/handlers/ux/sitemap-document/prompt.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
// Define and export the system prompts object
export const prompts = {
generateUxsmdrompt: (
projectName: string,
prdDocument: string,
platform: string,
): string => {
return `You are an expert frontend develper and ux designer. Your job is to analyze and expand upon the details provided, generating a Full UX Sitemap Document based on the following inputs:
generateUxsmdrompt: (projectName: string, platform: string): string => {
return `You are an expert frontend develper and ux designer. Your job is to analyze and expand upon the details provided, generating a Full UX Sitemap Document based on the following inputs provide later:
- Project name: ${projectName}
- product requirements document: ${prdDocument}
- product requirements document: {}
- Platform: ${platform}
Follow these rules as a guide to ensure clarity and completeness in your UX Sitemap Document.
Expand Down
35 changes: 27 additions & 8 deletions backend/src/build-system/handlers/ux/sitemap-document/uxsmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { prompts } from './prompt';
import { ModelProvider } from 'src/common/model-provider';
import { Logger } from '@nestjs/common';
import { removeCodeBlockFences } from 'src/build-system/utils/strings';
import { MessageInterface } from 'src/common/model-provider/types';

export class UXSMDHandler implements BuildHandler<string> {
readonly id = 'op:UX:SMD';
Expand All @@ -19,14 +20,10 @@ export class UXSMDHandler implements BuildHandler<string> {
const prdContent = context.getNodeData('op:PRD');

// Generate the prompt dynamically
const prompt = prompts.generateUxsmdrompt(
projectName,
prdContent,
platform,
);
const prompt = prompts.generateUxsmdrompt(projectName, platform);

// Send the prompt to the LLM server and process the response
const uxsmdContent = await this.generateUXSMDFromLLM(prompt);
const uxsmdContent = await this.generateUXSMDFromLLM(prompt, prdContent);

// Store the generated document in the context
context.setGlobalContext('uxsmdDocument', uxsmdContent);
Expand All @@ -38,13 +35,35 @@ export class UXSMDHandler implements BuildHandler<string> {
};
}

private async generateUXSMDFromLLM(prompt: string): Promise<string> {
private async generateUXSMDFromLLM(
prompt: string,
prdContent: string,
): Promise<string> {
const messages: MessageInterface[] = [
{
role: 'system',
content: prompt,
},
{
role: 'user',
content: `This is the product requiremnt ${prdContent}`,
},
{
role: 'assistant',
content: 'Here is the initial UX Sitemap Document...',
},
{
role: 'user',
content: 'Add more detail about user flows.',
},
];

const modelProvider = ModelProvider.getInstance();
const model = 'gpt-4o-mini';

const uxsmdContent = await modelProvider.chatSync({
model,
messages: [{ content: prompt, role: 'system' }],
messages,
});

this.logger.log('Received full UXSMD content from LLM server.');
Expand Down

0 comments on commit e5cc2ed

Please sign in to comment.