Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Web Svelte GUI Enhancements: Descriptions, Tags, Favorites, Search Bar, Language Integration, etc #1309

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jmd1010
Copy link

@jmd1010 jmd1010 commented Feb 20, 2025

Enhanced Pattern Selection, Pattern Descriptions, New Pattern TAG System, Language Support and other WEB UI Improvements

Screenshot 2025-02-20 at 3 49 57 PM Screenshot 2025-02-20 at 3 48 13 PM

This Cumulative PR adds several Web UI and functionality improvements to make pattern management and selection more intuitive and friction free:

  • New Pattern Descriptions
  • Ability to save favorites
  • New Pattern TAG system
  • Multilingual capabilities,
  • Help reference section,
  • More robust Youtube processing and a variety of ui improvements.

Thanks to Jonatan, Daniel, John and others who built this web app. It's a super fondation to continue building upon.

🎥 Demo Video

https://youtu.be/9Yk3DpNFiEU

🌟 Key Features

1. Web UI and Pattern Selection Improvements

  • Enhanced pattern selection interface for better user experience
  • New pattern descriptions section accessible via modal
  • New pattern favorite list and pattern search functionality
  • New Tag system for better pattern organization and filtering
  • Web UI refinements for clearer interaction
  • Help section & Pattern Selection via modal

2. Multilingual Support System

  • Language switching via UI dropdown
  • Persistent language state management
  • Pattern processing now use the selected language
    (Note: translation of pattern section "titles" not 100% for Youtube, anybody?)

3. YouTube Integration Enhancement

  • Language handling for YouTube transcript & Pattern output processing
  • Youtube required qualifiers or web site text conversion for llms (Jina) handled seamlessly behind the scene

4. Enhanced Tag Management Integration

The tag filtering system has been integrated into the Pattern Selection interface through several UI enhancements:

  1. Dual-Position Tag Panel

    • Sliding panel positioned to the right of pattern modal
    • Dynamic toggle button that adapts position and text based on panel state
    • Smooth transitions for opening/closing animations
  2. Tag Selection Visibility

    • New dedicated tag display section in pattern modal
    • Visual separation through subtle background styling
    • Immediate feedback showing selected tags with comma separation
    • Inline reset capability for quick tag clearing
  3. Improved User Experience

    • Clear visual hierarchy between pattern list and tag filtering
    • Multiple ways to manage tags (panel or quick reset)
    • Consistent styling with existing design language
    • Space-efficient tag brick layout in 3-column grid
  4. Technical Implementation

    • Reactive tag state management
    • Efficient tag filtering logic
    • Proper event dispatching between components
    • Maintained accessibility standards
    • Responsive design considerations

HOW TO USE
No change from existing process: from /web run fabric --serve or ./fabric --serve and run npm run dev from two different terminal windows.

These enhancements create a more intuitive and efficient pattern discovery experience, allowing users to quickly filter and find relevant patterns while maintaining a clean, modern interface.

5. Obsidian and Note integration

  • Fully operational
  • To work out of the box, please maintain this folder structure: (but you can change): web/myfiles/Fabric_obsidian and web/myfiles/inbox for notes.

🛠 Technical Implementation

Language Support Architecture

// Language state management
export const languageStore = writable<string>('');

// Chat input language detection
if (qualifier === 'fr') {
  languageStore.set('fr');
  userInput = userInput.replace(/--fr\s*/, '');
}

// Service layer integration
const language = get(languageStore) || 'en';
const languageInstruction = language !== 'en' 
  ? `. Please use the language '${language}' for the output.` 
  : '';

YouTube Processing Enhancement

// Process stream with language instruction per chunk
await chatService.processStream(
  stream,
  (content: string, response?: StreamResponse) => {
    if (currentLanguage !== 'en') {
      content = `${content}. Please use the language '${currentLanguage}' for the output.`;
    }
    // Update messages...
  }
);

Pattern Descriptions and Tags Management

This document explains the complete workflow for managing pattern descriptions and tags, including how to process new patterns and maintain metadata.

System Overview

The pattern system follows this hierarchy:

  1. ~/.config/fabric/patterns/ directory: The source of truth for available patterns
  2. pattern_extracts.json: Contains first 500 words of each pattern for reference
  3. pattern_descriptions.json: Stores pattern metadata (descriptions and tags)
  4. web/static/data/pattern_descriptions.json: Web-accessible copy for the interface

Pattern Processing Workflow

1. Adding New Patterns

  • Add patterns to ~/.config/fabric/patterns/
  • Run extract_patterns.py to process new additions:
    python extract_patterns.py
    

The Python Script automatically:

  • Creates pattern extracts for reference
  • Adds placeholder entries in descriptions file
  • Syncs to web interface

2. Pattern Extract Creation

The script extracts first 500 words from each pattern's system.md file to:

  • Provide context for writing descriptions
  • Maintain reference material
  • Aid in pattern categorization

3. Description and Tag Management

Pattern descriptions and tags are managed in pattern_descriptions.json:

{
"patterns": [
{
"patternName": "pattern_name",
"description": "[Description pending]",
"tags": []
}
]
}

Completing Pattern Metadata

Writing Descriptions

  1. Check pattern_descriptions.json for "[Description pending]" entries

  2. Reference pattern_extracts.json for context

  3. How to update Pattern short descriptions (one sentence).

You can update your descriptions in pattern_descriptions.json manually or using LLM assistance (prefered approach).

Tell AI to look for "Description pending" entries in this file and write a short description based on the extract info in the pattern_extracts.json file. You can also ask your LLM to add tags for those newly added patterns, using other patterns tag assignments as example.

Managing Tags

  1. Add appropriate tags to new patterns
  2. Update existing tags as needed
  3. Tags are stored as arrays: ["TAG1", "TAG2"]
  4. Edit pattern_descriptions.json directly to modify tags
  5. Make tags your own. You can delete, replace, amend existing tags.

File Synchronization

The script maintains synchronization between:

  • Local pattern_descriptions.json
  • Web interface copy in static/data/
  • No manual file copying needed

Pattern Updates (adding descriptions and tags)

  1. Run extract_patterns.py when:
    • Adding new patterns
    • Updating existing patterns
    • Modifying pattern structure

It will add the pattern extracts for the new patterns in the pattern_extracts.json and create placeholders in the pattern_descriptions.json file to complete later (ie add your pattern descriptions and tags). You can complete this step manually or with AI.

  1. Tags Management:
    • See current Tags definition in the Help guide
    • You can modify the Tag list and make it your own in the pattern_descriptions.json file.

Troubleshooting

If patterns are not showing in the web interface:

  1. Verify pattern_descriptions.json format
  2. Check web/static/data/pattern_descriptions.json copy exists
  3. Ensure proper file permissions
  4. Run extract_patterns.py to resync

File Structure

fabric/
├── patterns/ # Pattern source files
├── PATTERN_DESCRIPTIONS/
│ ├── extract_patterns.py # Pattern processing script
│ ├── pattern_extracts.json # Pattern content references
│ └── pattern_descriptions.json # Pattern metadata
└── web/
└── static/
└── data/
└── pattern_descriptions.json # Web interface copy

🎯 Usage Examples

1. Using Language Qualifiers

User: What is the weather?
AI: The weather information...

User: --fr What is the weather?
AI: Voici les informations météo...

2. Global Settings

  1. Select language from dropdown
  2. All interactions use selected language
  3. Automatic reset to English after each message

3. YouTube Analysis

User: Analyze this YouTube video --fr
AI: [Provides analysis in French, maintaining language throughout the transcript]

💡 Key Benefits

  1. Enhanced User Experience

    • Intuitive language switching
    • Consistent language handling
    • Seamless integration with existing features
  2. Robust Implementation

    • Simple yet powerful design
    • No complex language detection needed
    • Direct AI instruction approach
  3. Maintainable Architecture

    • Clean separation of concerns
    • Stateful language management
    • Easy to extend for new languages
  4. YouTube Integration

    • Handles long transcripts effectively
    • Maintains language consistency
    • Robust chunk processing

🔄 Implementation Notes

  1. State Management

    • Language persists until changed
    • Handles UI state updates efficiently
  2. Error Handling

    • Invalid qualifiers are ignored
    • Unknown languages default to English
    • Proper store reset on errors
  3. Next Steps

  • Fix "warning" Aria errors with modal
  • Reinstate correct language for Pattern output headings when Youtube is used (eg "Main Idea", "Key Take Aways"). Was working fine, lost along the way in some code change. Anyone wants to take a peak @johnconnor-sec ?
  • Finalize streaming, could not get this to work ie currently limited to deliver pattern output at once.
  • Would be nice to be able to upload a pdf as a source ie detect pdf and convert for llm processing. Anyone wants to collaborate on this?
  • Maybe an MCP type Pattern to handle the Pattern description update process when new patterns are added.
  • Else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant