Skip to content

Commit

Permalink
Refactor UI styles for prompt enhancements and version control
Browse files Browse the repository at this point in the history
  • Loading branch information
TMHSDigital committed Dec 23, 2024
1 parent 8c6c3ae commit c274c56
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 21 deletions.
55 changes: 49 additions & 6 deletions js/features/promptEnhancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export class PromptEnhancer {
// Get best practices for this medium and type
const practices = getBestPractices(medium, type);

// Add temperature recommendation if applicable
if (practices.temperature !== 0.7) { // Only add if different from default
enhancedPrompt = `[Temperature: ${practices.temperature}]\n${enhancedPrompt}`;
this.improvements.push(`Set temperature to ${practices.temperature}`);
}

// Validate prompt
if (!this.validator.validate(enhancedPrompt, medium, type, options)) {
const errors = this.validator.getErrors();
Expand Down Expand Up @@ -43,14 +49,25 @@ export class PromptEnhancer {
// Apply medium-specific enhancements
enhancedPrompt = this.applyMediumSpecificEnhancements(enhancedPrompt, medium, type, practices);

// Add version control comment if enabled
if (options.versionControl) {
const version = new Date().toISOString();
enhancedPrompt = `[Version: ${version}]\n${enhancedPrompt}`;
this.improvements.push('Added version control information');
}

// Ensure prompt doesn't exceed max length
const maxLength = medium === 'text' ? 2000 : 1000;
enhancedPrompt = this.truncateIfNeeded(enhancedPrompt, maxLength);

return {
enhancedPrompt,
improvements: this.improvements,
wasModified: enhancedPrompt !== prompt
wasModified: enhancedPrompt !== prompt,
settings: {
temperature: practices.temperature,
version: options.versionControl ? version : undefined
}
};
} catch (error) {
console.error('Error enhancing prompt:', error);
Expand Down Expand Up @@ -159,17 +176,43 @@ export class PromptEnhancer {
text: {
general: [
'- Clear, concise explanation with key points highlighted',
'- Step-by-step instructions with examples'
'- Step-by-step instructions with examples',
'- Structured response with introduction, main points, and conclusion',
'- Bullet points for easy readability'
],
completion: [
'- Natural continuation maintaining the original style and tone',
'- Coherent transition from the existing content',
'- Consistent voice and narrative flow'
],
chat: [
'- Natural conversational flow with appropriate context',
'- Clear response addressing the user\'s query',
'- Professional yet friendly tone with relevant information'
],
code: [
'- Well-documented function with clear parameters',
'- Implementation with error handling'
'- Well-documented function with clear parameters and return values',
'- Implementation with comprehensive error handling',
'- Clean, maintainable code following best practices',
'- Unit tests covering edge cases'
]
},
image: {
generation: [
'- Professional portrait with soft lighting',
'- Detailed landscape with atmospheric effects'
'- Professional portrait with soft lighting and natural pose',
'- Detailed landscape with atmospheric effects and depth',
'- Product shot with clean background and proper lighting',
'- Abstract concept with clear visual hierarchy'
],
editing: [
'- Color correction maintaining natural appearance',
'- Style transfer preserving key elements',
'- Background modification with seamless integration'
],
variation: [
'- Different perspectives of the same subject',
'- Style variations maintaining core elements',
'- Mood variations through lighting and color'
]
}
};
Expand Down
42 changes: 27 additions & 15 deletions js/features/promptValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,33 @@ export class PromptValidator {

hasFactor(prompt, factor, options) {
const factorPatterns = {
objective: /(goal|objective|purpose|task|aim):|^(i want|i need|please|could you)/im,
context: /(context|background|situation):|given that|assuming/i,
role: /(you are|act as|behave like|take on the role)/i,
tone: /(tone|style|manner|voice):|professional|casual|formal/i,
format: /(format|structure|organize|layout):|step[- ]by[- ]step/i,
language: /(using|in|with)\s+\w+(\s+programming)?(\s+language)?/i,
documentation: /comments|documentation|explain|describe/i,
tests: /test cases?|unit tests?|testing/i,
quality: /(quality|resolution|detailed|professional)/i,
style: /(style|artistic|aesthetic|visual)/i,
composition: /(composition|layout|arrangement|positioning)/i,
lighting: /(lighting|illumination|shadows|brightness)/i,
mood: /(mood|atmosphere|feeling|emotion|tone)/i,
constraints: /(constraints?|limitations?|restrictions?|requirements?)/i,
examples: /(examples?|instances?|cases?|scenarios?)/i
objective: /(goal|objective|purpose|task|aim|intent|target):|^(i want|i need|please|could you|help me|create|make|generate)/im,
context: /(context|background|situation|scenario|environment|setting|given|assuming|when|if):|for use in|in the context of/i,
role: /(you are|act as|behave like|take on the role|function as|serve as|perform as|work as)/i,
tone: /(tone|style|manner|voice|approach|attitude):|professional|casual|formal|friendly|serious|playful|technical/i,
format: /(format|structure|organize|layout|arrange|present|display):|step[- ]by[- ]step|in (points|sections|parts)/i,
language: /(using|in|with|written in|coded in|programmed in)\s+\w+(\s+programming)?(\s+language)?/i,
documentation: /comments|documentation|explain|describe|clarify|elaborate|annotate|document/i,
tests: /test cases?|unit tests?|testing|verification|validation|assert|check/i,
quality: /(quality|resolution|detailed|professional|refined|polished|high[- ]end|premium)/i,
style: /(style|artistic|aesthetic|visual|design|look|appearance|theme)/i,
composition: /(composition|layout|arrangement|positioning|framing|structure|balance|harmony)/i,
lighting: /(lighting|illumination|shadows|brightness|exposure|contrast|highlights|ambient)/i,
mood: /(mood|atmosphere|feeling|emotion|tone|ambiance|vibe|character)/i,
constraints: /(constraints?|limitations?|restrictions?|requirements?|boundaries|parameters|scope)/i,
examples: /(examples?|instances?|cases?|scenarios?|illustrations?|demonstrations?|samples?)/i,
creativity: /(creative|innovative|original|unique|novel|imaginative|inventive)/i,
continuity: /(continue|maintain|follow|consistent with|in line with|matching|flowing)/i,
memory: /(remember|recall|previous|earlier|before|maintain context|keep in mind)/i,
complexity: /(simple|complex|basic|advanced|intermediate|difficulty level|sophistication)/i,
detail: /(detailed|specific|precise|exact|thorough|comprehensive|complete)/i,
perspective: /(perspective|viewpoint|angle|pov|view|shot|camera)/i,
modification: /(modify|change|adjust|transform|alter|edit|revise|update)/i,
strength: /(strength|intensity|power|level|magnitude|force|impact)/i,
preservation: /(preserve|maintain|keep|retain|protect|safeguard|conserve)/i,
blend: /(blend|mix|combine|merge|integrate|fuse|unite)/i,
diversity: /(diverse|different|variety|range|assortment|mixture|varied)/i,
consistency: /(consistent|coherent|uniform|matching|aligned|harmonious|synchronized)/i
};

// Check if the factor is present in the prompt or options
Expand Down

0 comments on commit c274c56

Please sign in to comment.