From 80669ceba5b915b8ce3a334e86e54ac1211f1323 Mon Sep 17 00:00:00 2001 From: MHindermann Date: Tue, 19 Nov 2024 13:25:53 +0100 Subject: [PATCH] update with dcterms --- prompts.json | 140 ++++++++++++++++++++++----------------------------- script.js | 61 ++++++++++++---------- 2 files changed, 94 insertions(+), 107 deletions(-) diff --git a/prompts.json b/prompts.json index 09d3742..c79931e 100644 --- a/prompts.json +++ b/prompts.json @@ -1,104 +1,82 @@ [ { - "prompt_id": "PROMPT-0001", - "title": "Creative Writing Starter", - "description": "Generate an engaging opening line for a short story.", - "category": "Creative Writing", - "models": ["GPT-4", "Bloom", "Cohere"], - "author": "Maxim", + "dcterms:identifier": "PROMPT-0001", + "dcterms:title": "Creative Writing Starter", + "dcterms:description": "Generate an engaging opening line for a short story. Expected output: A single sentence that hooks the reader.", + "dcterms:subject": "Creative Writing", + "dcterms:relation": ["gpt-3.5", "gpt-4"], + "dcterms:creator": "Maxim", "prompt_text": "Write a compelling opening line for a short story.", - "expected_output": "A single sentence that hooks the reader.", - "use_case": "Storytelling", + "dcterms:type": "Storytelling", "input_type": "Text", "output_type": "Narrative", - "version_number": "v1.0", - "last_updated": "2024-11-19", - "license": "Creative Commons", + "dcterms:hasVersion": "v1.0", + "dcterms:modified": "2024-11-19", + "dcterms:rights": "Creative Commons", "export_format": ["JSON", "YAML"] }, { - "prompt_id": "PROMPT-0002", - "title": "Python Debugging Tips", - "description": "Provide common debugging strategies for Python code.", - "category": "Programming", - "models": ["GPT-4", "LLaMA", "Claude"], - "author": "Jane Doe", - "prompt_text": "Explain debugging techniques for Python code.", - "expected_output": "A list of 5-10 debugging techniques with brief descriptions.", - "use_case": "Educational Resource", - "input_type": "Text", - "output_type": "List", - "version_number": "v1.0", - "last_updated": "2024-11-20", - "license": "Open Source", - "export_format": ["JSON"] - }, - { - "prompt_id": "PROMPT-0003", - "title": "Translate to French", - "description": "Translate an English paragraph to French.", - "category": "Translation", - "models": ["Mistral", "Flan-T5", "GPT-4"], - "author": "Marie Curie", - "prompt_text": "Translate the following paragraph into French: {text}", - "expected_output": "A grammatically correct and fluent French translation.", - "use_case": "Language Learning", - "input_type": "Text", + "dcterms:identifier": "PROMPT-0002", + "dcterms:title": "Extract Text from Image", + "dcterms:description": "Analyze an image and extract the text content embedded within it. Expected output: A plain text representation of the extracted text.", + "dcterms:subject": "Image Processing", + "dcterms:relation": ["ocr-model-v1", "ocr-model-v2"], + "dcterms:creator": "Jane Doe", + "prompt_text": "Given an image containing text, extract all textual content accurately.", + "dcterms:type": "Optical Character Recognition (OCR)", + "input_type": "Image", "output_type": "Text", - "version_number": "v1.2", - "last_updated": "2024-11-18", - "license": "Creative Commons", - "export_format": ["JSON", "HTML"] + "dcterms:hasVersion": "v1.2", + "dcterms:modified": "2024-11-20", + "dcterms:rights": "Open Source License", + "export_format": ["JSON", "Plain Text"] }, { - "prompt_id": "PROMPT-0004", - "title": "Summarize a News Article", - "description": "Generate a concise summary of a news article.", - "category": "Summarization", - "models": ["GPT-4", "LLaMA", "Claude"], - "author": "John Smith", + "dcterms:identifier": "PROMPT-0003", + "dcterms:title": "Summarize a News Article", + "dcterms:description": "Generate a concise summary of a news article in 3-5 sentences.", + "dcterms:subject": "Summarization", + "dcterms:relation": ["summary-model-v1"], + "dcterms:creator": "John Smith", "prompt_text": "Summarize the following news article: {article}", - "expected_output": "A summary of 3-5 sentences capturing key points.", - "use_case": "News Analysis", + "dcterms:type": "News Analysis", "input_type": "Text", "output_type": "Text", - "version_number": "v2.0", - "last_updated": "2024-11-19", - "license": "Proprietary", + "dcterms:hasVersion": "v2.0", + "dcterms:modified": "2024-11-18", + "dcterms:rights": "Proprietary", "export_format": ["JSON"] }, { - "prompt_id": "PROMPT-0006", - "title": "Explain a Scientific Concept", - "description": "Provide a clear explanation of a scientific concept.", - "category": "Education", - "models": ["science", "education", "concepts"], - "author": "Isaac Newton", + "dcterms:identifier": "PROMPT-0004", + "dcterms:title": "Generate SQL Queries", + "dcterms:description": "Create SQL queries based on natural language instructions.", + "dcterms:subject": "Database Management", + "dcterms:relation": ["sql-query-gen-v1"], + "dcterms:creator": "Alice Johnson", + "prompt_text": "Write an SQL query to {task}.", + "dcterms:type": "Programming", + "input_type": "Text", + "output_type": "Code", + "dcterms:hasVersion": "v1.1", + "dcterms:modified": "2024-11-17", + "dcterms:rights": "Open Source License", + "export_format": ["JSON", "YAML"] + }, + { + "dcterms:identifier": "PROMPT-0005", + "dcterms:title": "Explain a Scientific Concept", + "dcterms:description": "Provide a simple explanation of a scientific concept for beginners.", + "dcterms:subject": "Education", + "dcterms:relation": ["science-explain-v1"], + "dcterms:creator": "Isaac Newton", "prompt_text": "Explain the concept of {concept} in simple terms.", - "expected_output": "A concise and easy-to-understand explanation of the concept.", - "use_case": "Educational Resource", + "dcterms:type": "Educational Resource", "input_type": "Text", "output_type": "Text", - "version_number": "v1.0", - "last_updated": "2024-11-15", - "license": "Creative Commons", + "dcterms:hasVersion": "v1.0", + "dcterms:modified": "2024-11-15", + "dcterms:rights": "Creative Commons", "export_format": ["JSON", "Markdown"] - }, - { - "prompt_id": "PROMPT-0007", - "title": "Generate a Meal Plan", - "description": "Create a weekly meal plan based on dietary preferences.", - "category": "Health", - "models": ["meal plan", "health", "diet"], - "author": "Julia Child", - "prompt_text": "Create a weekly meal plan for a {diet} diet.", - "expected_output": "A complete 7-day meal plan with breakfast, lunch, and dinner.", - "use_case": "Health and Wellness", - "input_type": "Text", - "output_type": "List", - "version_number": "v1.3", - "last_updated": "2024-11-16", - "license": "Proprietary", - "export_format": ["JSON", "PDF"] } ] diff --git a/script.js b/script.js index b2f383e..1de2baa 100644 --- a/script.js +++ b/script.js @@ -1,3 +1,4 @@ +// Fetch and render the prompts async function fetchPrompts() { try { const response = await fetch('prompts.json'); @@ -9,35 +10,37 @@ async function fetchPrompts() { window.allPrompts = prompts; // Store for filtering } catch (error) { console.error('Error loading prompts:', error); - document.querySelector('tbody').innerHTML = 'Error loading prompts.'; + document.querySelector('tbody').innerHTML = 'Error loading prompts.'; } } +// Render the prompts in a table function displayTable(data) { const tableBody = document.querySelector('#promptTable tbody'); tableBody.innerHTML = ''; // Clear previous rows data.forEach(prompt => { const row = document.createElement('tr'); row.innerHTML = ` - ${prompt.prompt_id} - ${prompt.title} - ${prompt.description} - ${prompt.category} - ${prompt.models.join(', ')} - ${prompt.author} + ${prompt["dcterms:identifier"]} + ${prompt["dcterms:title"]} + ${prompt["dcterms:description"]} + ${prompt["dcterms:subject"]} + ${prompt["dcterms:relation"].join(', ')} + ${prompt["dcterms:creator"]} ${prompt.prompt_text} - ${prompt.use_case} + ${prompt["dcterms:type"]} ${prompt.input_type} ${prompt.output_type} - ${prompt.version_number} - ${prompt.last_updated} - ${prompt.license} + ${prompt["dcterms:hasVersion"]} + ${prompt["dcterms:modified"]} + ${prompt["dcterms:rights"]} ${prompt.export_format.join(', ')} `; tableBody.appendChild(row); }); } +// Sort the table based on column index function sortTable(columnIndex) { const table = document.getElementById('promptTable'); const tbody = table.querySelector('tbody'); @@ -70,23 +73,29 @@ function sortTable(columnIndex) { sortedRows.forEach(row => tbody.appendChild(row)); } +// Corrected filterPrompts function function filterPrompts() { const query = document.getElementById('search').value.toLowerCase(); - const filtered = window.allPrompts.filter(prompt => - prompt.title.toLowerCase().includes(query) || - prompt.description.toLowerCase().includes(query) || - prompt.category.toLowerCase().includes(query) || - prompt.models.some(model => model.toLowerCase().includes(query)) || - prompt.author.toLowerCase().includes(query) || - prompt.prompt_text.toLowerCase().includes(query) || - prompt.use_case.toLowerCase().includes(query) || - prompt.input_type.toLowerCase().includes(query) || - prompt.output_type.toLowerCase().includes(query) || - prompt.version_number.toLowerCase().includes(query) || - prompt.last_updated.toLowerCase().includes(query) || - prompt.license.toLowerCase().includes(query) || - prompt.export_format.some(format => format.toLowerCase().includes(query)) - ); + + const filtered = window.allPrompts.filter(prompt => { + return ( + (prompt["dcterms:identifier"]?.toLowerCase() || '').includes(query) || + (prompt["dcterms:title"]?.toLowerCase() || '').includes(query) || + (prompt["dcterms:description"]?.toLowerCase() || '').includes(query) || + (prompt["dcterms:subject"]?.toLowerCase() || '').includes(query) || + (prompt["dcterms:creator"]?.toLowerCase() || '').includes(query) || + (prompt.prompt_text?.toLowerCase() || '').includes(query) || + (prompt.input_type?.toLowerCase() || '').includes(query) || + (prompt.output_type?.toLowerCase() || '').includes(query) || + (prompt["dcterms:type"]?.toLowerCase() || '').includes(query) || + (prompt["dcterms:hasVersion"]?.toLowerCase() || '').includes(query) || + (prompt["dcterms:modified"]?.toLowerCase() || '').includes(query) || + (prompt["dcterms:rights"]?.toLowerCase() || '').includes(query) || + prompt["dcterms:relation"].some(model => model.toLowerCase().includes(query)) || + prompt.export_format.some(format => format.toLowerCase().includes(query)) + ); + }); + displayTable(filtered); }