generate site using llm prompt
This commit is contained in:
@@ -11,37 +11,6 @@ export interface ComponentItem {
|
||||
orderIndex: number;
|
||||
}
|
||||
|
||||
export interface ComponentResponse {
|
||||
id: string;
|
||||
pageId: string;
|
||||
type: ComponentType;
|
||||
config: Record<string, unknown>;
|
||||
styles: Record<string, unknown>;
|
||||
orderIndex: number;
|
||||
}
|
||||
|
||||
export interface PageWithComponentsResponse {
|
||||
id: string;
|
||||
siteId: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
seoTitle: string;
|
||||
seoDescription: string;
|
||||
orderIndex: number;
|
||||
createdAt: string;
|
||||
components: ComponentResponse[];
|
||||
}
|
||||
|
||||
export interface SaveComponentsRequest {
|
||||
components: {
|
||||
id?: string;
|
||||
type: ComponentType;
|
||||
config: Record<string, unknown>;
|
||||
styles: Record<string, unknown>;
|
||||
orderIndex: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
export function getDefaultConfig(type: ComponentType): Record<string, unknown> {
|
||||
switch (type) {
|
||||
case 'HEADING': return { text: 'Heading', level: 'h2' };
|
||||
@@ -72,34 +41,36 @@ export function getDefaultStyles(type: ComponentType): Record<string, unknown> {
|
||||
}
|
||||
}
|
||||
|
||||
export function getComponentLabel(type: ComponentType): string {
|
||||
const labels: Record<ComponentType, string> = {
|
||||
HEADING: 'Heading',
|
||||
TEXT: 'Text',
|
||||
IMAGE: 'Image',
|
||||
BUTTON: 'Button',
|
||||
DIVIDER: 'Divider',
|
||||
GALLERY: 'Gallery',
|
||||
VIDEO: 'Video',
|
||||
CONTACT_FORM: 'Contact Form',
|
||||
MAP: 'Map',
|
||||
CUSTOM_HTML: 'Custom HTML',
|
||||
};
|
||||
return labels[type];
|
||||
const LABELS: Record<string, string> = {
|
||||
HEADING: 'Heading',
|
||||
TEXT: 'Text',
|
||||
IMAGE: 'Image',
|
||||
BUTTON: 'Button',
|
||||
DIVIDER: 'Divider',
|
||||
GALLERY: 'Gallery',
|
||||
VIDEO: 'Video',
|
||||
CONTACT_FORM: 'Contact Form',
|
||||
MAP: 'Map',
|
||||
CUSTOM_HTML: 'Custom HTML',
|
||||
};
|
||||
|
||||
const ICONS: Record<string, string> = {
|
||||
HEADING: 'title',
|
||||
TEXT: 'text_fields',
|
||||
IMAGE: 'image',
|
||||
BUTTON: 'smart_button',
|
||||
DIVIDER: 'horizontal_rule',
|
||||
GALLERY: 'photo_library',
|
||||
VIDEO: 'videocam',
|
||||
CONTACT_FORM: 'contact_mail',
|
||||
MAP: 'map',
|
||||
CUSTOM_HTML: 'code',
|
||||
};
|
||||
|
||||
export function getComponentLabel(type: string): string {
|
||||
return LABELS[type] || LABELS[type.toUpperCase()] || type;
|
||||
}
|
||||
|
||||
export function getComponentIcon(type: ComponentType): string {
|
||||
const icons: Record<ComponentType, string> = {
|
||||
HEADING: 'title',
|
||||
TEXT: 'text_fields',
|
||||
IMAGE: 'image',
|
||||
BUTTON: 'smart_button',
|
||||
DIVIDER: 'horizontal_rule',
|
||||
GALLERY: 'photo_library',
|
||||
VIDEO: 'videocam',
|
||||
CONTACT_FORM: 'contact_mail',
|
||||
MAP: 'map',
|
||||
CUSTOM_HTML: 'code',
|
||||
};
|
||||
return icons[type];
|
||||
export function getComponentIcon(type: string): string {
|
||||
return ICONS[type] || ICONS[type.toUpperCase()] || 'code';
|
||||
}
|
||||
|
||||
76
frontend/src/app/core/models/llm.ts
Normal file
76
frontend/src/app/core/models/llm.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { ComponentType } from './component';
|
||||
|
||||
export interface LLMGenerateRequest {
|
||||
prompt: string;
|
||||
siteId: string;
|
||||
references?: Reference[];
|
||||
}
|
||||
|
||||
export interface LLMRefineRequest {
|
||||
prompt: string;
|
||||
siteId: string;
|
||||
currentStructure: SiteStructure;
|
||||
references?: Reference[];
|
||||
}
|
||||
|
||||
export interface Reference {
|
||||
type: 'URL' | 'IMAGE';
|
||||
url: string;
|
||||
altText: string;
|
||||
}
|
||||
|
||||
export interface SiteStructure {
|
||||
theme: ThemeConfig;
|
||||
pages: PageStructure[];
|
||||
}
|
||||
|
||||
export interface ThemeConfig {
|
||||
colors: Record<string, string>;
|
||||
fonts: Record<string, string>;
|
||||
spacing: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface PageStructure {
|
||||
id?: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
seoTitle?: string;
|
||||
seoDescription?: string;
|
||||
orderIndex: number;
|
||||
components: ComponentStructure[];
|
||||
}
|
||||
|
||||
export interface ComponentStructure {
|
||||
id?: string;
|
||||
type: ComponentType;
|
||||
orderIndex: number;
|
||||
config: Record<string, unknown>;
|
||||
styles: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface TokenUsage {
|
||||
prompt: number;
|
||||
completion: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface LLMSession {
|
||||
id?: string;
|
||||
siteId: string;
|
||||
prompt: string;
|
||||
generatedStructure: SiteStructure | null;
|
||||
refinedPrompt: string | null;
|
||||
acceptedAt: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface GenerationVersion {
|
||||
id: string;
|
||||
siteId: string;
|
||||
userId: string;
|
||||
versionNumber: number;
|
||||
prompt: string;
|
||||
references: Reference[];
|
||||
fullStructure: string;
|
||||
createdAt: string;
|
||||
}
|
||||
29
frontend/src/app/core/services/llm-api.service.ts
Normal file
29
frontend/src/app/core/services/llm-api.service.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { LLMGenerateRequest, LLMRefineRequest, SiteStructure, GenerationVersion } from '../models/llm';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class LlmApiService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
generate(request: LLMGenerateRequest): Observable<SiteStructure> {
|
||||
return this.http.post<SiteStructure>('/api/llm/generate', request);
|
||||
}
|
||||
|
||||
refine(request: LLMRefineRequest): Observable<SiteStructure> {
|
||||
return this.http.post<SiteStructure>('/api/llm/refine', request);
|
||||
}
|
||||
|
||||
getVersions(siteId: string): Observable<GenerationVersion[]> {
|
||||
return this.http.get<GenerationVersion[]>(`/api/llm/versions/${siteId}`);
|
||||
}
|
||||
|
||||
restoreVersion(versionId: string): Observable<SiteStructure> {
|
||||
return this.http.post<SiteStructure>(`/api/llm/versions/${versionId}/restore`, {});
|
||||
}
|
||||
|
||||
deleteVersion(versionId: string): Observable<void> {
|
||||
return this.http.delete<void>(`/api/llm/versions/${versionId}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user